capybara

Capybara & Cucumber | Getting cookies

核能气质少年 提交于 2019-12-21 03:52:24
问题 I'm trying to get cookie values in the Cucumber step: Step definitions When /^I log in$/ do # code to log in end Then /^cookies should be set$/ do cookies[:author].should_not be_nil end Controller class SessionsController < ApplicationController def create cookies[:author] = 'me' redirect_to authors_path end end But it doesn't work: Result expected: not nil got: nil In the RSpec examples, all works just fine: Controller Spec require 'spec_helper' describe SessionsController do describe

Rails + Cucumber/Capybara: How to set/retrieve cookies in tests?

让人想犯罪 __ 提交于 2019-12-21 03:17:32
问题 I'm implementing a lazy login feature. My cucumber feature should describe it: Feature: User log in Scenario: Lazy login Given I didn't log out the last time I was on the site When I go to the homepage Then I should automatically be logged in And these are my step definitions: Given(/^I didn't log out the last time I was on the site$/) do user = FactoryGirl.create(:user) visit new_user_session_path fill_in('user[email]', with: user.email) fill_in('user[password]', with: 'test123') click

Why is this rspec request spec not updating the model?

偶尔善良 提交于 2019-12-20 21:00:52
问题 I have a requests spec for interactions with the User model. I want to make sure that Users with the Admin role can create/edit/destroy Users. I'm having a problem right now where the Edit action does not update the user. Everything works properly when I manually go through the actions on the site itself, but the tests fail to update the user. Here's my spec: it 'edits a user' do @user = FactoryGirl.create(:user) visit new_user_session_path unless current_path == new_user_session_path fill_in

How to fill tinymce-rails editor with capybara and selenium?

佐手、 提交于 2019-12-20 18:45:12
问题 I have trouble with using capybara to test tinymce form. I'm using tinymce-rails and have 7 editors in my form. Also I'm using asciimath plugin with tinymce. Everything works fine, but I'm unable to write tests to fill in tinymce editor. Here is how my step definition code looks like, very similar to what is described here: within_frame("content_ifr") do editor = page.find_by_id('tinymce') editor.native.send_keys 'test' end The problem is when I run the following: editor.native.clear # works,

Poltergeist throws JS errors when js_errors: false

被刻印的时光 ゝ 提交于 2019-12-20 18:07:27
问题 I have a large test suite that is using poltergeist and capybara. I keep getting the following error: One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details). I am pretty sure I have set js_errors: false but I am still getting the errors. I realize that the optimal solution is to fix the JS but I am inheriting legacy code and fixing

When to choose system test over integration test Rails 5.1?

北城以北 提交于 2019-12-20 17:36:26
问题 With the release of Rails 5.1, they included system tests. Which means we can test our JavaScript too in Rails. I see Rails guide explains a sample test creating article in both ways: via system test and via integration test. Now the question is: before Rails 5.1 I was writing complex test cases in integration tests. But now I have two options to write a test case. I can write test case like test: should create article in integration test, but I can also write the same test case in system

Capybara, finding within a css element

£可爱£侵袭症+ 提交于 2019-12-20 17:35:19
问题 I'm working with Ruby on Rails 3, Cucumber, and Capybara I've been searching for quite some time, and I can't figure out how to find a specific page element within a css tag. In my case, I need to make sure that a name is found inside of a table, and not in the "Welcome [Name]". I tried something like: within('table') do page.body.index("[Name]") end And I have a table with id='table' . But I'd like to know how to do this for any css element, such as: within('h2') do page.body.should have

Capybara, checking HTML element by ID and Class

半世苍凉 提交于 2019-12-20 17:33:36
问题 Two questions from a beginner. Q1- Is it possible to assert the existence of an HTML node by ID and class? For example, to see if the following element exists: <div class="drawer" id="first"....> I've seen you can use something like: page.should have_css('div.drawer') page.should have_css('div#first') but can we somehow query for the existence of both parameters, I've tried the following and didn't work: page.should have_selector("div", :class => "drawer", :id => "first") Q2- Is it possible

Is there a way to print javascript console.errors to the terminal with Rspec/Capybara/Selenium?

落爺英雄遲暮 提交于 2019-12-20 17:06:09
问题 When I run rspec, is it possible to have capybara/selenium report any javascript console.errors and other exceptions back to rspec? I have a whole bunch of tests failing, but my application is working when I manually test it. Without knowing the javascript errors that are likely blocking my single-page web app only during testing, it's really hard to figure out why the tests are failing. I've looked around and haven't really been able to find a solution to this. 回答1: I don't know if this will

Is there a way to print javascript console.errors to the terminal with Rspec/Capybara/Selenium?

大兔子大兔子 提交于 2019-12-20 17:05:08
问题 When I run rspec, is it possible to have capybara/selenium report any javascript console.errors and other exceptions back to rspec? I have a whole bunch of tests failing, but my application is working when I manually test it. Without knowing the javascript errors that are likely blocking my single-page web app only during testing, it's really hard to figure out why the tests are failing. I've looked around and haven't really been able to find a solution to this. 回答1: I don't know if this will