cucumber-rails2 0.3.3

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 (64) hide show
  1. data/.gitignore +4 -0
  2. data/HACKING.rdoc +24 -0
  3. data/History.txt +145 -0
  4. data/LICENSE +22 -0
  5. data/README.rdoc +70 -0
  6. data/Rakefile +24 -0
  7. data/VERSION +1 -0
  8. data/config/.gitignore +1 -0
  9. data/cucumber-rails2.gemspec +111 -0
  10. data/dev_tasks/cucumber.rake +5 -0
  11. data/dev_tasks/rspec.rake +13 -0
  12. data/features/rails2.feature +64 -0
  13. data/features/rails3.feature +97 -0
  14. data/features/rerun_profile.feature +39 -0
  15. data/features/step_definitions/cucumber_rails_steps.rb +35 -0
  16. data/features/support/env.rb +4 -0
  17. data/features/support/matchers/files.rb +17 -0
  18. data/generators/cucumber/USAGE +13 -0
  19. data/generators/cucumber/cucumber_generator.rb +88 -0
  20. data/generators/feature/USAGE +12 -0
  21. data/generators/feature/feature_generator.rb +47 -0
  22. data/lib/cucumber/rails/action_controller.rb +65 -0
  23. data/lib/cucumber/rails/active_record.rb +34 -0
  24. data/lib/cucumber/rails/capybara_javascript_emulation.rb +81 -0
  25. data/lib/cucumber/rails/rspec.rb +22 -0
  26. data/lib/cucumber/rails/test_unit.rb +7 -0
  27. data/lib/cucumber/rails/world.rb +48 -0
  28. data/lib/cucumber/web/tableish.rb +118 -0
  29. data/lib/generators/cucumber/feature/USAGE +16 -0
  30. data/lib/generators/cucumber/feature/feature_base.rb +29 -0
  31. data/lib/generators/cucumber/feature/feature_generator.rb +37 -0
  32. data/lib/generators/cucumber/feature/named_arg.rb +17 -0
  33. data/lib/generators/cucumber/install/USAGE +15 -0
  34. data/lib/generators/cucumber/install/install_base.rb +202 -0
  35. data/lib/generators/cucumber/install/install_generator.rb +64 -0
  36. data/spec/cucumber/web/tableish_spec.rb +192 -0
  37. data/spec/generators/cucumber/install/install_base_spec.rb +84 -0
  38. data/spec/spec.opts +2 -0
  39. data/spec/spec_helper.rb +6 -0
  40. data/templates/feature/feature.erb +63 -0
  41. data/templates/feature/steps.erb +14 -0
  42. data/templates/install/config/cucumber.yml.erb +8 -0
  43. data/templates/install/environments/cucumber.rb.erb +37 -0
  44. data/templates/install/script/cucumber +10 -0
  45. data/templates/install/step_definitions/capybara_steps.rb.erb +214 -0
  46. data/templates/install/step_definitions/web_steps_cs.rb.erb +136 -0
  47. data/templates/install/step_definitions/web_steps_da.rb.erb +114 -0
  48. data/templates/install/step_definitions/web_steps_de.rb.erb +136 -0
  49. data/templates/install/step_definitions/web_steps_es.rb.erb +136 -0
  50. data/templates/install/step_definitions/web_steps_ja.rb.erb +139 -0
  51. data/templates/install/step_definitions/web_steps_ko.rb.erb +141 -0
  52. data/templates/install/step_definitions/web_steps_no.rb.erb +114 -0
  53. data/templates/install/step_definitions/web_steps_pt-BR.rb.erb +140 -0
  54. data/templates/install/step_definitions/webrat_steps.rb.erb +276 -0
  55. data/templates/install/support/_rails_each_run.rb.erb +35 -0
  56. data/templates/install/support/_rails_prefork.rb.erb +12 -0
  57. data/templates/install/support/capybara.rb +9 -0
  58. data/templates/install/support/edit_warning.txt +5 -0
  59. data/templates/install/support/paths.rb +33 -0
  60. data/templates/install/support/rails.rb.erb +4 -0
  61. data/templates/install/support/rails_spork.rb.erb +13 -0
  62. data/templates/install/support/webrat.rb +8 -0
  63. data/templates/install/tasks/cucumber.rake.erb +48 -0
  64. metadata +143 -0
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
4
+ if vendored_cucumber_bin
5
+ load File.expand_path(vendored_cucumber_bin)
6
+ else
7
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
8
+ require 'cucumber'
9
+ load Cucumber::BINARY
10
+ end
@@ -0,0 +1,214 @@
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
+ module WithinHelpers
8
+ def with_scope(locator)
9
+ locator ? within(locator) { yield } : yield
10
+ end
11
+ end
12
+ World(WithinHelpers)
13
+
14
+ Given /^(?:|I )am on (.+)$/ do |page_name|
15
+ visit path_to(page_name)
16
+ end
17
+
18
+ When /^(?:|I )go to (.+)$/ do |page_name|
19
+ visit path_to(page_name)
20
+ end
21
+
22
+ When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
23
+ with_scope(selector) do
24
+ click_button(button)
25
+ end
26
+ end
27
+
28
+ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
29
+ with_scope(selector) do
30
+ click_link(link)
31
+ end
32
+ end
33
+
34
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
35
+ with_scope(selector) do
36
+ fill_in(field, :with => value)
37
+ end
38
+ end
39
+
40
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
41
+ with_scope(selector) do
42
+ fill_in(field, :with => value)
43
+ end
44
+ end
45
+
46
+ # Use this to fill in an entire form with data from a table. Example:
47
+ #
48
+ # When I fill in the following:
49
+ # | Account Number | 5002 |
50
+ # | Expiry date | 2009-11-01 |
51
+ # | Note | Nice guy |
52
+ # | Wants Email? | |
53
+ #
54
+ # TODO: Add support for checkbox, select og option
55
+ # based on naming conventions.
56
+ #
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
62
+ end
63
+ end
64
+
65
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
66
+ with_scope(selector) do
67
+ select(value, :from => field)
68
+ end
69
+ end
70
+
71
+ When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
72
+ with_scope(selector) do
73
+ check(field)
74
+ end
75
+ end
76
+
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
87
+ end
88
+
89
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
90
+ with_scope(selector) do
91
+ attach_file(field, path)
92
+ end
93
+ end
94
+
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
100
+ end
101
+
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
109
+ end
110
+ end
111
+
112
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
113
+ 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
120
+ end
121
+ end
122
+
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
130
+ end
131
+ end
132
+
133
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
134
+ 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
141
+ end
142
+ end
143
+
144
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
145
+ with_scope(selector) do
146
+ field = find_field(field)
147
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
148
+ if field_value.respond_to? :should
149
+ field_value.should =~ /#{value}/
150
+ else
151
+ assert_match(/#{value}/, field_value)
152
+ end
153
+ end
154
+ end
155
+
156
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
157
+ with_scope(selector) do
158
+ field = find_field(field)
159
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
160
+ if field_value.respond_to? :should_not
161
+ field_value.should_not =~ /#{value}/
162
+ else
163
+ assert_no_match(/#{value}/, field_value)
164
+ end
165
+ end
166
+ end
167
+
168
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
169
+ with_scope(selector) do
170
+ field_checked = find_field(label)['checked']
171
+ if field_checked.respond_to? :should
172
+ field_checked.should be_true
173
+ else
174
+ assert field_checked
175
+ end
176
+ end
177
+ end
178
+
179
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
180
+ with_scope(selector) do
181
+ field_checked = find_field(label)['checked']
182
+ if field_checked.respond_to? :should
183
+ field_checked.should be_false
184
+ else
185
+ assert !field_checked
186
+ end
187
+ end
188
+ end
189
+
190
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
191
+ current_path = URI.parse(current_url).path
192
+ if current_path.respond_to? :should
193
+ current_path.should == path_to(page_name)
194
+ else
195
+ assert_equal path_to(page_name), current_path
196
+ end
197
+ end
198
+
199
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
200
+ query = URI.parse(current_url).query
201
+ actual_params = query ? CGI.parse(query) : {}
202
+ expected_params = {}
203
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
204
+
205
+ if actual_params.respond_to? :should
206
+ actual_params.should == expected_params
207
+ else
208
+ assert_equal expected_params, actual_params
209
+ end
210
+ end
211
+
212
+ Then /^show me the page$/ do
213
+ save_and_open_page
214
+ end
@@ -0,0 +1,136 @@
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
+ Given /^jsem na (.+)$/ do |page_name|
7
+ Given %{I am on #{page_name}}
8
+ end
9
+
10
+ When /^jdu na (.+)$/ do |page_name|
11
+ When %{I go to #{page_name}}
12
+ end
13
+
14
+ When /^stisknu tlačítko "([^"]*)"$/ do |button|
15
+ When %{I press "#{button}"}
16
+ end
17
+
18
+ When /^kliknu na "([^"]*)"$/ do |link|
19
+ When %{I follow "#{link}"}
20
+ end
21
+
22
+ When /^kliknu na "([^"]*)" uvnitř "([^"]*)"$/ do |link, parent|
23
+ When %{I follow "#{link}" within "#{parent}"}
24
+ end
25
+
26
+ When /^vyplním pole "([^"]*)" hodnotou "([^"]*)"$/ do |field, value|
27
+ When %{I fill in "#{field}" with "#{value}"}
28
+ end
29
+
30
+ When /^vyplním "([^"]*)" do pole "([^"]*)"$/ do |value, field|
31
+ When %{I fill in "#{value}" for "#{field}"}
32
+ end
33
+
34
+ When /^vyplním následující:$/ do |fields|
35
+ When %{I fill in the following:}, fields
36
+ end
37
+
38
+ When /^vyberu "([^"]*)" z "([^"]*)"$/ do |value, field|
39
+ When %{I select "#{value}" from "#{field}"}
40
+ end
41
+
42
+ When /^vyberu "([^"]*)" jako datum a čas$/ do |time|
43
+ When %{I select "#{time}" as the date and time}
44
+ end
45
+
46
+ When /^vyberu "([^"]*)" jako "([^"]*)" datum a čas$/ do |datetime, datetime_label|
47
+ When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
48
+ end
49
+
50
+ When /^vyberu "([^"]*)" jako čas$/ do |time|
51
+ When %{I select "#{time}" as the time}
52
+ end
53
+
54
+ When /^vyberu "([^"]*)" jako "([^"]*)" čas$/ do |time, time_label|
55
+ When %{I select "#{time}" as the "#{time_label}" time}
56
+ end
57
+
58
+ When /^vyberu cd jako datum$/ do |date|
59
+ When %{I select "#{date}" as the date}
60
+ end
61
+
62
+ When /^vyberu "([^"]*)" jako "([^"]*)" datum$/ do |date, date_label|
63
+ When %{I select "#{date}" as the "#{date_label}" date}
64
+ end
65
+
66
+ When /^zaškrtnu "([^"]*)"$/ do |field|
67
+ When %{I check "#{field}"}
68
+ end
69
+
70
+ When /^vyškrtnu "([^"]*)"$/ do |field|
71
+ When %{I uncheck "#{field}"}
72
+ end
73
+
74
+ When /^vyberu "([^"]*)"$/ do |field|
75
+ When %{I choose "#{field}"}
76
+ end
77
+
78
+ When /^připojím soubor "([^"]*)" do pole "([^"]*)"$/ do |path, field|
79
+ When %{I attach the file "#{path}" to "#{field}"}
80
+ end
81
+
82
+ Then /^(?:|také )bych měl vidět "([^"]*)"$/ do |text|
83
+ Then %{I should see "#{text}"}
84
+ end
85
+
86
+ Then /^(?:|také )bych měl vidět "([^"]*)" uvnitř "([^"]*)"$/ do |text, selector|
87
+ Then %{I should see "#{text}" within "#{selector}"}
88
+ end
89
+
90
+ Then /^(?:|také )bych měl vidět \/([^\/]*)\/$/ do |regexp|
91
+ Then %{I should see /#{regexp}/}
92
+ end
93
+
94
+ Then /^(?:|také )bych měl vidět \/([^\/]*)\/ uvnitř "([^"]*)"$/ do |regexp, selector|
95
+ Then %{I should see /#{regexp}/ within "#{selector}"}
96
+ end
97
+
98
+ Then /^(?:|také )bych neměl vidět "([^"]*)"$/ do |text|
99
+ Then %{I should not see "#{text}"}
100
+ end
101
+
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
+ Then /^(?:|také )bych neměl vidět \/([^\/]*)\/$/ do |regexp|
107
+ Then %{I should not see /#{regexp}/}
108
+ end
109
+
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
+ Then /^pole "([^"]*)" by mělo obsahovat "([^"]*)"$/ do |field, value|
115
+ Then %{the "#{field}" field should contain "#{value}"}
116
+ end
117
+
118
+ Then /^pole "([^"]*)" by nemělo obsahovat "([^"]*)"$/ do |field, value|
119
+ Then %{the "#{field}" field should not contain "#{value}"}
120
+ end
121
+
122
+ Then /^pole "([^"]*)" by mělo být zaškrtnuté$/ do |label|
123
+ Then %{the "#{label}" checkbox should be checked}
124
+ end
125
+
126
+ Then /^pole "([^"]*)" by nemělo být zaškrtnuté$/ do |label|
127
+ Then %{the "#{label}" checkbox should not be checked}
128
+ end
129
+
130
+ Then /^(?:|také )bych měl být na (.+)$/ do |page_name|
131
+ Then %{I should be on #{page_name}}
132
+ end
133
+
134
+ Then /^(?:|také )mi ukaž stránku$/ do
135
+ Then %{show me the page}
136
+ end
@@ -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
+ Givet /^(?: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 fylder ud "([^"]*)" med "([^"]*)"$/ do |field, value|
27
+ When %{I fill in "#{field}" with "#{value}"}
28
+ end
29
+
30
+ Når /^jeg fylder ud "([^"]*)" for "([^"]*)"$/ do |value, field|
31
+ When %{I fill in "#{value}" for "#{field}"}
32
+ end
33
+
34
+ Når /^jeg fylder følgende ud:$/ do |fields|
35
+ When %{I fill in the following:}, fields
36
+ end
37
+
38
+ Når /^jeg vælger "([^"]*)" fra "([^"]*)"$/ do |value, field|
39
+ When %{I select "#{value}" from "#{field}"}
40
+ end
41
+
42
+ # Missing: date stuff
43
+
44
+ Når /^jeg afkrydser "([^"]*)"$/ do |field|
45
+ When %{I check "#{field}"}
46
+ end
47
+
48
+ Når /^jeg fjerner afkrydsning for "([^"]*)"$/ do |field|
49
+ When %{I uncheck "#{field}"}
50
+ end
51
+
52
+ Når /^jeg vælger "([^"]*)"$/ do |field|
53
+ When %{I choose "#{field}"}
54
+ end
55
+
56
+ Når /^jeg tilsætter 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 )indeholde "([^"]*)"$/ do |field, value|
93
+ Then %{the "#{field}" field should contain "#{value}"}
94
+ end
95
+
96
+ Så /^(?:skal ) "([^"]*)" feltet (?:skal )ikke indeholde "([^"]*)"$/ do |field, value|
97
+ Then %{the "#{field}" field should not contain "#{value}"}
98
+ end
99
+
100
+ Så /^(?:skal ) "([^"]*)" afkrydsningsboksen (?:skal )være krydset af$/ do |label|
101
+ Then %{the "#{label}" checkbox should be checked}
102
+ end
103
+
104
+ Så /^(?:skal ) "([^"]*)" afkrydsningsboksen (?:skal )ikke være krydset af$/ 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