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,7 +105,8 @@ Then /^(?:|I )should see JSON:$/ do |expected_json|
expected.should == actual
end
Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
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)
@ -114,6 +115,7 @@ Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
end
end
end
end
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
regexp = Regexp.new(regexp)
@ -126,7 +128,8 @@ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, select
end
end
Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
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)
@ -135,6 +138,7 @@ Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selecto
end
end
end
end
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
regexp = Regexp.new(regexp)