cucumber-rails 0.4.0.beta.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/.rvmrc +1 -1
  2. data/HACKING.rdoc +6 -8
  3. data/History.txt +18 -2
  4. data/README.rdoc +8 -10
  5. data/cucumber-rails.gemspec +10 -6
  6. data/dev_tasks/cucumber.rake +1 -1
  7. data/features/allow_rescue.feature +61 -0
  8. data/features/inspect_query_string.feature +36 -0
  9. data/features/install_cucumber_rails.feature +16 -0
  10. data/features/mongoid.feature +53 -0
  11. data/features/named_selectors.feature +33 -0
  12. data/features/no_database.feature +69 -0
  13. data/features/rerun_profile.feature +1 -2
  14. data/features/rest_api.feature +46 -0
  15. data/features/routing.feature +21 -0
  16. data/features/select_dates.feature +25 -0
  17. data/features/step_definitions/cucumber_rails_steps.rb +65 -4
  18. data/features/support/env.rb +5 -1
  19. data/generators/cucumber/cucumber_generator.rb +1 -27
  20. data/lib/cucumber/rails.rb +3 -20
  21. data/lib/cucumber/rails/capybara.rb +7 -0
  22. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +21 -14
  23. data/lib/cucumber/rails/hooks.rb +3 -0
  24. data/lib/cucumber/rails/hooks/database_cleaner.rb +16 -3
  25. data/lib/cucumber/rails/rspec.rb +2 -0
  26. data/lib/cucumber/rails/version.rb +14 -9
  27. data/lib/cucumber/rails/world.rb +6 -0
  28. data/lib/cucumber/rails2.rb +1 -1
  29. data/lib/cucumber/rails3.rb +7 -7
  30. data/lib/generators/cucumber/install/install_base.rb +11 -51
  31. data/templates/install/config/cucumber.yml.erb +1 -1
  32. data/templates/install/step_definitions/capybara_steps.rb.erb +63 -85
  33. data/templates/install/step_definitions/web_steps_cs.rb.erb +11 -20
  34. data/templates/install/step_definitions/web_steps_da.rb.erb +11 -20
  35. data/templates/install/step_definitions/web_steps_es.rb.erb +11 -20
  36. data/templates/install/step_definitions/web_steps_ja.rb.erb +1 -0
  37. data/templates/install/step_definitions/web_steps_ko.rb.erb +1 -0
  38. data/templates/install/step_definitions/web_steps_no.rb.erb +11 -20
  39. data/templates/install/step_definitions/web_steps_pt-BR.rb.erb +11 -20
  40. data/templates/install/step_definitions/webrat_steps.rb.erb +11 -10
  41. data/templates/install/support/_rails_each_run.rb.erb +3 -19
  42. data/templates/install/support/edit_warning.txt +19 -5
  43. data/templates/install/support/selectors.rb +39 -0
  44. data/templates/install/tasks/cucumber.rake.erb +4 -0
  45. metadata +100 -82
  46. data/features/rails2.feature +0 -45
  47. data/features/rails3.feature +0 -123
  48. data/features/support/matchers/files.rb +0 -17
  49. data/spec/generators/cucumber/install/install_base_spec.rb +0 -75
@@ -1,7 +1,7 @@
1
1
  <%%
2
2
  rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
3
  rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
- std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
5
  %>
6
6
  default: <%= spork? ? '--drb ' : '' %><%%= std_opts %> features
7
7
  wip: <%= spork? ? '--drb ' : '' %>--tags @wip:3 --wip features
@@ -3,14 +3,25 @@
3
3
  require 'uri'
4
4
  require 'cgi'
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
6
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
6
7
 
7
8
  module WithinHelpers
8
9
  def with_scope(locator)
9
- locator ? within(locator) { yield } : yield
10
+ locator ? within(*selector_for(locator)) { yield } : yield
10
11
  end
11
12
  end
12
13
  World(WithinHelpers)
13
14
 
15
+ # Single-line step scoper
16
+ When /^(.*) within ([^:]+)$/ do |step, parent|
17
+ with_scope(parent) { When step }
18
+ end
19
+
20
+ # Multi-line step scoper
21
+ When /^(.*) within ([^:]+):$/ do |step, parent, table_or_string|
22
+ with_scope(parent) { When "#{step}:", table_or_string }
23
+ end
24
+
14
25
  Given /^(?:|I )am on (.+)$/ do |page_name|
15
26
  visit path_to(page_name)
16
27
  end
@@ -19,28 +30,20 @@ When /^(?:|I )go to (.+)$/ do |page_name|
19
30
  visit path_to(page_name)
20
31
  end
21
32
 
22
- When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
23
- with_scope(selector) do
24
- click_button(button)
25
- end
33
+ When /^(?:|I )press "([^"]*)"$/ do |button|
34
+ click_button(button)
26
35
  end
27
36
 
28
- When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
29
- with_scope(selector) do
30
- click_link(link)
31
- end
37
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
38
+ click_link(link)
32
39
  end
33
40
 
34
- When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
35
- with_scope(selector) do
36
- fill_in(field, :with => value)
37
- end
41
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
42
+ fill_in(field, :with => value)
38
43
  end
39
44
 
40
- When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
41
- with_scope(selector) do
42
- fill_in(field, :with => value)
43
- end
45
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
46
+ fill_in(field, :with => value)
44
47
  end
45
48
 
46
49
  # Use this to fill in an entire form with data from a table. Example:
@@ -54,95 +57,70 @@ end
54
57
  # TODO: Add support for checkbox, select og option
55
58
  # based on naming conventions.
56
59
  #
57
- When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
58
- with_scope(selector) do
59
- fields.rows_hash.each do |name, value|
60
- When %{I fill in "#{name}" with "#{value}"}
61
- end
60
+ When /^(?:|I )fill in the following:$/ do |fields|
61
+ fields.rows_hash.each do |name, value|
62
+ When %{I fill in "#{name}" with "#{value}"}
62
63
  end
63
64
  end
64
65
 
65
- When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
66
- with_scope(selector) do
67
- select(value, :from => field)
68
- end
66
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
67
+ select(value, :from => field)
69
68
  end
70
69
 
71
- When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
72
- with_scope(selector) do
73
- check(field)
74
- end
70
+ When /^(?:|I )check "([^"]*)"$/ do |field|
71
+ check(field)
75
72
  end
76
73
 
77
- When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
78
- with_scope(selector) do
79
- uncheck(field)
80
- end
81
- end
82
-
83
- When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
84
- with_scope(selector) do
85
- choose(field)
86
- end
74
+ When /^(?:|I )uncheck "([^"]*)"$/ do |field|
75
+ uncheck(field)
87
76
  end
88
77
 
89
- When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
90
- with_scope(selector) do
91
- attach_file(field, File.expand_path(path))
92
- end
78
+ When /^(?:|I )choose "([^"]*)"$/ do |field|
79
+ choose(field)
93
80
  end
94
81
 
95
- Then /^(?:|I )should see JSON:$/ do |expected_json|
96
- require 'json'
97
- expected = JSON.pretty_generate(JSON.parse(expected_json))
98
- actual = JSON.pretty_generate(JSON.parse(response.body))
99
- expected.should == actual
82
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
83
+ attach_file(field, File.expand_path(path))
100
84
  end
101
85
 
102
- Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
103
- with_scope(selector) do
104
- if page.respond_to? :should
105
- page.should have_content(text)
106
- else
107
- assert page.has_content?(text)
108
- end
86
+ Then /^(?:|I )should see "([^"]*)"$/ do |text|
87
+ if page.respond_to? :should
88
+ page.should have_content(text)
89
+ else
90
+ assert page.has_content?(text)
109
91
  end
110
92
  end
111
93
 
112
- Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
94
+ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
113
95
  regexp = Regexp.new(regexp)
114
- with_scope(selector) do
115
- if page.respond_to? :should
116
- page.should have_xpath('//*', :text => regexp)
117
- else
118
- assert page.has_xpath?('//*', :text => regexp)
119
- end
96
+
97
+ if page.respond_to? :should
98
+ page.should have_xpath('//*', :text => regexp)
99
+ else
100
+ assert page.has_xpath?('//*', :text => regexp)
120
101
  end
121
102
  end
122
103
 
123
- Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
124
- with_scope(selector) do
125
- if page.respond_to? :should
126
- page.should have_no_content(text)
127
- else
128
- assert page.has_no_content?(text)
129
- end
104
+ Then /^(?:|I )should not see "([^"]*)"$/ do |text|
105
+ if page.respond_to? :should
106
+ page.should have_no_content(text)
107
+ else
108
+ assert page.has_no_content?(text)
130
109
  end
131
110
  end
132
111
 
133
- Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
112
+ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
134
113
  regexp = Regexp.new(regexp)
