The following works just fine:
Then /^I should see a button called "([^\"]*)"$/ do |name|
response.should have_selector("li") do |li|
li.should have_selector("a") do |a|
a.should contain(name)
end
end
end
Now I need to complement it with a step like this:
Then /^I should not see a button called "([^\"]*)"$/ do |name|
[snip...]
end
The standard "And I should not see" is not satisfactory, as it will pick up the target phrase anywhere in the page -- not just within buttons. I specifically need to check that no button with the target text are present.
My first instinct was to try something like this:
Then /^I should see a button called "([^\"]*)"$/ do |name|
response.should have_selector("li") do |li|
li.should have_selector("a") do |a|
a.should_not contain(name)
end
end
end
But of course that will pass as long as there's any button on the page that does not include the target text, even if there are also one or more buttons that do include the target text.
Your thoughts?
Many thanks,
Steven.