cucumber-rails2 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/HACKING.rdoc +24 -0
- data/History.txt +145 -0
- data/LICENSE +22 -0
- data/README.rdoc +70 -0
- data/Rakefile +24 -0
- data/VERSION +1 -0
- data/config/.gitignore +1 -0
- data/cucumber-rails2.gemspec +111 -0
- data/dev_tasks/cucumber.rake +5 -0
- data/dev_tasks/rspec.rake +13 -0
- data/features/rails2.feature +64 -0
- data/features/rails3.feature +97 -0
- data/features/rerun_profile.feature +39 -0
- data/features/step_definitions/cucumber_rails_steps.rb +35 -0
- data/features/support/env.rb +4 -0
- data/features/support/matchers/files.rb +17 -0
- data/generators/cucumber/USAGE +13 -0
- data/generators/cucumber/cucumber_generator.rb +88 -0
- data/generators/feature/USAGE +12 -0
- data/generators/feature/feature_generator.rb +47 -0
- data/lib/cucumber/rails/action_controller.rb +65 -0
- data/lib/cucumber/rails/active_record.rb +34 -0
- data/lib/cucumber/rails/capybara_javascript_emulation.rb +81 -0
- data/lib/cucumber/rails/rspec.rb +22 -0
- data/lib/cucumber/rails/test_unit.rb +7 -0
- data/lib/cucumber/rails/world.rb +48 -0
- data/lib/cucumber/web/tableish.rb +118 -0
- data/lib/generators/cucumber/feature/USAGE +16 -0
- data/lib/generators/cucumber/feature/feature_base.rb +29 -0
- data/lib/generators/cucumber/feature/feature_generator.rb +37 -0
- data/lib/generators/cucumber/feature/named_arg.rb +17 -0
- data/lib/generators/cucumber/install/USAGE +15 -0
- data/lib/generators/cucumber/install/install_base.rb +202 -0
- data/lib/generators/cucumber/install/install_generator.rb +64 -0
- data/spec/cucumber/web/tableish_spec.rb +192 -0
- data/spec/generators/cucumber/install/install_base_spec.rb +84 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +6 -0
- data/templates/feature/feature.erb +63 -0
- data/templates/feature/steps.erb +14 -0
- data/templates/install/config/cucumber.yml.erb +8 -0
- data/templates/install/environments/cucumber.rb.erb +37 -0
- data/templates/install/script/cucumber +10 -0
- data/templates/install/step_definitions/capybara_steps.rb.erb +214 -0
- data/templates/install/step_definitions/web_steps_cs.rb.erb +136 -0
- data/templates/install/step_definitions/web_steps_da.rb.erb +114 -0
- data/templates/install/step_definitions/web_steps_de.rb.erb +136 -0
- data/templates/install/step_definitions/web_steps_es.rb.erb +136 -0
- data/templates/install/step_definitions/web_steps_ja.rb.erb +139 -0
- data/templates/install/step_definitions/web_steps_ko.rb.erb +141 -0
- data/templates/install/step_definitions/web_steps_no.rb.erb +114 -0
- data/templates/install/step_definitions/web_steps_pt-BR.rb.erb +140 -0
- data/templates/install/step_definitions/webrat_steps.rb.erb +276 -0
- data/templates/install/support/_rails_each_run.rb.erb +35 -0
- data/templates/install/support/_rails_prefork.rb.erb +12 -0
- data/templates/install/support/capybara.rb +9 -0
- data/templates/install/support/edit_warning.txt +5 -0
- data/templates/install/support/paths.rb +33 -0
- data/templates/install/support/rails.rb.erb +4 -0
- data/templates/install/support/rails_spork.rb.erb +13 -0
- data/templates/install/support/webrat.rb +8 -0
- data/templates/install/tasks/cucumber.rake.erb +48 -0
- metadata +143 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
<%= embed_file('support/edit_warning.txt') %>
|
3
|
+
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
5
|
+
|
6
|
+
Gitt /^(?:at )jeg står på (.*)$/ do |page_name|
|
7
|
+
Given %{I am on #{page_name}}
|
8
|
+
end
|
9
|
+
|
10
|
+
Når /^jeg går til (.*)$/ do |page_name|
|
11
|
+
When %{I go to #{page_name}}
|
12
|
+
end
|
13
|
+
|
14
|
+
Når /^jeg trykker "([^"]*)"$/ do |button|
|
15
|
+
When %{I press "#{button}"}
|
16
|
+
end
|
17
|
+
|
18
|
+
Når /^jeg klikker "([^"]*)"$/ do |link|
|
19
|
+
When %{I follow "#{link}"}
|
20
|
+
end
|
21
|
+
|
22
|
+
Når /^jeg klikker "([^"]*)" under "([^"]*)"$/ do |link, parent|
|
23
|
+
When %{I follow "#{link}" within "#{parent}"}
|
24
|
+
end
|
25
|
+
|
26
|
+
Når /^jeg fyller inn "([^"]*)" med "([^"]*)"$/ do |field, value|
|
27
|
+
When %{I fill in "#{field}" with "#{value}"}
|
28
|
+
end
|
29
|
+
|
30
|
+
Når /^jeg fyller inn "([^"]*)" for "([^"]*)"$/ do |value, field|
|
31
|
+
When %{I fill in "#{value}" for "#{field}"}
|
32
|
+
end
|
33
|
+
|
34
|
+
Når /^jeg fyller inn følgende:$/ do |fields|
|
35
|
+
When %{I fill in the following:}, fields
|
36
|
+
end
|
37
|
+
|
38
|
+
Når /^jeg velger "([^"]*)" fra "([^"]*)"$/ do |value, field|
|
39
|
+
When %{I select "#{value}" from "#{field}"}
|
40
|
+
end
|
41
|
+
|
42
|
+
# Missing: date stuff
|
43
|
+
|
44
|
+
Når /^jeg krysser av "([^"]*)"$/ do |field|
|
45
|
+
When %{I check "#{field}"}
|
46
|
+
end
|
47
|
+
|
48
|
+
Når /^jeg fjerner avkrysning for "([^"]*)"$/ do |field|
|
49
|
+
When %{I uncheck "#{field}"}
|
50
|
+
end
|
51
|
+
|
52
|
+
Når /^jeg velger "([^"]*)"$/ do |field|
|
53
|
+
When %{I choose "#{field}"}
|
54
|
+
end
|
55
|
+
|
56
|
+
Når /^jeg legger ved filen "([^"]*)" til "([^"]*)"$/ do |path, field|
|
57
|
+
When %{I attach the file "#{path}" to "#{field}"}
|
58
|
+
end
|
59
|
+
|
60
|
+
Så /^(?:skal jeg|jeg skal) se "([^"]*)"$/ do |text|
|
61
|
+
Then %{I should see "#{text}"}
|
62
|
+
end
|
63
|
+
|
64
|
+
Så /^(?:skal jeg|jeg skal) se "([^"]*)" under "([^"]*)"$/ do |text, selector|
|
65
|
+
Then %{I should see "#{text}" within "#{selector}"}
|
66
|
+
end
|
67
|
+
|
68
|
+
Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/$/ do |regexp|
|
69
|
+
Then %{I should see /#{regexp}/}
|
70
|
+
end
|
71
|
+
|
72
|
+
Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/ under "([^"]*)"$/ do |regexp, selector|
|
73
|
+
Then %{I should see /#{regexp}/ within "#{selector}"}
|
74
|
+
end
|
75
|
+
|
76
|
+
Så /^(?:skal jeg|jeg skal) ikke se "([^"]*)"$/ do |text|
|
77
|
+
Then %{I should not see "#{text}"}
|
78
|
+
end
|
79
|
+
|
80
|
+
Så /^(?:skal jeg|jeg skal) ikke se "([^"]*)" under "([^"]*)"$/ do |text, selector|
|
81
|
+
Then %{I should not see "#{text}" within "#{selector}"}
|
82
|
+
end
|
83
|
+
|
84
|
+
Så /^(?:skal jeg|jeg skal) ikke se \/([^\/]*)\/$/ do |regexp|
|
85
|
+
Then %{I should not see /#{regexp}/}
|
86
|
+
end
|
87
|
+
|
88
|
+
Så /^(?:skal jeg|jeg skal) ikke se \/([^\/]*)\/ under "([^"]*)"$/ do |regexp, selector|
|
89
|
+
Then %{I should not see /#{regexp}/ within "#{selector}"}
|
90
|
+
end
|
91
|
+
|
92
|
+
Så /^(?:skal )"([^"]*)" feltet (?:skal )inneholde "([^"]*)"$/ do |field, value|
|
93
|
+
Then %{the "#{field}" field should contain "#{value}"}
|
94
|
+
end
|
95
|
+
|
96
|
+
Så /^(?:skal ) "([^"]*)" feltet (?:skal )ikke inneholde "([^"]*)"$/ do |field, value|
|
97
|
+
Then %{the "#{field}" field should not contain "#{value}"}
|
98
|
+
end
|
99
|
+
|
100
|
+
Så /^(?:skal ) "([^"]*)" avkrysningsboksen (?:skal )være krysset av$/ do |label|
|
101
|
+
Then %{the "#{label}" checkbox should be checked}
|
102
|
+
end
|
103
|
+
|
104
|
+
Så /^(?:skal ) "([^"]*)" avkrysningsboksen (?:skal )ikke være krysset av$/ do |label|
|
105
|
+
Then %{the "#{label}" checkbox should not be checked}
|
106
|
+
end
|
107
|
+
|
108
|
+
Så /^(?:skal jeg|jeg skal) komme til (.+)$/ do |page_name|
|
109
|
+
Then %{I should be on #{page_name}}
|
110
|
+
end
|
111
|
+
|
112
|
+
Så /^vil jeg se siden$/ do |page_name|
|
113
|
+
Then %{show me the page}
|
114
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
<%= embed_file('support/edit_warning.txt') %>
|
3
|
+
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
5
|
+
|
6
|
+
Dado /^que eu esteja na (.+)$/ do |page_name|
|
7
|
+
Given %{I am on #{page_name}}
|
8
|
+
end
|
9
|
+
|
10
|
+
Quando /^eu vou para (.+)$/ do |page_name|
|
11
|
+
When %{I go to #{page_name}}
|
12
|
+
end
|
13
|
+
|
14
|
+
Quando /^eu aperto "([^"]*)"$/ do |button|
|
15
|
+
When %{I press "#{button}"}
|
16
|
+
end
|
17
|
+
|
18
|
+
Quando /^eu clico "([^"]*)"$/ do |link|
|
19
|
+
When %{I follow "#{link}"}
|
20
|
+
end
|
21
|
+
|
22
|
+
Quando /^eu clico "([^"]*)" dentro de "([^"]*)"$/ do |link, parent|
|
23
|
+
When %{I follow "#{link}" within "#{parent}"}
|
24
|
+
end
|
25
|
+
|
26
|
+
Quando /^eu preencho "([^"]*)" com "([^"]*)"$/ do |field, value|
|
27
|
+
When %{I fill in "#{field}" with "#{value}"}
|
28
|
+
end
|
29
|
+
|
30
|
+
Quando /^eu preencho "([^"]*)" para "([^"]*)"$/ do |value, field|
|
31
|
+
When %{I fill in "#{value}" for "#{field}"}
|
32
|
+
end
|
33
|
+
|
34
|
+
Quando /^eu preencho o seguinte:$/ do |fields|
|
35
|
+
When %{I fill in the following:}, fields
|
36
|
+
end
|
37
|
+
|
38
|
+
Quando /^eu seleciono "([^"]*)" de "([^"]*)"$/ do |value, field|
|
39
|
+
When %{I select "#{value}" from "#{field}"}
|
40
|
+
end
|
41
|
+
|
42
|
+
Quando /^eu seleciono "([^"]*)" como a data e a hora$/ do |time|
|
43
|
+
When %{I select "#{time}" as the date and time}
|
44
|
+
end
|
45
|
+
|
46
|
+
Quando /^eu seleciono "([^"]*)" como a data e a hora "([^"]*)"$/ do |datetime, datetime_label|
|
47
|
+
When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
|
48
|
+
end
|
49
|
+
|
50
|
+
Quando /^eu seleciono "([^"]*)" como a hora$/ do |time|
|
51
|
+
When %{I select "#{time}" as the time}
|
52
|
+
end
|
53
|
+
|
54
|
+
Quando /^eu seleciono "([^"]*)" como a hora "([^"]*)"$/ do |time, time_label|
|
55
|
+
When %{I select "#{time}" as the "#{time_label}" time}
|
56
|
+
end
|
57
|
+
|
58
|
+
Quando /^eu seleciono "([^"]*)" como a data$/ do |date|
|
59
|
+
When %{I select "#{date}" as the date}
|
60
|
+
end
|
61
|
+
|
62
|
+
Quando /^eu seleciono "([^"]*)" como a data "([^"]*)"$/ do |date, date_label|
|
63
|
+
When %{I select "#{date}" as the "#{date_label}" date}
|
64
|
+
end
|
65
|
+
|
66
|
+
Quando /^eu seleciono "([^"]*)" como "([^"]*)"$/ do |date, date_label|
|
67
|
+
When %{I select "#{date}" as the "#{date_label}" date}
|
68
|
+
end
|
69
|
+
|
70
|
+
Quando /^eu marco "([^"]*)"$/ do |field|
|
71
|
+
When %{I check "#{field}"}
|
72
|
+
end
|
73
|
+
|
74
|
+
Quando /^eu desmarco "([^"]*)"$/ do |field|
|
75
|
+
When %{I uncheck "#{field}"}
|
76
|
+
end
|
77
|
+
|
78
|
+
Quando /^eu escolho "([^"]*)"$/ do |field|
|
79
|
+
When %{I choose "#{field}"}
|
80
|
+
end
|
81
|
+
|
82
|
+
Quando /^eu anexo o arquivo em "([^"]*)" a "([^"]*)"$/ do |path, field|
|
83
|
+
When %{I attach the file "#{path}" to "#{field}"}
|
84
|
+
end
|
85
|
+
|
86
|
+
Então /^eu devo ver "([^"]*)"$/ do |text|
|
87
|
+
Then %{I should see "#{text}"}
|
88
|
+
end
|
89
|
+
|
90
|
+
Então /^eu devo ver "([^"]*)" dentro de "([^"]*)"$/ do |text, selector|
|
91
|
+
Then %{I should see "#{text}" within "#{selector}"}
|
92
|
+
end
|
93
|
+
|
94
|
+
Então /^eu devo ver \/([^\/]*)\/$/ do |regexp|
|
95
|
+
Then %{I should see /#{regexp}/}
|
96
|
+
end
|
97
|
+
|
98
|
+
Então /^eu devo ver \/([^\/]*)\/ dentro de "([^"]*)"$/ do |regexp, selector|
|
99
|
+
Then %{I should see /#{regexp}/ within "#{selector}"}
|
100
|
+
end
|
101
|
+
|
102
|
+
Então /^eu não devo ver "([^"]*)"$/ do |text|
|
103
|
+
Then %{I should not see "#{text}"}
|
104
|
+
end
|
105
|
+
|
106
|
+
Então /^eu não devo ver "([^"]*)" dentro de "([^"]*)"$/ do |text, selector|
|
107
|
+
Then %{I should not see "#{text}" within "#{selector}"}
|
108
|
+
end
|
109
|
+
|
110
|
+
Então /^eu não devo ver \/([^\/]*)\/$/ do |regexp|
|
111
|
+
Then %{I should not see /#{regexp}/}
|
112
|
+
end
|
113
|
+
|
114
|
+
Então /^eu não devo ver \/([^\/]*)\/ dentro de "([^"]*)"$/ do |regexp, selector|
|
115
|
+
Then %{I should not see /#{regexp}/ within "#{selector}"}
|
116
|
+
end
|
117
|
+
|
118
|
+
Então /^o campo "([^"]*)" deve conter "([^"]*)"$/ do |field, value|
|
119
|
+
Then %{the "#{field}" field should contain "#{value}"}
|
120
|
+
end
|
121
|
+
|
122
|
+
Então /^o campo "([^"]*)" não deve conter "([^"]*)"$/ do |field, value|
|
123
|
+
Then %{the "#{field}" field should not contain "#{value}"}
|
124
|
+
end
|
125
|
+
|
126
|
+
Então /^o checkbox "([^"]*)" deve estar marcado$/ do |label|
|
127
|
+
Then %{the "#{label}" checkbox should be checked}
|
128
|
+
end
|
129
|
+
|
130
|
+
Então /^o checkbox "([^"]*)" não deve estar marcado$/ do |label|
|
131
|
+
Then %{the "#{label}" checkbox should not be checked}
|
132
|
+
end
|
133
|
+
|
134
|
+
Então /^eu devo estar na (.+)$/ do |page_name|
|
135
|
+
Then %{I should be on #{page_name}}
|
136
|
+
end
|
137
|
+
|
138
|
+
Então /^mostre-me a página$/ do
|
139
|
+
Then %{show me the page}
|
140
|
+
end
|
@@ -0,0 +1,276 @@
|
|
1
|
+
<%= embed_file('support/edit_warning.txt') %>
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'cgi'
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
6
|
+
|
7
|
+
# Commonly used webrat steps
|
8
|
+
# http://github.com/brynary/webrat
|
9
|
+
|
10
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
11
|
+
visit path_to(page_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
15
|
+
visit path_to(page_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^(?:|I )press "([^"]*)"$/ do |button|
|
19
|
+
click_button(button)
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
23
|
+
click_link(link)
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^(?:|I )follow "([^"]*)" within "([^"]*)"$/ do |link, parent|
|
27
|
+
click_link_within(parent, link)
|
28
|
+
end
|
29
|
+
|
30
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
31
|
+
fill_in(field, :with => value)
|
32
|
+
end
|
33
|
+
|
34
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
35
|
+
fill_in(field, :with => value)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Use this to fill in an entire form with data from a table. Example:
|
39
|
+
#
|
40
|
+
# When I fill in the following:
|
41
|
+
# | Account Number | 5002 |
|
42
|
+
# | Expiry date | 2009-11-01 |
|
43
|
+
# | Note | Nice guy |
|
44
|
+
# | Wants Email? | |
|
45
|
+
#
|
46
|
+
# TODO: Add support for checkbox, select og option
|
47
|
+
# based on naming conventions.
|
48
|
+
#
|
49
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
50
|
+
fields.rows_hash.each do |name, value|
|
51
|
+
When %{I fill in "#{name}" with "#{value}"}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
56
|
+
select(value, :from => field)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
60
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
61
|
+
When /^(?:|I )select "([^"]*)" as the date and time$/ do |time|
|
62
|
+
select_datetime(time)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
66
|
+
# you want to specify which datetime to select. Given the following view:
|
67
|
+
# <%%= f.label :preferred %><br />
|
68
|
+
# <%%= f.datetime_select :preferred %>
|
69
|
+
# <%%= f.label :alternative %><br />
|
70
|
+
# <%%= f.datetime_select :alternative %>
|
71
|
+
# The following steps would fill out the form:
|
72
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
|
73
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
|
74
|
+
When /^(?:|I )select "([^"]*)" as the "([^"]*)" date and time$/ do |datetime, datetime_label|
|
75
|
+
select_datetime(datetime, :from => datetime_label)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
79
|
+
# When I select "2:20PM" as the time
|
80
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
81
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
82
|
+
When /^(?:|I )select "([^"]*)" as the time$/ do |time|
|
83
|
+
select_time(time)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
87
|
+
# specify the name of the time on the form. For example:
|
88
|
+
# When I select "7:30AM" as the "Gym" time
|
89
|
+
When /^(?:|I )select "([^"]*)" as the "([^"]*)" time$/ do |time, time_label|
|
90
|
+
select_time(time, :from => time_label)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
94
|
+
# When I select "February 20, 1981" as the date
|
95
|
+
When /^(?:|I )select "([^"]*)" as the date$/ do |date|
|
96
|
+
select_date(date)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Use this step when using multiple date_select helpers on one page or
|
100
|
+
# you want to specify the name of the date on the form. For example:
|
101
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
102
|
+
When /^(?:|I )select "([^"]*)" as the "([^"]*)" date$/ do |date, date_label|
|
103
|
+
select_date(date, :from => date_label)
|
104
|
+
end
|
105
|
+
|
106
|
+
When /^(?:|I )check "([^"]*)"$/ do |field|
|
107
|
+
check(field)
|
108
|
+
end
|
109
|
+
|
110
|
+
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
111
|
+
uncheck(field)
|
112
|
+
end
|
113
|
+
|
114
|
+
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
115
|
+
choose(field)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Adds support for validates_attachment_content_type. Without the mime-type getting
|
119
|
+
# passed to attach_file() you will get a "Photo file is not one of the allowed file types."
|
120
|
+
# error message
|
121
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
122
|
+
type = path.split(".")[1]
|
123
|
+
|
124
|
+
case type
|
125
|
+
when "jpg"
|
126
|
+
type = "image/jpg"
|
127
|
+
when "jpeg"
|
128
|
+
type = "image/jpeg"
|
129
|
+
when "png"
|
130
|
+
type = "image/png"
|
131
|
+
when "gif"
|
132
|
+
type = "image/gif"
|
133
|
+
end
|
134
|
+
|
135
|
+
attach_file(field, path, type)
|
136
|
+
end
|
137
|
+
|
138
|
+
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
139
|
+
if response.respond_to? :should
|
140
|
+
response.should contain(text)
|
141
|
+
else
|
142
|
+
assert_contain text
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
Then /^(?:|I )should see "([^"]*)" within "([^"]*)"$/ do |text, selector|
|
147
|
+
within(selector) do |content|
|
148
|
+
if content.respond_to? :should
|
149
|
+
content.should contain(text)
|
150
|
+
else
|
151
|
+
hc = Webrat::Matchers::HasContent.new(text)
|
152
|
+
assert hc.matches?(content), hc.failure_message
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
158
|
+
regexp = Regexp.new(regexp)
|
159
|
+
if response.respond_to? :should
|
160
|
+
response.should contain(regexp)
|
161
|
+
else
|
162
|
+
assert_match(regexp, response_body)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
Then /^(?:|I )should see \/([^\/]*)\/ within "([^"]*)"$/ do |regexp, selector|
|
167
|
+
within(selector) do |content|
|
168
|
+
regexp = Regexp.new(regexp)
|
169
|
+
if content.respond_to? :should
|
170
|
+
content.should contain(regexp)
|
171
|
+
else
|
172
|
+
assert_match(regexp, content)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
178
|
+
if response.respond_to? :should_not
|
179
|
+
response.should_not contain(text)
|
180
|
+
else
|
181
|
+
assert_not_contain(text)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
Then /^(?:|I )should not see "([^"]*)" within "([^"]*)"$/ do |text, selector|
|
186
|
+
within(selector) do |content|
|
187
|
+
if content.respond_to? :should_not
|
188
|
+
content.should_not contain(text)
|
189
|
+
else
|
190
|
+
hc = Webrat::Matchers::HasContent.new(text)
|
191
|
+
assert !hc.matches?(content), hc.negative_failure_message
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
197
|
+
regexp = Regexp.new(regexp)
|
198
|
+
if response.respond_to? :should_not
|
199
|
+
response.should_not contain(regexp)
|
200
|
+
else
|
201
|
+
assert_not_contain(regexp)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
Then /^(?:|I )should not see \/([^\/]*)\/ within "([^"]*)"$/ do |regexp, selector|
|
206
|
+
within(selector) do |content|
|
207
|
+
regexp = Regexp.new(regexp)
|
208
|
+
if content.respond_to? :should_not
|
209
|
+
content.should_not contain(regexp)
|
210
|
+
else
|
211
|
+
assert_no_match(regexp, content)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
Then /^the "([^"]*)" field should contain "([^"]*)"$/ do |field, value|
|
217
|
+
field_value = field_labeled(field).value
|
218
|
+
if field_value.respond_to? :should
|
219
|
+
field_value.should =~ /#{value}/
|
220
|
+
else
|
221
|
+
assert_match(/#{value}/, field_value)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
Then /^the "([^"]*)" field should not contain "([^"]*)"$/ do |field, value|
|
226
|
+
field_value = field_labeled(field).value
|
227
|
+
if field_value.respond_to? :should_not
|
228
|
+
field_value.should_not =~ /#{value}/
|
229
|
+
else
|
230
|
+
assert_no_match(/#{value}/, field_value)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
Then /^the "([^"]*)" checkbox should be checked$/ do |label|
|
235
|
+
field = field_labeled(label)
|
236
|
+
if field.respond_to? :should
|
237
|
+
field.should be_checked
|
238
|
+
else
|
239
|
+
assert field.checked?
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
Then /^the "([^"]*)" checkbox should not be checked$/ do |label|
|
244
|
+
field = field_labeled(label)
|
245
|
+
if field.respond_to? :should_not
|
246
|
+
field.should_not be_checked
|
247
|
+
else
|
248
|
+
assert !field.checked?
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
253
|
+
current_path = URI.parse(current_url).path
|
254
|
+
if current_path.respond_to? :should
|
255
|
+
current_path.should == path_to(page_name)
|
256
|
+
else
|
257
|
+
assert_equal path_to(page_name), current_path
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
262
|
+
query = URI.parse(current_url).query
|
263
|
+
actual_params = query ? CGI.parse(query) : {}
|
264
|
+
expected_params = {}
|
265
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
266
|
+
|
267
|
+
if actual_params.respond_to? :should
|
268
|
+
actual_params.should == expected_params
|
269
|
+
else
|
270
|
+
assert_equal expected_params, actual_params
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
Then /^show me the page$/ do
|
275
|
+
save_and_open_page
|
276
|
+
end
|