135
- with_scope(selector) do
136
- if page.respond_to? :should
137
- page.should have_no_xpath('//*', :text => regexp)
138
- else
139
- assert page.has_no_xpath?('//*', :text => regexp)
140
- end
114
+
115
+ if page.respond_to? :should
116
+ page.should have_no_xpath('//*', :text => regexp)
117
+ else
118
+ assert page.has_no_xpath?('//*', :text => regexp)
141
119
  end
142
120
  end
143
121
 
144
- Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
145
- with_scope(selector) do
122
+ Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
123
+ with_scope(parent) do
146
124
  field = find_field(field)
147
125
  field_value = (field.tag_name == 'textarea') ? field.text : field.value
148
126
  if field_value.respond_to? :should
@@ -153,8 +131,8 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |
153
131
  end
154
132
  end
155
133
 
156
- Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
157
- with_scope(selector) do
134
+ Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
135
+ with_scope(parent) do
158
136
  field = find_field(field)
159
137
  field_value = (field.tag_name == 'textarea') ? field.text : field.value
160
138
  if field_value.respond_to? :should_not
@@ -165,8 +143,8 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/
165
143
  end
166
144
  end
167
145
 
168
- Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
169
- with_scope(selector) do
146
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
147
+ with_scope(parent) do
170
148
  field_checked = find_field(label)['checked']
171
149
  if field_checked.respond_to? :should
172
150
  field_checked.should be_true
@@ -176,8 +154,8 @@ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |labe
176
154
  end
177
155
  end
178
156
 
179
- Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
180
- with_scope(selector) do
157
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
158
+ with_scope(parent) do
181
159
  field_checked = find_field(label)['checked']
182
160
  if field_checked.respond_to? :should
183
161
  field_checked.should be_false
@@ -2,6 +2,17 @@
2
2
  <%= embed_file('support/edit_warning.txt') %>
3
3
 
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
6
+
7
+ # Single-line step scoper
8
+ When /^(.*) uvnitř ([^:]+)$/ do |step, parent|
9
+ with_scope(parent) { When step }
10
+ end
11
+
12
+ # Multi-line step scoper
13
+ When /^(.*) uvnitř ([^:]+):$/ do |step, parent, table_or_string|
14
+ with_scope(parent) { When "#{step}:", table_or_string }
15
+ end
5
16
 
6
17
  Given /^jsem na (.+)$/ do |page_name|
7
18
  Given %{I am on #{page_name}}
@@ -19,10 +30,6 @@ When /^kliknu na "([^"]*)"$/ do |link|
19
30
  When %{I follow "#{link}"}
20
31
  end
21
32
 
22
- When /^kliknu na "([^"]*)" uvnitř "([^"]*)"$/ do |link, parent|
23
- When %{I follow "#{link}" within "#{parent}"}
24
- end
25
-
26
33
  When /^vyplním pole "([^"]*)" hodnotou "([^"]*)"$/ do |field, value|
27
34
  When %{I fill in "#{field}" with "#{value}"}
28
35
  end
@@ -83,34 +90,18 @@ Then /^(?:|také )bych měl vidět "([^"]*)"$/ do |text|
83
90
  Then %{I should see "#{text}"}
84
91
  end
85
92
 
86
- Then /^(?:|také )bych měl vidět "([^"]*)" uvnitř "([^"]*)"$/ do |text, selector|
87
- Then %{I should see "#{text}" within "#{selector}"}
88
- end
89
-
90
93
  Then /^(?:|také )bych měl vidět \/([^\/]*)\/$/ do |regexp|
91
94
  Then %{I should see /#{regexp}/}
92
95
  end
93
96
 
94
- Then /^(?:|také )bych měl vidět \/([^\/]*)\/ uvnitř "([^"]*)"$/ do |regexp, selector|
95
- Then %{I should see /#{regexp}/ within "#{selector}"}
96
- end
97
-
98
97
  Then /^(?:|také )bych neměl vidět "([^"]*)"$/ do |text|
99
98
  Then %{I should not see "#{text}"}
100
99
  end
101
100
 
