Created
April 11, 2010 05:29
-
-
Save chendo/362522 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When /^I fill in "([^\"]*)" with:$/ do |field, string| | |
fill_in(field, :with => string) | |
end | |
Then /^I should not see a "([^\"]*)" button$/ do |button_name| | |
lambda { | |
When %Q{I press "#{button_name}"} | |
}.should raise_error(Capybara::ElementNotFound) | |
end | |
When /^(.*) in the "([^\"]*)" section$/ do |action, title| | |
within :xpath, "//*[(h1|h2|h3|h4|h5|h6|legend|caption)/descendant-or-self::*[contains(text(), '#{title}')]]" do | |
When action | |
end | |
end | |
When /^(.*) in the "([^\"]*)" row$/ do |action, title| | |
within :xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{title}')]]" do | |
When action | |
end | |
end | |
When /^(.*) in the "([^\"]*)" row:$/ do |action, title, table| | |
within :xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{title}')]]" do | |
When action + ":", table | |
end | |
end | |
Then /^I should see (?:(css|xpath) )?selector "([^\"]*)" (\d+) times?$/ do |mode, selector, number| | |
mode = :css if mode.blank? | |
all(mode.to_sym, selector).should have(number.to_i).items | |
end | |
When /^(.*) inside (?:(xpath|css) )?"([^\"]*)"$/ do |step, selector_type, selector| | |
selector_type ||= Capybara.default_selector | |
within(selector_type.to_sym, selector) do | |
When step | |
end | |
end | |
When /^(.*) inside (?:(xpath|css) )?"([^\"]*)":$/ do |step, selector_type, selector, table| | |
selector_type ||= Capybara.default_selector | |
within(selector_type.to_sym, selector) do | |
When step + ":", table | |
end | |
end | |
Then /^I should( not)? see the following:$/ do |negate, table| | |
table.raw.each do |row| | |
Then %Q{I should#{negate} see "#{row[0]}"} | |
end | |
end | |
When /^(?:|I )attach the fixture file "([^\"]*)" to "([^\"]*)"(?: within "([^\"]*)")?$/ do |path, field, selector| | |
path = File.join(Rails.root, "spec", "fixtures", "uploads", path) | |
with_scope(selector) do | |
attach_file(field, path) | |
end | |
end | |
When /^I attach the following fixture files to "([^\"]*)":$/ do |field, table| | |
table.raw.each_with_index do |rows, index| | |
field_name = "#{field} ##{index+1}" | |
When %Q{I attach the fixture file "#{rows[0]}" to "#{field_name}"} | |
end | |
end | |
Then /^the "([^\"]*)" field should be disabled$/ do |field| | |
within("input[disabled]") do | |
find_field(field) | |
end | |
end | |
Then /^I should see the following in order:$/ do |table| | |
page.body.should match(Regexp.new(table.raw.join('.*?'), Regexp::MULTILINE)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment