...
|
...
|
@@ -0,0 +1,119 @@ |
|
1
|
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) |
|
2
|
+ |
|
3
|
+# Commonly used webrat steps |
|
4
|
+# http://github.com/brynary/webrat |
|
5
|
+ |
|
6
|
+Given /^I am on (.+)$/ do |page_name| |
|
7
|
+ visit path_to(page_name) |
|
8
|
+end |
|
9
|
+ |
|
10
|
+When /^I go to (.+)$/ do |page_name| |
|
11
|
+ visit path_to(page_name) |
|
12
|
+end |
|
13
|
+ |
|
14
|
+When /^I press "([^\"]*)"$/ do |button| |
|
15
|
+ click_button(button) |
|
16
|
+end |
|
17
|
+ |
|
18
|
+When /^I follow "([^\"]*)"$/ do |link| |
|
19
|
+ click_link(link) |
|
20
|
+end |
|
21
|
+ |
|
22
|
+When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value| |
|
23
|
+ fill_in(field, :with => value) |
|
24
|
+end |
|
25
|
+ |
|
26
|
+When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field| |
|
27
|
+ select(value, :from => field) |
|
28
|
+end |
|
29
|
+ |
|
30
|
+# Use this step in conjunction with Rail's datetime_select helper. For example: |
|
31
|
+# When I select "December 25, 2008 10:00" as the date and time |
|
32
|
+When /^I select "([^\"]*)" as the date and time$/ do |time| |
|
33
|
+ select_datetime(time) |
|
34
|
+end |
|
35
|
+ |
|
36
|
+# Use this step when using multiple datetime_select helpers on a page or |
|
37
|
+# you want to specify which datetime to select. Given the following view: |
|
38
|
+# <%= f.label :preferred %><br /> |
|
39
|
+# <%= f.datetime_select :preferred %> |
|
40
|
+# <%= f.label :alternative %><br /> |
|
41
|
+# <%= f.datetime_select :alternative %> |
|
42
|
+# The following steps would fill out the form: |
|
43
|
+# When I select "November 23, 2004 11:20" as the "Preferred" date and time |
|
44
|
+# And I select "November 25, 2004 10:30" as the "Alternative" date and time |
|
45
|
+When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label| |
|
46
|
+ select_datetime(datetime, :from => datetime_label) |
|
47
|
+end |
|
48
|
+ |
|
49
|
+# Use this step in conjunction with Rail's time_select helper. For example: |
|
50
|
+# When I select "2:20PM" as the time |
|
51
|
+# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat |
|
52
|
+# will convert the 2:20PM to 14:20 and then select it. |
|
53
|
+When /^I select "([^\"]*)" as the time$/ do |time| |
|
54
|
+ select_time(time) |
|
55
|
+end |
|
56
|
+ |
|
57
|
+# Use this step when using multiple time_select helpers on a page or you want to |
|
58
|
+# specify the name of the time on the form. For example: |
|
59
|
+# When I select "7:30AM" as the "Gym" time |
|
60
|
+When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label| |
|
61
|
+ select_time(time, :from => time_label) |
|
62
|
+end |
|
63
|
+ |
|
64
|
+# Use this step in conjunction with Rail's date_select helper. For example: |
|
65
|
+# When I select "February 20, 1981" as the date |
|
66
|
+When /^I select "([^\"]*)" as the date$/ do |date| |
|
67
|
+ select_date(date) |
|
68
|
+end |
|
69
|
+ |
|
70
|
+# Use this step when using multiple date_select helpers on one page or |
|
71
|
+# you want to specify the name of the date on the form. For example: |
|
72
|
+# When I select "April 26, 1982" as the "Date of Birth" date |
|
73
|
+When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label| |
|
74
|
+ select_date(date, :from => date_label) |
|
75
|
+end |
|
76
|
+ |
|
77
|
+When /^I check "([^\"]*)"$/ do |field| |
|
78
|
+ check(field) |
|
79
|
+end |
|
80
|
+ |
|
81
|
+When /^I uncheck "([^\"]*)"$/ do |field| |
|
82
|
+ uncheck(field) |
|
83
|
+end |
|
84
|
+ |
|
85
|
+When /^I choose "([^\"]*)"$/ do |field| |
|
86
|
+ choose(field) |
|
87
|
+end |
|
88
|
+ |
|
89
|
+When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field| |
|
90
|
+ attach_file(field, path) |
|
91
|
+end |
|
92
|
+ |
|
93
|
+Then /^I should see "([^\"]*)"$/ do |text| |
|
94
|
+ response.should contain(text) |
|
95
|
+end |
|
96
|
+ |
|
97
|
+Then /^I should not see "([^\"]*)"$/ do |text| |
|
98
|
+ response.should_not contain(text) |
|
99
|
+end |
|
100
|
+ |
|
101
|
+Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value| |
|
102
|
+ field_labeled(field).value.should =~ /#{value}/ |
|
103
|
+end |
|
104
|
+ |
|
105
|
+Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value| |
|
106
|
+ field_labeled(field).value.should_not =~ /#{value}/ |
|
107
|
+end |
|
108
|
+ |
|
109
|
+Then /^the "([^\"]*)" checkbox should be checked$/ do |label| |
|
110
|
+ field_labeled(label).should be_checked |
|
111
|
+end |
|
112
|
+ |
|
113
|
+Then /^the "([^\"]*)" checkbox should not be checked$/ do |label| |
|
114
|
+ field_labeled(label).should_not be_checked |
|
115
|
+end |
|
116
|
+ |
|
117
|
+Then /^I should be on (.+)$/ do |page_name| |
|
118
|
+ URI.parse(current_url).path.should == path_to(page_name) |
|
119
|
+end |
...
|
...
|
|