cucumber-rails 1.4.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE.md +52 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +42 -0
  4. data/.gitignore +3 -0
  5. data/.rspec +4 -1
  6. data/.rubocop.yml +68 -0
  7. data/.travis.yml +53 -26
  8. data/Appraisals +27 -63
  9. data/{History.md → CHANGELOG.md} +299 -19
  10. data/CONTRIBUTING.md +18 -27
  11. data/Gemfile +2 -4
  12. data/LICENSE +1 -1
  13. data/README.md +73 -29
  14. data/Rakefile +18 -14
  15. data/bin/install_geckodriver.sh +19 -0
  16. data/bin/install_webpacker.sh +9 -0
  17. data/config/cucumber.yml +5 -3
  18. data/cucumber-rails.gemspec +37 -25
  19. data/dev_tasks/cucumber.rake +3 -3
  20. data/dev_tasks/rspec.rake +3 -6
  21. data/dev_tasks/yard/default/layout/html/footer.erb +1 -1
  22. data/dev_tasks/yard/default/layout/html/layout.erb +5 -5
  23. data/dev_tasks/yard/default/layout/html/logo.erb +1 -1
  24. data/dev_tasks/yard/default/layout/html/setup.rb +6 -1
  25. data/dev_tasks/yard.rake +7 -14
  26. data/features/allow_rescue.feature +17 -12
  27. data/features/annotations.feature +20 -0
  28. data/features/capybara_javascript_drivers.feature +42 -32
  29. data/features/choose_javascript_database_strategy.feature +38 -57
  30. data/features/configuration.feature +48 -0
  31. data/features/database_cleaner.feature +20 -20
  32. data/features/disable_automatic_database_cleaning.feature +13 -19
  33. data/features/emulate_javascript.feature +65 -48
  34. data/features/install_cucumber_rails.feature +6 -5
  35. data/features/no_database.feature +8 -15
  36. data/features/raising_errors.feature +10 -4
  37. data/features/rerun_profile.feature +18 -8
  38. data/features/rest_api.feature +13 -13
  39. data/features/step_definitions/cucumber_rails_steps.rb +52 -66
  40. data/features/support/aruba.rb +5 -0
  41. data/features/support/cucumber_rails_helper.rb +85 -0
  42. data/features/support/env.rb +4 -35
  43. data/features/support/hooks.rb +8 -0
  44. data/gemfiles/rails_4_2.gemfile +10 -0
  45. data/gemfiles/rails_5_0.gemfile +10 -0
  46. data/gemfiles/rails_5_1.gemfile +10 -0
  47. data/gemfiles/rails_5_2.gemfile +10 -0
  48. data/gemfiles/rails_6_0.gemfile +9 -0
  49. data/lib/cucumber/rails/action_dispatch.rb +21 -0
  50. data/lib/cucumber/rails/application.rb +17 -8
  51. data/lib/cucumber/rails/capybara/javascript_emulation.rb +47 -39
  52. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +8 -6
  53. data/lib/cucumber/rails/capybara.rb +2 -0
  54. data/lib/cucumber/rails/database.rb +36 -17
  55. data/lib/cucumber/rails/hooks/active_record.rb +14 -12
  56. data/lib/cucumber/rails/hooks/allow_rescue.rb +2 -0
  57. data/lib/cucumber/rails/hooks/database_cleaner.rb +6 -4
  58. data/lib/cucumber/rails/hooks/mail.rb +4 -4
  59. data/lib/cucumber/rails/hooks.rb +2 -0
  60. data/lib/cucumber/rails/rspec.rb +5 -3
  61. data/lib/cucumber/rails/world.rb +26 -9
  62. data/lib/cucumber/rails.rb +21 -18
  63. data/lib/generators/cucumber/{install/USAGE → USAGE} +2 -2
  64. data/lib/generators/cucumber/{install/install_generator.rb → install_generator.rb} +28 -15
  65. data/lib/generators/cucumber/{install/templates → templates}/config/cucumber.yml.erb +4 -3
  66. data/lib/generators/cucumber/{install/templates → templates}/script/cucumber +1 -0
  67. data/lib/generators/cucumber/{install/templates → templates}/support/_rails_each_run.rb.erb +4 -4
  68. data/lib/generators/cucumber/{install/templates → templates}/support/_rails_prefork.rb.erb +0 -0
  69. data/lib/generators/cucumber/{install/templates → templates}/support/capybara.rb +2 -0
  70. data/lib/generators/cucumber/{install/templates → templates}/support/edit_warning.txt +0 -0
  71. data/lib/generators/cucumber/{install/templates → templates}/support/rails.rb.erb +0 -0
  72. data/lib/generators/cucumber/{install/templates → templates}/support/rails_spork.rb.erb +2 -2
  73. data/lib/generators/cucumber/{install/templates → templates}/tasks/cucumber.rake.erb +19 -8
  74. data/spec/cucumber/rails/database_spec.rb +46 -33
  75. data/spec/generators/cucumber/install_generator_spec.rb +55 -0
  76. data/spec/spec_helper.rb +14 -2
  77. metadata +228 -142
  78. data/Gemfile.appraisal +0 -3
  79. data/features/step_definitions/mongo_steps.rb +0 -3
  80. data/features/support/bundler_pre_support.rb +0 -28
  81. data/features/support/fixtures/bundler-1.0.21.gem +0 -0
  82. data/features/support/fixtures/bundler-1.1.rc.gem +0 -0
  83. data/features/support/legacy_web_steps_support.rb +0 -290
  84. data/gemfiles/capybara_1_1.gemfile +0 -17
  85. data/gemfiles/rails_3_0.gemfile +0 -16
  86. data/gemfiles/rails_3_1.gemfile +0 -17
  87. data/gemfiles/rails_3_2.gemfile +0 -17
  88. data/gemfiles/rails_4_0.gemfile +0 -20
  89. data/lib/cucumber/rails/action_controller.rb +0 -12
  90. data/spec/generators/cucumber/install/install_generator_spec.rb +0 -47