102
- Then /^(?:|také )bych neměl vidět "([^"]*)" uvnitř "([^"]*)"$/ do |text, selector|
103
- Then %{I should not see "#{text}" within "#{selector}"}
104
- end
105
-
106
101
  Then /^(?:|také )bych neměl vidět \/([^\/]*)\/$/ do |regexp|
107
102
  Then %{I should not see /#{regexp}/}
108
103
  end
109
104
 
110
- Then /^(?:|také )bych neměl vidět \/([^\/]*)\/ uvnitř "([^"]*)"$/ do |regexp, selector|
111
- Then %{I should not see /#{regexp}/ within "#{selector}"}
112
- end
113
-
114
105
  Then /^pole "([^"]*)" by mělo obsahovat "([^"]*)"$/ do |field, value|
115
106
  Then %{the "#{field}" field should contain "#{value}"}
116
107
  end
@@ -2,6 +2,17 @@
2
2
  <%= embed_file('support/edit_warning.txt') %>
3
3
 
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
6
+
7
+ # Single-line step scoper
8
+ Når /^(.*) under ([^:]+)$/ do |step, parent|
9
+ with_scope(parent) { Når step }
10
+ end
11
+
12
+ # Multi-line step scoper
13
+ Når /^(.*) under ([^:]+):$/ do |step, parent, table_or_string|
14
+ with_scope(parent) { Når "#{step}:", table_or_string }
15
+ end
5
16
 
6
17
  Givet /^(?:|at )jeg står på (.*)$/ do |page_name|
7
18
  Given %{I am on #{page_name}}
@@ -19,10 +30,6 @@ Når /^jeg klikker "([^"]*)"$/ do |link|
19
30
  When %{I follow "#{link}"}
20
31
  end
21
32
 
22
- Når /^jeg klikker "([^"]*)" under "([^"]*)"$/ do |link, parent|
23
- When %{I follow "#{link}" within "#{parent}"}
24
- end
25
-
26
33
  Når /^jeg fylder ud "([^"]*)" med "([^"]*)"$/ do |field, value|
27
34
  When %{I fill in "#{field}" with "#{value}"}
28
35
  end
@@ -61,34 +68,18 @@ Så /^(?:skal jeg|jeg skal) se "([^"]*)"$/ do |text|
61
68
  Then %{I should see "#{text}"}
62
69
  end
63
70
 
64
- Så /^(?:skal jeg|jeg skal) se "([^"]*)" under "([^"]*)"$/ do |text, selector|
65
- Then %{I should see "#{text}" within "#{selector}"}
66
- end
67
-
68
71
  Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/$/ do |regexp|
69
72
  Then %{I should see /#{regexp}/}
70
73
  end
71
74
 
72
- Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/ under "([^"]*)"$/ do |regexp, selector|
73
- Then %{I should see /#{regexp}/ within "#{selector}"}
74
- end
75
-
76
75
  Så /^(?:skal jeg|jeg skal) ikke se "([^"]*)"$/ do |text|
77
76
  Then %{I should not see "#{text}"}
78
77
  end
79
78
 
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
79
  Så /^(?:skal jeg|jeg skal) ikke se \/([^\/]*)\/$/ do |regexp|
85
80
  Then %{I should not see /#{regexp}/}
86
81
  end
87
82
 
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
83
  Så /^(?:skal )"([^"]*)" feltet (?:skal )indeholde "([^"]*)"$/ do |field, value|
93
84
  Then %{the "#{field}" field should contain "#{value}"}
94
85
  end
@@ -2,6 +2,17 @@
2
2
  <%= embed_file('support/edit_warning.txt') %>
3
3
 
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
6
+
7
+ # Single-line step scoper
8
+ Cuando /^(.*) dentro de ([^:]+)$/ do |step, parent|
9
+ with_scope(parent) { Cuando step }
10
+ end
11
+
12
+ # Multi-line step scoper
13
+ Cuando /^(.*) dentro de ([^:]+):$/ do |step, parent, table_or_string|
14
+ with_scope(parent) { Cuando "#{step}:", table_or_string }
15
+ end
5
16
 
6
17
  Dado /^que estoy en (.+)$/ do |page_name|
7
18
  Given %{I am on #{page_name}}
@@ -19,10 +30,6 @@ Cuando /^clickeo "([^"]*)"$/ do |link|
19
30
  When %{I follow "#{link}"}
20
31
  end
21
32
 
22
- Cuando /^clickeo "([^"]*)" dentro de "([^"]*)"$/ do |link, parent|
23
- When %{I follow "#{link}" within "#{parent}"}
24
- end
25
-
26
33
  Cuando /^completo "([^"]*)" con "([^"]*)"$/ do |field, value|
27
34
  When %{I fill in "#{field}" with "#{value}"}
28
35
  end
@@ -83,34 +90,18 @@ Entonces /^debería ver "([^"]*)"$/ do |text|
83
90
  Then %{I should see "#{text}"}
84
91
  end
85
92
 
