Reputation: 167
I am testing the creation of an account on a large consumer website using cucumber and capybara. When I run my capybara code in a regular pry session it all works. But when I run the cucumber test, the within
block doesn't seem to run and the sign up form doesn't get filled out.
env.rb
require 'capybara/cucumber'
require 'selenium-webdriver'
Before do
Capybara.default_driver = :selenium
end
test.feature
Scenario: Test consumer site account creation
* I create a new example.com account
step_definition.rb
When(/^I create a new account$/) do
visit 'http://example.com/myaccount'
find("#cboxClose").click if page.has_css?("#cboxClose")
require 'pry';binding.pry
within("form[name='newCustomer']") do
random_letters = SecureRandom.urlsafe_base64(5)
fill_in "Email Address", :with => "test-#{random_letters}@example.com"
fill_in "Create Password", :with => "Password123"
fill_in "Confirm Password", :with => "Password123"
click_on "Create Account"
end
end
When I run cucumber
and try to run the within
block in pry, I get this:
#<RSpec::Matchers::AliasedMatcher:0x007ff5e86b16e8
@base_matcher=
#<RSpec::Matchers::BuiltIn::BeWithin:0x007ff5e86b1710
@delta="form[name='newCustomer']">,
@description_block=
#<Proc:0x007ff5e4c34d08@/Users/anthonychung/.rvm/gems/ruby-2.1.2/gems/rspec-expectations-3.2.0/lib/rspec/matchers.rb:245 (lambda)>>
So I suspect RSpec's aliased matcher is overriding capybara's within method somehow.
When I try to do within(:css, "form[etc.]")
I get an argument error ArgumentError: wrong number of arguments (2 for 1)
.
Upvotes: 1
Views: 478