cucumber_rails3_gen 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +19 -0
- data/README.rdoc +19 -0
- data/USAGE +19 -0
- data/VERSION +1 -0
- data/bin/cucumber_skeleton +19 -0
- data/lib/generators/cucumber/skeleton/USAGE +19 -0
- data/lib/generators/cucumber/skeleton/skeleton_generator.rb +178 -0
- data/lib/generators/cucumber/skeleton/templates/config/cucumber.yml.erb +7 -0
- data/lib/generators/cucumber/skeleton/templates/environments/cucumber.rb.erb +37 -0
- data/lib/generators/cucumber/skeleton/templates/script/cucumber +10 -0
- data/lib/generators/cucumber/skeleton/templates/step_definitions/capybara_steps.rb.erb +187 -0
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_cs.rb.erb +136 -0
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_da.rb.erb +114 -0
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_de.rb.erb +136 -0
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_es.rb.erb +136 -0
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_ja.rb.erb +136 -0
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_no.rb.erb +114 -0
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_pt-BR.rb.erb +140 -0
- data/lib/generators/cucumber/skeleton/templates/step_definitions/webrat_steps.rb.erb +258 -0
- data/lib/generators/cucumber/skeleton/templates/support/_rails_each_run.rb +29 -0
- data/lib/generators/cucumber/skeleton/templates/support/_rails_prefork.rb.erb +10 -0
- data/lib/generators/cucumber/skeleton/templates/support/capybara.rb +9 -0
- data/lib/generators/cucumber/skeleton/templates/support/edit_warning.txt +5 -0
- data/lib/generators/cucumber/skeleton/templates/support/paths.rb +27 -0
- data/lib/generators/cucumber/skeleton/templates/support/rails.rb.erb +5 -0
- data/lib/generators/cucumber/skeleton/templates/support/rails_spork.rb.erb +13 -0
- data/lib/generators/cucumber/skeleton/templates/support/webrat.rb +8 -0
- data/lib/generators/cucumber/skeleton/templates/tasks/cucumber.rake.erb +42 -0
- data/spec/cucumber_gen_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +95 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
<%= Cucumber::Helper.embed_file('support/edit_warning.txt') %>
|
3
|
+
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
5
|
+
|
6
|
+
Given /^"([^\"]*)"ページを表示している$/ do |page_name|
|
7
|
+
Given %{I am on #{page_name}}
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^"([^\"]*)"ページを表示する$/ do |page_name|
|
11
|
+
Given %{I go to #{page_name}}
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^"([^\"]*)"ボタンをクリックする$/ do |button|
|
15
|
+
When %{I press "#{button}"}
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^"([^\"]*)"リンクをクリックする$/ do |link|
|
19
|
+
When %{I follow "#{link}"}
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^"([^\"]*)"の"([^\"]*)"リンクをクリックする$/ do |parent, link|
|
23
|
+
When %{I follow "#{link}" within "#{parent}"}
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^"([^\"]*)"に"([^\"]*)"と入力する$/ do |field, value|
|
27
|
+
When %{I fill in "#{field}" with "#{value}"}
|
28
|
+
end
|
29
|
+
|
30
|
+
When /^以下の項目を入力する:$/ do |fields|
|
31
|
+
When %{I fill in the following:}, fields
|
32
|
+
end
|
33
|
+
|
34
|
+
When /^"([^\"]*)"から"([^\"]*)"を選択する$/ do |field, value|
|
35
|
+
When %{I select "#{value}" from "#{field}"}
|
36
|
+
end
|
37
|
+
|
38
|
+
When /^日時として"([^\"]*)"を選択する$/ do |time|
|
39
|
+
When %{I select "#{time}" as the date and time}
|
40
|
+
end
|
41
|
+
|
42
|
+
When /^"([^\"]*)"の日時として"([^\"]*)"を選択する$/ do |datetime_label, datetime|
|
43
|
+
When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
|
44
|
+
end
|
45
|
+
|
46
|
+
When /^時間として"([^\"]*)"を選択する$/ do |time|
|
47
|
+
When %{I select "#{time}" as the time}
|
48
|
+
end
|
49
|
+
|
50
|
+
When /^"([^\"]*)"の時間として"([^\"]*)"を選択する$/ do |time_label, time|
|
51
|
+
When %{I select "#{time}" as the "#{time_label}" time}
|
52
|
+
end
|
53
|
+
|
54
|
+
When /^日付として"([^\"]*)"を選択する$/ do |date|
|
55
|
+
When %{I select "#{date}" as the date}
|
56
|
+
end
|
57
|
+
|
58
|
+
When /^"([^\"]*)"の日付として"([^\"]*)"を選択する$/ do |date_label, date|
|
59
|
+
When %{I select "#{date}" as the "#{date_label}" date}
|
60
|
+
end
|
61
|
+
|
62
|
+
When /^"([^\"]*)"をチェックする$/ do |field|
|
63
|
+
When %{I check "#{field}"}
|
64
|
+
end
|
65
|
+
|
66
|
+
When /^"([^\"]*)"のチェックを外す$/ do |field|
|
67
|
+
When %{I uncheck "#{field}"}
|
68
|
+
end
|
69
|
+
|
70
|
+
When /^"([^\"]*)"を選択する$/ do |field|
|
71
|
+
When %{I choose "#{field}"}
|
72
|
+
end
|
73
|
+
|
74
|
+
When /^"([^\"]*)"としてファイル"([^\"]*)"を選択する$/ do |field, path|
|
75
|
+
When %{I attach the file at "#{path}" to "#{field}"}
|
76
|
+
end
|
77
|
+
|
78
|
+
Then /^"([^\"]*)"と表示されていること$/ do |text|
|
79
|
+
Then %{I should see "#{text}"}
|
80
|
+
end
|
81
|
+
|
82
|
+
Then /^"([^\"]*)"に"([^\"]*)"と表示されていること$/ do |selector, text|
|
83
|
+
Then %{I should see "#{text}" within "#{selector}"}
|
84
|
+
end
|
85
|
+
|
86
|
+
Then /^\/([^\/]*)\/と表示されていること$/ do |regexp|
|
87
|
+
Then %{I should see /#{regexp}/}
|
88
|
+
end
|
89
|
+
|
90
|
+
Then /^"([^\"]*)"に\/([^\/]*)\/と表示されていること$/ do |selector, regexp|
|
91
|
+
Then %{I should see \/#{regexp}\/ within "#{selector}"}
|
92
|
+
end
|
93
|
+
|
94
|
+
Then /^"([^\"]*)"と表示されていないこと$/ do |text|
|
95
|
+
Then %{I should not see "#{text}"}
|
96
|
+
end
|
97
|
+
|
98
|
+
Then /^"([^\"]*)"に"([^\"]*)"と表示されていないこと$/ do |selector, text|
|
99
|
+
Then %{I should not see "#{text}" within "#{selector}"}
|
100
|
+
end
|
101
|
+
|
102
|
+
Then /^\/([^\/]*)\/と表示されていないこと$/ do |regexp|
|
103
|
+
Then %{I should not see /#{regexp}/}
|
104
|
+
end
|
105
|
+
|
106
|
+
Then /^"([^\"]*)"に\/([^\/]*)\/と表示されていないこと$/ do |selector, regexp|
|
107
|
+
Then %{I should not see \/#{regexp}\/ within "#{selector}"}
|
108
|
+
end
|
109
|
+
|
110
|
+
Then /^入力項目"([^\"]*)"に"([^\"]*)"と表示されていること$/ do |field, value|
|
111
|
+
Then %{the "#{field}" field should contain "#{value}"}
|
112
|
+
end
|
113
|
+
|
114
|
+
Then /^入力項目"([^\"]*)"に"([^\"]*)"と表示されていないこと$/ do |field, value|
|
115
|
+
Then %{the "#{field}" field should not contain "#{value}"}
|
116
|
+
end
|
117
|
+
|
118
|
+
Then /^"([^\"]*)"がチェックされていること$/ do |label|
|
119
|
+
Then %{the "#{label}" checkbox should be checked}
|
120
|
+
end
|
121
|
+
|
122
|
+
Then /^"([^\"]*)"がチェックされていないこと$/ do |label|
|
123
|
+
Then %{the "#{label}" checkbox should not be checked}
|
124
|
+
end
|
125
|
+
|
126
|
+
Then /^"([^\"]*)"ページを表示していること$/ do |page_name|
|
127
|
+
Then %{I should be on #{page_name}}
|
128
|
+
end
|
129
|
+
|
130
|
+
show_me_the_page = lambda { Then %{show me the page} }
|
131
|
+
Then /^ページを表示する$/, &show_me_the_page
|
132
|
+
Then /^画面を目視$/, &show_me_the_page
|
133
|
+
|
134
|
+
# backword-compat for old japanese translation.
|
135
|
+
Then /^デバッグ(?:のため)?$/, &show_me_the_page
|
136
|
+
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
<%= Cucumber::Helper.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
|
+
<%= Cucumber::Helper.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,258 @@
|
|
1
|
+
<%= Cucumber::Helper.embed_file('support/edit_warning.txt') %>
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
5
|
+
|
6
|
+
# Commonly used webrat steps
|
7
|
+
# http://github.com/brynary/webrat
|
8
|
+
|
9
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
10
|
+
visit path_to(page_name)
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
14
|
+
visit path_to(page_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
When /^(?:|I )press "([^\"]*)"$/ do |button|
|
18
|
+
click_button(button)
|
19
|
+
end
|
20
|
+
|
21
|
+
When /^(?:|I )follow "([^\"]*)"$/ do |link|
|
22
|
+
click_link(link)
|
23
|
+
end
|
24
|
+
|
25
|
+
When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
|
26
|
+
click_link_within(parent, link)
|
27
|
+
end
|
28
|
+
|
29
|
+
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
30
|
+
fill_in(field, :with => value)
|
31
|
+
end
|
32
|
+
|
33
|
+
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
|
34
|
+
fill_in(field, :with => value)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Use this to fill in an entire form with data from a table. Example:
|
38
|
+
#
|
39
|
+
# When I fill in the following:
|
40
|
+
# | Account Number | 5002 |
|
41
|
+
# | Expiry date | 2009-11-01 |
|
42
|
+
# | Note | Nice guy |
|
43
|
+
# | Wants Email? | |
|
44
|
+
#
|
45
|
+
# TODO: Add support for checkbox, select og option
|
46
|
+
# based on naming conventions.
|
47
|
+
#
|
48
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
49
|
+
fields.rows_hash.each do |name, value|
|
50
|
+
When %{I fill in "#{name}" with "#{value}"}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
|
55
|
+
select(value, :from => field)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
59
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
60
|
+
When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
|
61
|
+
select_datetime(time)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
65
|
+
# you want to specify which datetime to select. Given the following view:
|
66
|
+
# <%%= f.label :preferred %><br />
|
67
|
+
# <%%= f.datetime_select :preferred %>
|
68
|
+
# <%%= f.label :alternative %><br />
|
69
|
+
# <%%= f.datetime_select :alternative %>
|
70
|
+
# The following steps would fill out the form:
|
71
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
|
72
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
|
73
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
74
|
+
select_datetime(datetime, :from => datetime_label)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
78
|
+
# When I select "2:20PM" as the time
|
79
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
80
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
81
|
+
When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
|
82
|
+
select_time(time)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
86
|
+
# specify the name of the time on the form. For example:
|
87
|
+
# When I select "7:30AM" as the "Gym" time
|
88
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
|
89
|
+
select_time(time, :from => time_label)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
93
|
+
# When I select "February 20, 1981" as the date
|
94
|
+
When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
|
95
|
+
select_date(date)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Use this step when using multiple date_select helpers on one page or
|
99
|
+
# you want to specify the name of the date on the form. For example:
|
100
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
101
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
|
102
|
+
select_date(date, :from => date_label)
|
103
|
+
end
|
104
|
+
|
105
|
+
When /^(?:|I )check "([^\"]*)"$/ do |field|
|
106
|
+
check(field)
|
107
|
+
end
|
108
|
+
|
109
|
+
When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
|
110
|
+
uncheck(field)
|
111
|
+
end
|
112
|
+
|
113
|
+
When /^(?:|I )choose "([^\"]*)"$/ do |field|
|
114
|
+
choose(field)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Adds support for validates_attachment_content_type. Without the mime-type getting
|
118
|
+
# passed to attach_file() you will get a "Photo file is not one of the allowed file types."
|
119
|
+
# error message
|
120
|
+
When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
121
|
+
type = path.split(".")[1]
|
122
|
+
|
123
|
+
case type
|
124
|
+
when "jpg"
|
125
|
+
type = "image/jpg"
|
126
|
+
when "jpeg"
|
127
|
+
type = "image/jpeg"
|
128
|
+
when "png"
|
129
|
+
type = "image/png"
|
130
|
+
when "gif"
|
131
|
+
type = "image/gif"
|
132
|
+
end
|
133
|
+
|
134
|
+
attach_file(field, path, type)
|
135
|
+
end
|
136
|
+
|
137
|
+
Then /^(?:|I )should see "([^\"]*)"$/ do |text|
|
138
|
+
if defined?(Spec::Rails::Matchers)
|
139
|
+
response.should contain(text)
|
140
|
+
else
|
141
|
+
assert_contain text
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
146
|
+
within(selector) do |content|
|
147
|
+
if defined?(Spec::Rails::Matchers)
|
148
|
+
content.should contain(text)
|
149
|
+
else
|
150
|
+
hc = Webrat::Matchers::HasContent.new(text)
|
151
|
+
assert hc.matches?(content), hc.failure_message
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
157
|
+
regexp = Regexp.new(regexp)
|
158
|
+
if defined?(Spec::Rails::Matchers)
|
159
|
+
response.should contain(regexp)
|
160
|
+
else
|
161
|
+
assert_match(regexp, response_body)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
166
|
+
within(selector) do |content|
|
167
|
+
regexp = Regexp.new(regexp)
|
168
|
+
if defined?(Spec::Rails::Matchers)
|
169
|
+
content.should contain(regexp)
|
170
|
+
else
|
171
|
+
assert_match(regexp, content)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
|
177
|
+
if defined?(Spec::Rails::Matchers)
|
178
|
+
response.should_not contain(text)
|
179
|
+
else
|
180
|
+
assert_not_contain(text)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
185
|
+
within(selector) do |content|
|
186
|
+
if defined?(Spec::Rails::Matchers)
|
187
|
+
content.should_not contain(text)
|
188
|
+
else
|
189
|
+
hc = Webrat::Matchers::HasContent.new(text)
|
190
|
+
assert !hc.matches?(content), hc.negative_failure_message
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
196
|
+
regexp = Regexp.new(regexp)
|
197
|
+
if defined?(Spec::Rails::Matchers)
|
198
|
+
response.should_not contain(regexp)
|
199
|
+
else
|
200
|
+
assert_not_contain(regexp)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
205
|
+
within(selector) do |content|
|
206
|
+
regexp = Regexp.new(regexp)
|
207
|
+
if defined?(Spec::Rails::Matchers)
|
208
|
+
content.should_not contain(regexp)
|
209
|
+
else
|
210
|
+
assert_no_match(regexp, content)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
216
|
+
if defined?(Spec::Rails::Matchers)
|
217
|
+
field_labeled(field).value.should =~ /#{value}/
|
218
|
+
else
|
219
|
+
assert_match(/#{value}/, field_labeled(field).value)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
|
224
|
+
if defined?(Spec::Rails::Matchers)
|
225
|
+
field_labeled(field).value.should_not =~ /#{value}/
|
226
|
+
else
|
227
|
+
assert_no_match(/#{value}/, field_labeled(field).value)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
232
|
+
if defined?(Spec::Rails::Matchers)
|
233
|
+
field_labeled(label).should be_checked
|
234
|
+
else
|
235
|
+
assert field_labeled(label).checked?
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
|
240
|
+
if defined?(Spec::Rails::Matchers)
|
241
|
+
field_labeled(label).should_not be_checked
|
242
|
+
else
|
243
|
+
assert !field_labeled(label).checked?
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
248
|
+
current_path = URI.parse(current_url).select(:path, :query).compact.join('?')
|
249
|
+
if defined?(Spec::Rails::Matchers)
|
250
|
+
current_path.should == path_to(page_name)
|
251
|
+
else
|
252
|
+
assert_equal path_to(page_name), current_path
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
Then /^show me the page$/ do
|
257
|
+
save_and_open_page
|
258
|
+
end
|