Testing form submission with Cucumber
- by picardo
I wrote a simple Cuke feature for a form on a demo site. The feature looks like this.
Given I am on the home page
When I set the "Start Date" to "2010-10-25"
And I set the "End Date" to "2011-1-3"
And I press the "Go" button
Then I should see "Cake Shop"
The idea is that after I press the Go button, a new page will load, showing a list of results, and one of the results should be "Cake Shop."
But I have not managed to get this to work. Is there something that I am missing?
Edit: here is the step definitions.
Given /^I am on the "([^"]*)" page$/ do |page|
visit root_path
end
When /^I set the "([^"]*)" to "([^"]*)"$/ do |field, date|
fill_in field, :with=>date
end
When /^I press the "([^"]*)" button$/ do |arg1|
click_button('Go')
end
The final step is defined in web_steps.rb I believe....and it's always there that it's failing.
Then I should see "Cake Shop" #
features/step_definitions/web_steps.rb:107
expected #has_content?("Cake Shop") to return true,
got false
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/web_steps.rb:110:in
block (2 levels) in <top (required)>'
./features/step_definitions/web_steps.rb:14:in
with_scope'
./features/step_definitions/web_steps.rb:108:in
/^(?:|I )should see "([^"]*)"(?:
within "([^"]*)")?$/'
features/specify_timerange.feature:12:in
Then I should see "Cake Shop"'