Adding step definitions to facilitate merging of multiple consecutive "I (should|should not) see " clauses on single statement, adding one example as well

This commit is contained in:
Devendra 2012-08-09 16:00:39 +05:30
parent fb9da740bb
commit 3d21e89b3b
2 changed files with 17 additions and 15 deletions

View file

@ -8,9 +8,7 @@ Feature: new user registration
And I fill in "user_password" with "secret"
And I press "Continue"
Then I should be on the getting started page
And I should see "Well, hello there!"
And I should see "Who are you?"
And I should see "What are you into?"
And I should see "Well, hello there!" and "Who are you?" and "What are you into?"
Scenario: new user goes through the setup wizard
When I fill in the following:

View file

@ -105,12 +105,14 @@ Then /^(?:|I )should see JSON:$/ do |expected_json|
expected.should == actual
end
Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
with_scope(selector) do
if page.respond_to? :should
page.should have_content(text)
else
assert page.has_content?(text)
Then /^(?:|I )should see (\".+?\"[\s]*)(?:[\s]+within[\s]* "([^"]*)")?$/ do |vars,selector|
vars.scan(/"([^"]+?)"/).flatten.each do |text|
with_scope(selector) do
if page.respond_to? :should
page.should have_content(text)
else
assert page.has_content?(text)
end
end
end
end
@ -126,12 +128,14 @@ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, select
end
end
Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
with_scope(selector) do
if page.respond_to? :should
page.should have_no_content(text)
else
assert page.has_no_content?(text)
Then /^(?:|I )should not see (\".+?\"[\s]*)(?:[\s]+within[\s]* "([^"]*)")?$/ do |vars,selector|
vars.scan(/"([^"]+?)"/).flatten.each do |text|
with_scope(selector) do
if page.respond_to? :should
page.should have_no_content(text)
else
assert page.has_no_content?(text)
end
end
end
end