I'm new to using Cucumber and Capybara. I've set up a test on a webpage, and run into this error when attempting to run.
undefined method `locate' for #<Webrat::Session:0x007fdf2ac41c18> (NoMethodError)
./Documents/Work:etc./Raster Media/Cucumber/Klinq Testing/1/features/step_definitions/steps.rb:14:in `/^I make sure the (.*) box is checked$/'
./Documents/Work:etc./Raster Media/Cucumber/Klinq Testing/1/features/account.feature:16:in `And I make sure the vendor[tos] box is checked'
I'm trying to get it to make sure a box is checked in my webpage. Here is my step definition:
When /^I make sure the (.*) box is checked$/ do |box|
locate(:css, 'box').set(true)
My env.rb file:
require 'rspec/expectations'
require 'test/unit/assertions'
require 'capybara'
require 'webrat'
World(Test::Unit::Assertions)
Webrat.configure do |config|
config.mode = :mechanize
end
World do
session = Webrat::Session.new
session.extend(Webrat::Methods)
session.extend(Webrat::Matchers)
session
end
Here is my source code for the checkbox
<input type="checkbox" name="vendor[tos]" value="1" id="vendor[tos]" class="one left">
It would also be helpful to know how to set a checkbox to checked if it doesn't pass this test.
Thanks so much to anyone who helps.