cucumber-rails 1.5.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE.md +52 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +42 -0
  4. data/.gitignore +3 -1
  5. data/.rspec +4 -1
  6. data/.rubocop.yml +68 -0
  7. data/.travis.yml +43 -33
  8. data/Appraisals +25 -92
  9. data/{History.md → CHANGELOG.md} +242 -40
  10. data/CONTRIBUTING.md +15 -24
  11. data/Gemfile +2 -4
  12. data/LICENSE +1 -1
  13. data/README.md +57 -27
  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 +2 -5
  18. data/cucumber-rails.gemspec +35 -28
  19. data/dev_tasks/cucumber.rake +2 -0
  20. data/dev_tasks/rspec.rake +2 -0
  21. data/dev_tasks/yard.rake +7 -14
  22. data/dev_tasks/yard/default/layout/html/setup.rb +6 -1
  23. data/features/allow_rescue.feature +16 -11
  24. data/features/annotations.feature +8 -11
  25. data/features/capybara_javascript_drivers.feature +38 -28
  26. data/features/choose_javascript_database_strategy.feature +37 -57
  27. data/features/configuration.feature +48 -0
  28. data/features/database_cleaner.feature +18 -18
  29. data/features/disable_automatic_database_cleaning.feature +12 -18
  30. data/features/emulate_javascript.feature +64 -47
  31. data/features/install_cucumber_rails.feature +4 -4
  32. data/features/no_database.feature +8 -19
  33. data/features/raising_errors.feature +9 -3
  34. data/features/rerun_profile.feature +17 -7
  35. data/features/rest_api.feature +12 -12
  36. data/features/step_definitions/cucumber_rails_steps.rb +44 -88
  37. data/features/support/aruba.rb +3 -1
  38. data/features/support/cucumber_rails_helper.rb +85 -0
  39. data/features/support/env.rb +4 -30
  40. data/features/support/hooks.rb +8 -0
  41. data/gemfiles/rails_4_2.gemfile +5 -13
  42. data/gemfiles/rails_5_0.gemfile +5 -12
  43. data/gemfiles/rails_5_1.gemfile +4 -9
  44. data/gemfiles/rails_5_2.gemfile +10 -0
  45. data/gemfiles/rails_6_0.gemfile +9 -0
  46. data/lib/cucumber/rails.rb +17 -15
  47. data/lib/cucumber/rails/action_dispatch.rb +21 -0
  48. data/lib/cucumber/rails/application.rb +16 -7
  49. data/lib/cucumber/rails/capybara.rb +2 -0
  50. data/lib/cucumber/rails/capybara/javascript_emulation.rb +45 -37
  51. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +6 -4
  52. data/lib/cucumber/rails/database.rb +30 -8
  53. data/lib/cucumber/rails/hooks.rb +2 -0
  54. data/lib/cucumber/rails/hooks/active_record.rb +14 -12
  55. data/lib/cucumber/rails/hooks/allow_rescue.rb +2 -0
  56. data/lib/cucumber/rails/hooks/database_cleaner.rb +6 -4
  57. data/lib/cucumber/rails/hooks/mail.rb +4 -4
  58. data/lib/cucumber/rails/rspec.rb +3 -1
  59. data/lib/cucumber/rails/world.rb +24 -7
  60. data/lib/generators/cucumber/{install/USAGE → USAGE} +0 -0
  61. data/lib/generators/cucumber/{install/install_generator.rb → install_generator.rb} +23 -10
  62. data/lib/generators/cucumber/{install/templates → templates}/config/cucumber.yml.erb +4 -3
  63. data/lib/generators/cucumber/{install/templates → templates}/script/cucumber +1 -0
  64. data/lib/generators/cucumber/{install/templates → templates}/support/_rails_each_run.rb.erb +2 -2
  65. data/lib/generators/cucumber/{install/templates → templates}/support/_rails_prefork.rb.erb +0 -0
  66. data/lib/generators/cucumber/{install/templates → templates}/support/capybara.rb +2 -0
  67. data/lib/generators/cucumber/{install/templates → templates}/support/edit_warning.txt +0 -0
  68. data/lib/generators/cucumber/{install/templates → templates}/support/rails.rb.erb +0 -0
  69. data/lib/generators/cucumber/{install/templates → templates}/support/rails_spork.rb.erb +0 -0
  70. data/lib/generators/cucumber/{install/templates → templates}/tasks/cucumber.rake.erb +9 -9
  71. data/spec/cucumber/rails/database_spec.rb +46 -33
  72. data/spec/generators/cucumber/{install/install_generator_spec.rb → install_generator_spec.rb} +17 -9
  73. data/spec/spec_helper.rb +13 -4
  74. metadata +105 -139
  75. data/Gemfile.appraisal +0 -3
  76. data/features/support/bundler_pre_support.rb +0 -28
  77. data/features/support/fixtures/bundler-1.0.21.gem +0 -0
  78. data/features/support/fixtures/bundler-1.1.rc.gem +0 -0
  79. data/features/support/legacy_web_steps_support.rb +0 -289
  80. data/gemfiles/lowest_version_bounds.gemfile +0 -26
  81. data/gemfiles/rails_4_0.gemfile +0 -19
  82. data/gemfiles/rails_4_1.gemfile +0 -18
  83. data/lib/cucumber/rails/action_controller.rb +0 -12
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
@@ -1,28 +0,0 @@
1
- module BundlerPreHelper
2
- def bundler
3
- fixture 'bundler-1.0.21.gem'
4
- end
5
-
6
- def bundler_pre
7
- fixture 'bundler-1.1.rc.gem'
8
- end
9
-
10
- def gem_install(path)
11
- run_simple("gem install #{path} --no-ri --no-rdoc")
12
- end
13
-
14
- def gem_uninstall(path)
15
- run_simple("gem uninstall #{path}")
16
- end
17
- end
18
-
19
- Before('@bundler-pre') do
20
- extend(BundlerPreHelper)
21
- gem_uninstall bundler
22
- gem_install bundler_pre
23
- end
24
-
25
- After('@bundler-pre') do
26
- gem_uninstall bundler_pre
27
- gem_install bundler
28
- end
@@ -1,289 +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)
@@ -1,26 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "capybara", "~> 1.1.2"
6
- gem "cucumber", "~> 1.3.8"
7
- gem "nokogiri", "~> 1.5.0"
8
- gem "railties", "~> 4.0.0"
9
- gem "mime-types", "~> 1.17.0"
10
- gem "rails", "~> 4.0.0"
11
- gem "protected_attributes", "~> 1.0.3"
12
- gem "turn", "~> 0.9.6"
13
- gem "sass-rails", "~> 4.0.0"
14
- gem "coffee-rails", "~> 4.0.0"
15
- gem "jquery-rails", "~> 2.2.1"
16
- gem "uglifier", "~> 2.1.0"
17
- gem "sqlite3", "~> 1.3.7"
18
- gem "ammeter", "~> 1.0.0"
19
- gem "builder", "~> 3.1.0"
20
- gem "selenium-webdriver", "~> 2.45.0"
21
- gem "database_cleaner", "~> 1.0.0"
22
- gem "factory_girl", "~> 3.2.0"
23
- gem "rspec-rails", "~> 3.0.0"
24
- gem "rake", "~> 0.9.2.2"
25
-
26
- gemspec :path => "../"
@@ -1,19 +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", "~> 3.1.0"
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 "database_cleaner", "~> 1.0.1"
17
- gem "rake", "< 11.0"
18
-
19
- gemspec :path => "../"
@@ -1,18 +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.1.0"
7
- gem "railties", "~> 4.1.0"
8
- gem "capybara", "~> 2.0.2"
9
- gem "rspec-rails", "~> 3.1.0"
10
- gem "sass-rails", "~> 4.0.0"
11
- gem "coffee-rails", "~> 4.0.0"
12
- gem "jquery-rails", "~> 2.2.1"
13
- gem "uglifier", "~> 2.1.0"
14
- gem "sqlite3", "~> 1.3.7"
15
- gem "database_cleaner", "~> 1.0.1"
16
- gem "rake", "< 11.0"
17
-
18
- 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