lib/spreewald/web_steps.rb in spreewald-1.6.0 vs lib/spreewald/web_steps.rb in spreewald-1.7.0
- old
+ new
@@ -31,15 +31,15 @@
require 'spreewald_support/web_steps_helpers'
require 'uri'
require 'cgi'
-# You can append `within [selector]` to any other web step
+# You can append `within [selector]` to any other web step.
#
# Example:
#
-# Then I should see "some text" within ".page_body"
+# Then I should see "some text" within ".page_body"
When /^(.*) within (.*[^:])$/ do |nested_step, parent|
patiently do
with_scope(parent) { step(nested_step) }
end
end.overridable(:priority => 10)
@@ -97,16 +97,16 @@
# Fill in text field with multi-line block
# You can use a doc string to supply multi-line text
#
# Example:
#
-# When I fill in "some field" with:
-# """
-# Apple
-# Banana
-# Pear
-# """
+# When I fill in "some field" with:
+# """
+# Apple
+# Banana
+# Pear
+# """
When /^(?:|I )fill in "([^"]*)" (?:with|for):$/ do |field, value|
patiently do
fill_in(field, :with => value)
end
end.overridable
@@ -216,14 +216,13 @@
# Checks that a list of label/value pairs are visible as control inputs.
#
# Example:
#
-# Then I should see a form with the following values:
-# | E-mail | foo@bar.com |
-# | Role | Administrator |
-#
+# Then I should see a form with the following values:
+# | E-mail | foo@bar.com |
+# | Role | Administrator |
Then /^I should see a form with the following values:$/ do |table|
expectations = table.raw
expectations.each do |label, expected_value|
step %(the "#{label}" field should contain "#{expected_value}")
end
@@ -283,13 +282,13 @@
end
end.overridable
# Example:
#
-# I should have the following query string:
-# | locale | de |
-# | currency_code | EUR |
+# I should have the following query string:
+# | locale | de |
+# | currency_code | EUR |
#
# Succeeds when the URL contains the given `locale` and `currency_code` params
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
patiently do
query = URI.parse(current_url).query
@@ -494,11 +493,10 @@
# Then "Sponsor" should link to "http://makandra.com/"
#
# Don't forget the trailing slash. Otherwise you'll get the error
# expected: /http:\/\/makandra.com(\?[^\/]*)?$/
# got: "http://makandra.com/" (using =~)
-#
Then /^"([^"]*)" should link to "([^"]*)"$/ do |link_label, target|
patiently do
link = find_link(link_label)
link[:href].should =~ /#{Regexp.escape target}(\?[^\/]*)?$/ # ignore trailing timestamps
end
@@ -510,11 +508,10 @@
#
# Then I should see an element ".panel"
# Then I should see the element ".panel"
# Then I should not see an element ".sidebar"
# Then I should not see the element ".sidebar"
-#
Then /^I should (not )?see (?:an|the) element "([^"]+)"$/ do |negate, selector|
expectation = negate ? :should_not : :should
patiently do
page.send(expectation, have_css(selector))
end
@@ -526,11 +523,10 @@
#
# Then I should see an element for the panel
# Then I should see the element for the panel
# Then I should not see an element for the sidebar
# Then I should not see the element for the sidebar
-#
Then /^I should (not )?see (?:an|the) element for (.*?)$/ do |negate, locator|
expectation = negate ? :should_not : :should
selector = _selector_for(locator)
patiently do
page.send(expectation, have_css(selector))
@@ -546,12 +542,11 @@
# Click a link within an element matching the given selector. Will try to be clever
# and disregard elements that don't contain a matching link.
#
# Example:
#
-# When I follow "Read more" inside any ".text_snippet"
-#
+# When I follow "Read more" inside any ".text_snippet"
When /^I follow "([^"]*)" inside any "([^"]*)"$/ do |label, selector|
node = find("#{selector} a", :text => label)
node.click
end.overridable
@@ -600,15 +595,14 @@
# Checks that these strings are rendered in the given order in a single line or in multiple lines
#
# Example:
#
-# Then I should see in this order:
-# | Alpha Group |
-# | Augsburg |
-# | Berlin |
-# | Beta Group |
-#
+# Then I should see in this order:
+# | Alpha Group |
+# | Augsburg |
+# | Berlin |
+# | Beta Group |
Then /^I should see in this order:?$/ do |text|
if text.is_a?(String)
lines = text.split(/\n/)
else
lines = text.raw.flatten