@@ -1,290 +0,0 @@
1
- module WebSteps
2
- def create_web_steps
3
- write_file('features/step_definitions/web_steps.rb', <<-EOF)
4
- # web_steps.rb used to be in Cucumber-Rails, but was removed in 1.1.0. We're still using them in the tests because
5
- # the tests were written while we still thought web_steps.rb was a good idea. We don't think so anymore:
6
- #
7
- # http://groups.google.com/group/cukes/browse_thread/thread/26f80b93c94f2952
8
- # https://github.com/cucumber/cucumber-rails/issues/174
9
- # http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
10
- # http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
11
- # http://elabs.se/blog/15-you-re-cuking-it-wrong
12
- #
13
- # I'm sure someone will find this and paste it into their own projects. Go ahead. It's a bad idea.
14
- # You have been warned.
15
- #
16
- # Aslak
17
-
18
- require 'uri'
19
- require 'cgi'
20
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
21
-
22
- module WithinHelpers
23
- def with_scope(locator)
24
- locator ? within(*selector_for(locator)) { yield } : yield
25
- end
26
- end
27
- World(WithinHelpers)
28
-
29
- # Single-line step scoper
30
- When /^(.*) within (.*[^:])$/ do |step, parent|
31
- with_scope(parent) { When step }
32
- end
33
-
34
- # Multi-line step scoper
35
- When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
36
- with_scope(parent) { When "\#{step}:", table_or_string }
37
- end
38
-
39
- Given /^(?:|I )am on (.+)$/ do |page_name|
40
- visit path_to(page_name)
41
- end
42
-
43
- When /^(?:|I )go to (.+)$/ do |page_name|
44
- visit path_to(page_name)
45
- end
46
-
47
- When /^(?:|I )press "([^"]*)"$/ do |button|
48
- click_button(button)
49
- end
50
-
51
- When /^(?:|I )follow "([^"]*)"$/ do |link|
52
- click_link(link)
53
- end
54
-
55
- When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
56
- fill_in(field, :with => value)
57
- end
58
-
59
- When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
60
- fill_in(field, :with => value)
61
- end
62
-
63
- # Use this to fill in an entire form with data from a table. Example:
64
- #
65
- # When I fill in the following:
66
- # | Account Number | 5002 |
67
- # | Expiry date | 2009-11-01 |
68
- # | Note | Nice guy |
69
- # | Wants Email? | |
70
- #
71
- # TODO: Add support for checkbox, select or option
72
- # based on naming conventions.
73
- #
74
- When /^(?:|I )fill in the following:$/ do |fields|
75
- fields.rows_hash.each do |name, value|
76
- When %{I fill in "\#{name}" with "\#{value}"}
77
- end
78
- end
79
-
80
- When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
81
- select(value, :from => field)
82
- end
83
-
84
- When /^(?:|I )check "([^"]*)"$/ do |field|
85
- check(field)
86
- end
87
-
88
- When /^(?:|I )uncheck "([^"]*)"$/ do |field|
89
- uncheck(field)
90
- end
91
-
92
- When /^(?:|I )choose "([^"]*)"$/ do |field|
93
- choose(field)
94
- end
95
-
96
- When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
97
- attach_file(field, File.expand_path(path))
98
- end
99
-
100
- Then /^(?:|I )should see "([^"]*)"$/ do |text|
101
- if page.respond_to? :should
102
- page.should have_content(text)
103
- else
104
- assert page.has_content?(text)
105
- end
106
- end
107
-
108
- Then /^(?:|I )should see \\/([^\\/]*)\\/$/ do |regexp|
109
- regexp = Regexp.new(regexp)
110
-
111
- if page.respond_to? :should
112
- page.should have_xpath('//*', :text => regexp)
113
- else
114
- assert page.has_xpath?('//*', :text => regexp)
115
- end
116
- end
117
-
118
- Then /^(?:|I )should not see "([^"]*)"$/ do |text|
119
- if page.respond_to? :should
120
- page.should have_no_content(text)
121
- else
122
- assert page.has_no_content?(text)
123
- end
124
- end
125
-
126
- Then /^(?:|I )should not see \\/([^\\/]*)\\/$/ do |regexp|
127
- regexp = Regexp.new(regexp)
128
-
129
- if page.respond_to? :should
130
- page.should have_no_xpath('//*', :text => regexp)
131
- else
132
- assert page.has_no_xpath?('//*', :text => regexp)
133
- end
134
- end
135
-
136
- Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
137
- with_scope(parent) do
138
- field = find_field(field)
139
- field_value = (field.tag_name == 'textarea') ? field.text : field.value
140
- if field_value.respond_to? :should
141
- field_value.should =~ /\#{value}/
142
- else
143
- assert_match(/\#{value}/, field_value)
144
- end
145
- end
146
- end
147
-
148
- Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
149
- with_scope(parent) do
150
- field = find_field(field)
151
- field_value = (field.tag_name == 'textarea') ? field.text : field.value
152
- if field_value.respond_to? :should_not
153
- field_value.should_not =~ /\#{value}/
154
- else
155
- assert_no_match(/\#{value}/, field_value)
156
- end
157
- end
158
- end
159
-
160
- Then /^the "([^"]*)" field should have the error "([^"]*)"$/ do |field, error_message|
161
- element = find_field(field)
162
- classes = element.find(:xpath, '..')[:class].split(' ')
163
-
164
- form_for_input = element.find(:xpath, 'ancestor::form[1]')
165
- using_formtastic = form_for_input[:class].include?('formtastic')
166
- error_class = using_formtastic ? 'error' : 'field_with_errors'
167
-
168
- if classes.respond_to? :should
169
- classes.should include(error_class)
170
- else
171
- assert classes.include?(error_class)
172
- end
173
-
174
- if page.respond_to?(:should)
175
- if using_formtastic
176
- error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
177
- error_paragraph.should have_content(error_message)
178
- else
179
- page.should have_content("\#{field.titlecase} \#{error_message}")
180
- end
181
- else
182
- if using_formtastic
183
- error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
184
- assert error_paragraph.has_content?(error_message)
185
- else
186
- assert page.has_content?("\#{field.titlecase} \#{error_message}")
187
- end
188
- end
189
- end
190
-
191
- Then /^the "([^"]*)" field should have no error$/ do |field|
192
- element = find_field(field)
193
- classes = element.find(:xpath, '..')[:class].split(' ')
194
- if classes.respond_to? :should
195
- classes.should_not include('field_with_errors')
196
- classes.should_not include('error')
197
- else
198
- assert !classes.include?('field_with_errors')
199
- assert !classes.include?('error')
200
- end
201
- end
202
-
203
- Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
204
- with_scope(parent) do
205
- field_checked = find_field(label)['checked']
206
- if field_checked.respond_to? :should
207
- field_checked.should be_true
208
- else
209
- assert field_checked
210
- end
211
- end
212
- end
213
-
214
- Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
215
- with_scope(parent) do
216
- field_checked = find_field(label)['checked']
217
- if field_checked.respond_to? :should
218
- field_checked.should be_false
219
- else
220
- assert !field_checked
221
- end
222
- end
223
- end
224
-
225
- Then /^(?:|I )should be on (.+)$/ do |page_name|
226
- current_path = URI.parse(current_url).path
227
- if current_path.respond_to? :should
228
- current_path.should == path_to(page_name)
229
- else
230
- assert_equal path_to(page_name), current_path
231
- end
232
- end
233
-
234
- Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
235
- query = URI.parse(current_url).query
236
- actual_params = query ? CGI.parse(query) : {}
237
- expected_params = {}
238
- expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
239
-
240
- if actual_params.respond_to? :should
241
- actual_params.should == expected_params
242
- else
243
- assert_equal expected_params, actual_params
244
- end
245
- end
246
-
247
- Then /^show me the page$/ do
248
- save_and_open_page
249
- end
250
- EOF
251
-
252
- write_file('features/support/paths.rb', <<-EOF)
253
- module NavigationHelpers
254
- # Maps a name to a path. Used by the
255
- #
256
- # When /^I go to (.+)$/ do |page_name|
257
- #
258
- # step definition in web_steps.rb
259
- #
260
- def path_to(page_name)
261
- case page_name
262
-
263
- when /^the home\s?page$/
264
- '/'
265
-
266
- # Add more mappings here.
267
- # Here is an example that pulls values out of the Regexp:
268
- #
269
- # when /^(.*)'s profile page$/i
270
- # user_profile_path(User.find_by_login($1))
271
-
272
- else
273
- begin
274
- page_name =~ /^the (.*) page$/
275
- path_components = $1.split(/\s+/)
276
- self.send(path_components.push('path').join('_').to_sym)
277
- rescue NoMethodError, ArgumentError
278
- raise "Can't find mapping from \"\#{page_name}\" to a path.\\n" +
279
- "Now, go and add a mapping in \#{__FILE__}"
280
- end
281
- end
282
- end
283
- end
284
-
285
- World(NavigationHelpers)
286
- EOF
287
- end
288
- end
289
- World(WebSteps)
290
-
@@ -1,17 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "capybara", "~> 1.1.2"
6
- gem "rails", "~> 3.2.12"
7
- gem "turn", "~> 0.9.6"
8
- gem "rspec-rails", "~> 2.12.2"
9
- gem "sass-rails", "~> 3.2.6"
10
- gem "coffee-rails", "~> 3.2.2"
11
- gem "jquery-rails", "~> 2.2.1"
12
- gem "uglifier", "~> 2.1.0"
13
- gem "sqlite3", "~> 1.3.7"
14
- gem "bson_ext", "~> 1.8.5"
15
- gem "database_cleaner", "~> 1.0.1"
16
-
17
- gemspec :path=>"../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.0.20"
6
- gem "capybara", "~> 2.0.2"
7
- gem "turn", "~> 0.9.6"
8
- gem "rspec-rails", "~> 2.12.2"
9
- gem "jquery-rails", "~> 2.2.1"
10
- gem "uglifier", "~> 2.1.0"
11
- gem "sqlite3", "~> 1.3.7"
12
- gem "bson_ext", "~> 1.8.5"
13
- gem "mongoid", "~> 2.2.6"
14
- gem "database_cleaner", "~> 1.0.1"
15
-
16
- gemspec :path=>"../"
@@ -1,17 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.1.11"
6
- gem "capybara", "~> 2.0.2"
7
- gem "turn", "~> 0.9.6"
8
- gem "rspec-rails", "~> 2.12.2"
9
- gem "sass-rails", "~> 3.1.7"
10
- gem "coffee-rails", "~> 3.1.1"
11
- gem "jquery-rails", "~> 2.2.1"
12
- gem "uglifier", "~> 2.1.0"
13
- gem "sqlite3", "~> 1.3.7"
14
- gem "bson_ext", "~> 1.8.5"
15
- gem "database_cleaner", "~> 1.0.1"
16
-
17
- gemspec :path=>"../"
@@ -1,17 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.2.12"
6
- gem "capybara", "~> 2.0.2"
7
- gem "turn", "~> 0.9.6"
8
- gem "rspec-rails", "~> 2.12.2"
9
- gem "sass-rails", "~> 3.2.6"
10
- gem "coffee-rails", "~> 3.2.2"
11
- gem "jquery-rails", "~> 2.2.1"
12
- gem "uglifier", "~> 2.1.0"
13
- gem "sqlite3", "~> 1.3.7"
14
- gem "bson_ext", "~> 1.8.5"
15
- gem "database_cleaner", "~> 1.0.1"
16
-
17
- gemspec :path=>"../"
@@ -1,20 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "protected_attributes", "~> 1.0.3"
6
- gem "rails", "~> 4.0.0"
7
- gem "railties", "~> 4.0.0"
8
- gem "capybara", "~> 2.0.2"
9
- gem "turn", "~> 0.9.6"
10
- gem "rspec-rails", "~> 2.12.2"
11
- gem "sass-rails", "~> 4.0.0"
12
- gem "coffee-rails", "~> 4.0.0"
13
- gem "jquery-rails", "~> 2.2.1"
14
- gem "uglifier", "~> 2.1.0"
15
- gem "sqlite3", "~> 1.3.7"
16
- gem "bson_ext", "~> 1.8.5"
17
- gem "mongoid", :git=>"https://github.com/mongoid/mongoid.git"
18
- gem "database_cleaner", "~> 1.0.1"
19
-
20
- gemspec :path=>"../"
@@ -1,12 +0,0 @@
1
- ActionController::Base.class_eval do
2
- cattr_accessor :allow_rescue
3
- end
4
-
5
- class ActionDispatch::ShowExceptions
6
- alias __cucumber_orig_call__ call
7
-
8
- def call(env)
9
- env['action_dispatch.show_exceptions'] = !!ActionController::Base.allow_rescue
10
- __cucumber_orig_call__(env)
11
- end
12
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # Generators are not automatically loaded by Rails
4
- require 'generators/cucumber/install/install_generator'
5
-
6
- describe Cucumber::InstallGenerator do
7
- # Tell the generator where to put its output (what it thinks of as Rails.root)
8
- destination File.expand_path("../../../../../tmp", __FILE__)
9
-
10
- before { prepare_destination }
11
-
12
- describe 'no arguments' do
13
- before { run_generator }
14
-
15
- describe 'config/cucumber.yml' do
16
- subject { file('config/cucumber.yml') }
17
- it { should exist }
18
- it { should contain "default: <%= std_opts %> features" }
19
- end
20
-
21
- describe 'features/step_definitions folder' do
22
- subject { file('features/step_definitions') }
23
- it { should exist }
24
- end
25
-
26
- describe 'features/support/env.rb' do
27
- subject { file('features/support/env.rb') }
28
- it { should exist }
29
- it { should contain "# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril." }
30
- it { should contain "require 'cucumber/rails'" }
31
- end
32
-
33
- describe 'lib/tasks/cucumber.rake' do
34
- subject { file('lib/tasks/cucumber.rake') }
35
- it { should exist }
36
- it { should contain "# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril." }
37
- it { should contain "task :cucumber => 'cucumber:ok'" }
38
- end
39
-
40
- describe 'script/cucumber' do
41
- subject { file('script/cucumber') }
42
- it { should exist }
43
- it { should contain "load Cucumber::BINARY" }
44
- end
45
-
46
- end
47
- end