Reputation: 1851
I have a form that has this
<%= submit_tag 'Search Event' %>
and a cucumber step that says
And I should see "Search Event"
but this step fails.. why is that?
Here is the error i get
expected #has_content?("Search Event") to return true, got false (RSpec::Expectations::ExpectationNotMetError)
Upvotes: 1
Views: 2202
Reputation: 1973
This work in positive:
Then /^I should see "([^"]*)" button/ do |name|
should have_button name
end
in negative:
Then /^I should not see "([^"]*)" button/ do |name|
should have_no_button name
end
Upvotes: 1
Reputation: 1451
Write your own step, i.e. using capybara (rspec as well):
Then /^I should see "([^"]*)" button/ do |name|
find_button(name).should_not be_nil
end
Upvotes: 13
Reputation: 978
I think this doesn't work because the button label is not text content -- it's the value attribute of the submit button.
Upvotes: 1