86
- Entonces /^debería ver "([^"]*)" dentro de "([^"]*)"$/ do |text, selector|
87
- Then %{I should see "#{text}" within "#{selector}"}
88
- end
89
-
90
93
  Entonces /^debería ver \/([^\/]*)\/$/ do |regexp|
91
94
  Then %{I should see /#{regexp}/}
92
95
  end
93
96
 
94
- Entonces /^debería ver \/([^\/]*)\/ dentro de "([^"]*)"$/ do |regexp, selector|
95
- Then %{I should see /#{regexp}/ within "#{selector}"}
96
- end
97
-
98
97
  Entonces /^no debería ver "([^"]*)"$/ do |text|
99
98
  Then %{I should not see "#{text}"}
100
99
  end
101
100
 
102
- Entonces /^no debería ver "([^"]*)" dentro de "([^"]*)"$/ do |text, selector|
103
- Then %{I should not see "#{text}" within "#{selector}"}
104
- end
105
-
106
101
  Entonces /^no debería ver \/([^\/]*)\/$/ do |regexp|
107
102
  Then %{I should not see /#{regexp}/}
108
103
  end
109
104
 
110
- Entonces /^no debería ver \/([^\/]*)\/ dentro de "([^"]*)"$/ do |regexp, selector|
111
- Then %{I should not see /#{regexp}/ within "#{selector}"}
112
- end
113
-
114
105
  Entonces /^el campo "([^"]*)" debería contener "([^"]*)"$/ do |field, value|
115
106
  Then %{the "#{field}" field should contain "#{value}"}
116
107
  end
@@ -2,6 +2,7 @@
2
2
  <%= embed_file('support/edit_warning.txt') %>
3
3
 
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
5
6
 
6
7
  前提 /^"([^"]*)"ページを表示している$/ do |page_name|
7
8
  Given %{I am on #{page_name}}
@@ -2,6 +2,7 @@
2
2
  <%= embed_file('support/edit_warning.txt') %>
3
3
 
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
5
6
 
6
7
  조건 /^(.+)페이지에 있습니다$/ do |page_name|
7
8
  Given %{I am on #{page_name}}
@@ -2,6 +2,17 @@
2
2
  <%= embed_file('support/edit_warning.txt') %>
3
3
 
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
6
+
7
+ # Single-line step scoper
8
+ Når /^(.*) under ([^:]+)$/ do |step, parent|
9
+ with_scope(parent) { Når step }
10
+ end
11
+
12
+ # Multi-line step scoper
13
+ Når /^(.*) under ([^:]+):$/ do |step, parent, table_or_string|
14
+ with_scope(parent) { Når "#{step}:", table_or_string }
15
+ end
5
16
 
6
17
  Gitt /^(?:|at )jeg står på (.*)$/ do |page_name|
7
18
  Given %{I am on #{page_name}}
@@ -19,10 +30,6 @@ Når /^jeg klikker "([^"]*)"$/ do |link|
19
30
  When %{I follow "#{link}"}
20
31
  end
21
32
 
22
- Når /^jeg klikker "([^"]*)" under "([^"]*)"$/ do |link, parent|
23
- When %{I follow "#{link}" within "#{parent}"}
24
- end
25
-
26
33
  Når /^jeg fyller inn "([^"]*)" med "([^"]*)"$/ do |field, value|
27
34
  When %{I fill in "#{field}" with "#{value}"}
28
35
  end
@@ -61,34 +68,18 @@ Så /^(?:skal jeg|jeg skal) se "([^"]*)"$/ do |text|
61
68
  Then %{I should see "#{text}"}
62
69
  end
63
70
 
64
- Så /^(?:skal jeg|jeg skal) se "([^"]*)" under "([^"]*)"$/ do |text, selector|
65
- Then %{I should see "#{text}" within "#{selector}"}
66
- end
67
-
68
71
  Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/$/ do |regexp|
69
72
  Then %{I should see /#{regexp}/}
70
73
  end
71
74
 
72
- Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/ under "([^"]*)"$/ do |regexp, selector|
73
- Then %{I should see /#{regexp}/ within "#{selector}"}
74
- end
75
-
76
75
  Så /^(?:skal jeg|jeg skal) ikke se "([^"]*)"$/ do |text|
77
76
  Then %{I should not see "#{text}"}
78
77
  end
79
78
 
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
79
  Så /^(?:skal jeg|jeg skal) ikke se \/([^\/]*)\/$/ do |regexp|
85
80
  Then %{I should not see /#{regexp}/}
86
81
  end
87
82
 
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
83
  Så /^(?:skal )"([^"]*)" feltet (?:skal )inneholde "([^"]*)"$/ do |field, value|
93
84
  Then %{the "#{field}" field should contain "#{value}"}
94
85
  end