I have a simple feature:
Feature: User can see the welcome page
Scenario: User can see the worker page
Given I am on the welcome page
Then I should see the Worker button
When I click on the Worker button
Then I should be on the Worker page
Scenario: User can see the requester page
Given I am on the welcome page
Then I should see the Requester button
When I click on the Requester button
Then I should be on the Requester page
What is strange is that I can pass the Then I should see the Worker button but cannot pass the click on test.
Here is my step definition
Then /^I should see the (.+) button$/ do |button_name|
page.has_button? button_name
end
When /^I click on the (.*) button$/ do |button_name|
#page.has_button? button_name
click_on button_name
end
Here is my welcome page
div.row
%div.span6
= button_to 'Worker', workers_path, :class => "btn btn-large btn-primary"
%div.span6
= button_to 'Requester', requesters_path, :class => "btn btn-large btn-primary"
Is the has_button? a method of Cabybara or Cucumber ?
Your Then step will always pass regardless of what’s on the page, since
has_button?returns true or false, neither of which will cause your Cucumber step to fail. For that to happen your step would have to throw an exception, which would best be achieved by using: