Commit 7fe87c6253633a102b72516add30b973d4a347bf
1 parent
fcd07561
Exists in
master
and in
29 other branches
Removing webrat steps
Showing
1 changed file
with
0 additions
and
239 deletions
Show diff stats
features/step_definitions/webrat_steps.rb
| @@ -1,239 +0,0 @@ | @@ -1,239 +0,0 @@ | ||
| 1 | -# IMPORTANT: This file was generated by Cucumber 0.4.0 | ||
| 2 | -# Edit at your own peril - it's recommended to regenerate this file | ||
| 3 | -# in the future when you upgrade to a newer version of Cucumber. | ||
| 4 | -# Consider adding your own code to a new file instead of editing this one. | ||
| 5 | - | ||
| 6 | -require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) | ||
| 7 | - | ||
| 8 | -# Commonly used webrat steps | ||
| 9 | -# http://github.com/brynary/webrat | ||
| 10 | - | ||
| 11 | -Given /^I am on (.+)$/ do |page_name| | ||
| 12 | - visit path_to(page_name) | ||
| 13 | -end | ||
| 14 | - | ||
| 15 | -When /^I go to (.+)$/ do |page_name| | ||
| 16 | - visit path_to(page_name) | ||
| 17 | -end | ||
| 18 | - | ||
| 19 | -When /^I visit "([^\"]*)" and wait$/ do |page_name| | ||
| 20 | - visit path_to(page_name) | ||
| 21 | - selenium.wait_for_page_to_load(10000) | ||
| 22 | -# selenium.wait_for_page | ||
| 23 | -end | ||
| 24 | - | ||
| 25 | -When /^I press "([^\"]*)"$/ do |button| | ||
| 26 | - click_button(button) | ||
| 27 | -end | ||
| 28 | - | ||
| 29 | -When /^I press "([^\"]*)" and wait$/ do |button| | ||
| 30 | - click_button(button) | ||
| 31 | - selenium.wait_for_page_to_load(10000) | ||
| 32 | -end | ||
| 33 | - | ||
| 34 | -When /^I follow "([^\"]*)"$/ do |link| | ||
| 35 | - click_link(link) | ||
| 36 | -end | ||
| 37 | - | ||
| 38 | -When /^I follow "([^\"]*)" and wait$/ do |link| | ||
| 39 | - click_link(link) | ||
| 40 | - selenium.wait_for_page_to_load(10000) | ||
| 41 | -end | ||
| 42 | - | ||
| 43 | -When /^I follow "([^\"]*)" and wait until "([^\"]*)" is present$/ do |link, element| | ||
| 44 | - click_link(link) | ||
| 45 | - selenium.wait_for_element(string_to_element_locator(element)) | ||
| 46 | -end | ||
| 47 | - | ||
| 48 | -When /^I follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent| | ||
| 49 | - click_link_within(parent, link) | ||
| 50 | -end | ||
| 51 | - | ||
| 52 | -When /^I follow "([^\"]*)" within "([^\"]*)" and wait$/ do |link, parent| | ||
| 53 | - click_link_within(parent, link) | ||
| 54 | - selenium.wait_for_page_to_load(10000) | ||
| 55 | -end | ||
| 56 | - | ||
| 57 | -When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value| | ||
| 58 | - if response.class.to_s == 'Webrat::SeleniumResponse' | ||
| 59 | - response.selenium.type("//*[@id=//label[contains(., '#{field}')]/@for]", value) | ||
| 60 | - else | ||
| 61 | - fill_in(field, :with => value) | ||
| 62 | - end | ||
| 63 | -end | ||
| 64 | - | ||
| 65 | -When /^I fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field| | ||
| 66 | - fill_in(field, :with => value) | ||
| 67 | -end | ||
| 68 | - | ||
| 69 | -# Use this to fill in an entire form with data from a table. Example: | ||
| 70 | -# | ||
| 71 | -# When I fill in the following: | ||
| 72 | -# | Account Number | 5002 | | ||
| 73 | -# | Expiry date | 2009-11-01 | | ||
| 74 | -# | Note | Nice guy | | ||
| 75 | -# | Wants Email? | | | ||
| 76 | -# | ||
| 77 | -# TODO: Add support for checkbox, select og option | ||
| 78 | -# based on naming conventions. | ||
| 79 | -# | ||
| 80 | -When /^I fill in the following:$/ do |fields| | ||
| 81 | - fields.rows_hash.each do |name, value| | ||
| 82 | - When %{I fill in "#{name}" with "#{value}"} | ||
| 83 | - end | ||
| 84 | -end | ||
| 85 | - | ||
| 86 | -When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field| | ||
| 87 | - if response.class.to_s == 'Webrat::SeleniumResponse' | ||
| 88 | - response.selenium.select("//*[@id=//label[contains(., '#{field}')]/@for]", value) | ||
| 89 | - else | ||
| 90 | - select(value, :from => field) | ||
| 91 | - end | ||
| 92 | -end | ||
| 93 | - | ||
| 94 | -# Use this step in conjunction with Rail's datetime_select helper. For example: | ||
| 95 | -# When I select "December 25, 2008 10:00" as the date and time | ||
| 96 | -When /^I select "([^\"]*)" as the date and time$/ do |time| | ||
| 97 | - select_datetime(time) | ||
| 98 | -end | ||
| 99 | - | ||
| 100 | -# Use this step when using multiple datetime_select helpers on a page or | ||
| 101 | -# you want to specify which datetime to select. Given the following view: | ||
| 102 | -# <%= f.label :preferred %><br /> | ||
| 103 | -# <%= f.datetime_select :preferred %> | ||
| 104 | -# <%= f.label :alternative %><br /> | ||
| 105 | -# <%= f.datetime_select :alternative %> | ||
| 106 | -# The following steps would fill out the form: | ||
| 107 | -# When I select "November 23, 2004 11:20" as the "Preferred" date and time | ||
| 108 | -# And I select "November 25, 2004 10:30" as the "Alternative" date and time | ||
| 109 | -When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label| | ||
| 110 | - select_datetime(datetime, :from => datetime_label) | ||
| 111 | -end | ||
| 112 | - | ||
| 113 | -# Use this step in conjunction with Rail's time_select helper. For example: | ||
| 114 | -# When I select "2:20PM" as the time | ||
| 115 | -# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat | ||
| 116 | -# will convert the 2:20PM to 14:20 and then select it. | ||
| 117 | -When /^I select "([^\"]*)" as the time$/ do |time| | ||
| 118 | - select_time(time) | ||
| 119 | -end | ||
| 120 | - | ||
| 121 | -# Use this step when using multiple time_select helpers on a page or you want to | ||
| 122 | -# specify the name of the time on the form. For example: | ||
| 123 | -# When I select "7:30AM" as the "Gym" time | ||
| 124 | -When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label| | ||
| 125 | - select_time(time, :from => time_label) | ||
| 126 | -end | ||
| 127 | - | ||
| 128 | -# Use this step in conjunction with Rail's date_select helper. For example: | ||
| 129 | -# When I select "February 20, 1981" as the date | ||
| 130 | -When /^I select "([^\"]*)" as the date$/ do |date| | ||
| 131 | - select_date(date) | ||
| 132 | -end | ||
| 133 | - | ||
| 134 | -# Use this step when using multiple date_select helpers on one page or | ||
| 135 | -# you want to specify the name of the date on the form. For example: | ||
| 136 | -# When I select "April 26, 1982" as the "Date of Birth" date | ||
| 137 | -When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label| | ||
| 138 | - select_date(date, :from => date_label) | ||
| 139 | -end | ||
| 140 | - | ||
| 141 | -When /^I check "([^\"]*)"$/ do |field| | ||
| 142 | - check(field) | ||
| 143 | -end | ||
| 144 | - | ||
| 145 | -When /^I uncheck "([^\"]*)"$/ do |field| | ||
| 146 | - uncheck(field) | ||
| 147 | -end | ||
| 148 | - | ||
| 149 | -When /^I choose "([^\"]*)"$/ do |field| | ||
| 150 | - choose(field) | ||
| 151 | -end | ||
| 152 | - | ||
| 153 | -When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field| | ||
| 154 | - attach_file(field, path) | ||
| 155 | -end | ||
| 156 | - | ||
| 157 | -Then /^I should see "([^\"]*)"$/ do |text| | ||
| 158 | - response.should contain(text) | ||
| 159 | -end | ||
| 160 | - | ||
| 161 | -Then /^I should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector| | ||
| 162 | - if response.class.to_s == 'Webrat::SeleniumResponse' | ||
| 163 | - response.selenium.text('css=' + selector).should include(text) | ||
| 164 | - else | ||
| 165 | - within(selector) do |content| | ||
| 166 | - content.should contain(text) | ||
| 167 | - end | ||
| 168 | - end | ||
| 169 | -end | ||
| 170 | - | ||
| 171 | -Then /^I should see \/([^\/]*)\/$/ do |regexp| | ||
| 172 | - regexp = Regexp.new(regexp) | ||
| 173 | - response.should contain(regexp) | ||
| 174 | -end | ||
| 175 | - | ||
| 176 | -Then /^I should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector| | ||
| 177 | - within(selector) do |content| | ||
| 178 | - regexp = Regexp.new(regexp) | ||
| 179 | - content.should contain(regexp) | ||
| 180 | - end | ||
| 181 | -end | ||
| 182 | - | ||
| 183 | -Then /^I should not see "([^\"]*)"$/ do |text| | ||
| 184 | - response.should_not contain(text) | ||
| 185 | -end | ||
| 186 | - | ||
| 187 | -Then /^I should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector| | ||
| 188 | - if response.class.to_s == 'Webrat::SeleniumResponse' | ||
| 189 | - response.selenium.text('css=' + selector).should_not include(text) | ||
| 190 | - else | ||
| 191 | - within(selector) do |content| | ||
| 192 | - content.should_not contain(text) | ||
| 193 | - end | ||
| 194 | - end | ||
| 195 | -end | ||
| 196 | - | ||
| 197 | -Then /^I should not see \/([^\/]*)\/$/ do |regexp| | ||
| 198 | - regexp = Regexp.new(regexp) | ||
| 199 | - response.should_not contain(regexp) | ||
| 200 | -end | ||
| 201 | - | ||
| 202 | -Then /^I should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector| | ||
| 203 | - within(selector) do |content| | ||
| 204 | - regexp = Regexp.new(regexp) | ||
| 205 | - content.should_not contain(regexp) | ||
| 206 | - end | ||
| 207 | -end | ||
| 208 | - | ||
| 209 | -Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value| | ||
| 210 | - if response.class.to_s == 'Webrat::SeleniumResponse' | ||
| 211 | - response.selenium.get_value("//*[@id=//label[contains(., '#{field}')]/@for]").should match(value) | ||
| 212 | - else | ||
| 213 | - field_labeled(field).value.should =~ /#{value}/ | ||
| 214 | - end | ||
| 215 | -end | ||
| 216 | - | ||
| 217 | -Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value| | ||
| 218 | - field_labeled(field).value.should_not =~ /#{value}/ | ||
| 219 | -end | ||
| 220 | - | ||
| 221 | -Then /^the "([^\"]*)" checkbox should be checked$/ do |label| | ||
| 222 | - field_labeled(label).should be_checked | ||
| 223 | -end | ||
| 224 | - | ||
| 225 | -Then /^the "([^\"]*)" checkbox should not be checked$/ do |label| | ||
| 226 | - field_labeled(label).should_not be_checked | ||
| 227 | -end | ||
| 228 | - | ||
| 229 | -Then /^I should be on (.+)$/ do |page_name| | ||
| 230 | - if response.class.to_s == 'Webrat::SeleniumResponse' | ||
| 231 | - URI.parse(response.selenium.get_location).path.should == path_to(page_name) | ||
| 232 | - else | ||
| 233 | - URI.parse(current_url).path.should == path_to(page_name) | ||
| 234 | - end | ||
| 235 | -end | ||
| 236 | - | ||
| 237 | -Then /^show me the page$/ do | ||
| 238 | - save_and_open_page | ||
| 239 | -end |