cucumber-rails 2.0.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +147 -18
  3. data/CONTRIBUTING.md +14 -2
  4. data/LICENSE +1 -1
  5. data/README.md +5 -24
  6. data/lib/cucumber/rails/action_dispatch.rb +21 -0
  7. data/lib/cucumber/rails/application.rb +11 -8
  8. data/lib/cucumber/rails/capybara/javascript_emulation.rb +27 -16
  9. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +40 -11
  10. data/lib/cucumber/rails/database/deletion_strategy.rb +13 -0
  11. data/lib/cucumber/rails/database/null_strategy.rb +15 -0
  12. data/lib/cucumber/rails/database/shared_connection_strategy.rb +27 -0
  13. data/lib/cucumber/rails/database/strategy.rb +35 -0
  14. data/lib/cucumber/rails/database/truncation_strategy.rb +13 -0
  15. data/lib/cucumber/rails/database.rb +9 -58
  16. data/lib/cucumber/rails/hooks/database_cleaner.rb +9 -3
  17. data/lib/cucumber/rails/hooks/mail.rb +1 -1
  18. data/lib/cucumber/rails/world.rb +2 -2
  19. data/lib/cucumber/rails.rb +12 -13
  20. data/lib/generators/cucumber/install_generator.rb +13 -16
  21. data/lib/generators/cucumber/templates/config/cucumber.yml.erb +3 -3
  22. data/lib/generators/cucumber/templates/tasks/cucumber.rake.erb +5 -0
  23. metadata +96 -102
  24. data/.github/ISSUE_TEMPLATE.md +0 -52
  25. data/.github/PULL_REQUEST_TEMPLATE.md +0 -42
  26. data/.gitignore +0 -14
  27. data/.rspec +0 -4
  28. data/.rubocop.yml +0 -33
  29. data/.rubocop_todo.yml +0 -59
  30. data/.travis.yml +0 -60
  31. data/Appraisals +0 -35
  32. data/Gemfile +0 -5
  33. data/Rakefile +0 -53
  34. data/bin/install_geckodriver.sh +0 -19
  35. data/bin/install_webpacker.sh +0 -9
  36. data/config/.gitignore +0 -1
  37. data/config/cucumber.yml +0 -17
  38. data/cucumber-rails.gemspec +0 -44
  39. data/dev_tasks/cucumber.rake +0 -5
  40. data/dev_tasks/rspec.rake +0 -5
  41. data/dev_tasks/yard/default/layout/html/bubble_32x32.png +0 -0
  42. data/dev_tasks/yard/default/layout/html/footer.erb +0 -5
  43. data/dev_tasks/yard/default/layout/html/index.erb +0 -1
  44. data/dev_tasks/yard/default/layout/html/layout.erb +0 -25
  45. data/dev_tasks/yard/default/layout/html/logo.erb +0 -1
  46. data/dev_tasks/yard/default/layout/html/setup.rb +0 -9
  47. data/dev_tasks/yard.rake +0 -36
  48. data/features/allow_rescue.feature +0 -65
  49. data/features/annotations.feature +0 -20
  50. data/features/capybara_javascript_drivers.feature +0 -82
  51. data/features/choose_javascript_database_strategy.feature +0 -125
  52. data/features/configuration.feature +0 -48
  53. data/features/database_cleaner.feature +0 -44
  54. data/features/disable_automatic_database_cleaning.feature +0 -49
  55. data/features/emulate_javascript.feature +0 -109
  56. data/features/install_cucumber_rails.feature +0 -14
  57. data/features/no_database.feature +0 -61
  58. data/features/raising_errors.feature +0 -22
  59. data/features/rerun_profile.feature +0 -47
  60. data/features/rest_api.feature +0 -47
  61. data/features/step_definitions/cucumber_rails_steps.rb +0 -69
  62. data/features/support/aruba.rb +0 -5
  63. data/features/support/cucumber_rails_helper.rb +0 -76
  64. data/features/support/env.rb +0 -6
  65. data/features/support/hooks.rb +0 -8
  66. data/gemfiles/rails_4_2.gemfile +0 -10
  67. data/gemfiles/rails_5_0.gemfile +0 -10
  68. data/gemfiles/rails_5_1.gemfile +0 -10
  69. data/gemfiles/rails_5_2.gemfile +0 -10
  70. data/gemfiles/rails_6_0.gemfile +0 -9
  71. data/lib/cucumber/rails/action_controller.rb +0 -17
  72. data/lib/generators/cucumber/templates/support/rails_spork.rb.erb +0 -13
  73. data/spec/cucumber/rails/database_spec.rb +0 -61
  74. data/spec/generators/cucumber/install_generator_spec.rb +0 -55
  75. data/spec/spec_helper.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aea01cd8d17a13c8f43f785981239c8aeb28202591bce35bedeee997ac2c25ea
4
- data.tar.gz: f021c09f4793b9e179f80214d6572498645fd65a007a5e17121a91a73effc3a4
3
+ metadata.gz: 02bbc6df3e0541e238dfedd61156318fc8766754bd66929553e41b3770507ed0
4
+ data.tar.gz: d9781472cfdebcaccec5fc0879698d486a06809d36809bc95c5624d36e13b6a0
5
5
  SHA512:
6
- metadata.gz: b90e398bf55e9bb8d3f5eb267bd981ba16929f16c2be420829da9498ba4c077f9ba37652a6744ac57a1a96653b2bccf1d0bc57b40aa1700a89725dfd9a95179c
7
- data.tar.gz: 80ee71f600ddff221964012001529345b769503f12b9124257ddca788e8a27e132c62a71a712b80f1d4bd7b314ddfad7c32a741a314fac386d9fad7bb0c0c3f8
6
+ metadata.gz: 8868ff0ebe1844b2eae18b3b8b580ab00683790a7a02bc28aeb421b33ef4022eb4779478fff94de2f5abc80c068bdcdd098decdeab1b180dad37ae40bbe06ae2
7
+ data.tar.gz: 17ab8f1588d771f564aaec40a873e85f43d2b366674bb959bd4d2ddb4f519093f450f2411122498d8437d238a5b347483c34f9590a799d7f96d76ad790fd8e1b
data/CHANGELOG.md CHANGED
@@ -1,20 +1,140 @@
1
- Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) on how to contribute to Cucumber.
1
+ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md)
2
+ on how to contribute to Cucumber.
2
3
 
3
- ## [master](https://github.com/cucumber/cucumber-rails/compare/v2.0.0...master) (Not yet released)
4
+ ## [main](https://github.com/cucumber/cucumber-rails/compare/v2.5.1...main) (Not yet released)
4
5
 
5
6
  ### New Features
6
7
 
7
- *
8
+ ### Changed
9
+
10
+ ### Fixed
11
+
12
+ ## [v2.5.1](https://github.com/cucumber/cucumber-rails/compare/v2.5.0...v2.5.1) (2022-04-01)
13
+
14
+ ### Fixed
15
+
16
+ * Date input support in Rails 7 ([#535](https://github.com/cucumber/cucumber-rails/pull/535) [mgrunberg])
17
+
18
+ ## [v2.5.0](https://github.com/cucumber/cucumber-rails/compare/v2.4.0...v2.5.0) (2022-03-07)
19
+
20
+ ### New Features
21
+
22
+ * Added `:none` option for `javascript_strategy` which indicates no special handling of `@javascript` tagged tests ([#522](https://github.com/cucumber/cucumber-rails/pull/522) [akostadinov])
23
+ * Added support for Rails 7 ([#526](https://github.com/cucumber/cucumber-rails/pull/526/) [mgrunberg])
24
+ * Added Ruby 3.1 support ([#529](https://github.com/cucumber/cucumber-rails/pull/529) [mgrunberg])
25
+
26
+ ### Changed
27
+
28
+ * Dropped Ruby 2.4 support ([#529](https://github.com/cucumber/cucumber-rails/pull/529) [mgrunberg])
29
+
30
+ ## [v2.4.0](https://github.com/cucumber/cucumber-rails/compare/v2.3.0...v2.4.0) (2021-07-21)
31
+
32
+ ### New Features
33
+
34
+ * Added new docker / Makefile script to permit releasing from repo ([#502](https://github.com/cucumber/cucumber-rails/pull/502) [luke-hill])
35
+ * Gem update: allowed cucumber 6/7 ([#515](https://github.com/cucumber/cucumber-rails/pull/515) /
36
+ [#519](https://github.com/cucumber/cucumber-rails/pull/519))
37
+ * Add support for Ruby 3 ([#517](https://github.com/cucumber/cucumber-rails/pull/517/))
38
+
39
+ ### Changed
40
+
41
+ * Updated rubocop to use new major versions ([#504](https://github.com/cucumber/cucumber-rails/pull/504) /
42
+ [#519](https://github.com/cucumber/cucumber-rails/pull/519) [luke-hill])
43
+
44
+ ### Removed
45
+
46
+ * Removed traces of legacy spork setup / help (No longer used) ([#518](https://github.com/cucumber/cucumber-rails/pull/518))
47
+
48
+ ## [v2.3.0](https://github.com/cucumber/cucumber-rails/compare/v2.2.0...v2.3.0) (2021-03-30)
49
+
50
+ ### Changed
51
+
52
+ * Changed dependency from rails to railties to avoid pulling in optional Rails gems like actioncable ([#486](https://github.com/cucumber/cucumber-rails/pull/486) [langalex])
53
+
54
+ * Lightened gem binary by removing un-needed files ([#496](https://github.com/cucumber/cucumber-rails/pull/496) [orien])
55
+
56
+ ### Fixed
57
+
58
+ * Fixed up a couple of legacy capybara specs to use a better format ([#498](https://github.com/cucumber/cucumber-rails/pull/498) [luke-hill])
59
+
60
+ ## [v2.2.0](https://github.com/cucumber/cucumber-rails/compare/v2.1.0...v2.2.0) (2020-08-10)
61
+
62
+ ### New Features
63
+
64
+ * Added more documentation and tests around Javascript tagged scenarios
65
+ ([#480](https://github.com/cucumber/cucumber-rails/pull/480) [luke-hill])
66
+
67
+ * Gem Updates
68
+ * Allowed cucumber5, updated other gem dependencies
69
+ * Updated travis runs and gem builds tested against
70
+ ([#482](https://github.com/cucumber/cucumber-rails/pull/482) [luke-hill])
8
71
 
9
72
  ### Changed
10
73
 
11
- *
74
+ * Dropped Rails 4.2 support ([#392](https://github.com/cucumber/cucumber-rails/pull/392) [deivid-rodriguez])
75
+
76
+ ### Fixed
77
+
78
+ * Database cleaning no longer silently fails when using database_cleaner v2 adapter gems
79
+ ([#467](https://github.com/cucumber/cucumber-rails/pull/467) [botandrose])
80
+
81
+ * Restored compatibility with `database_cleaner` versions earlier than 1.8.0.beta
82
+ ([#473](https://github.com/cucumber/cucumber-rails/pull/473) [cgriego])
83
+
84
+ * Restored previous `database_cleaner` behavior for apps that do not use/load ActiveRecord
85
+ ([#474](https://github.com/cucumber/cucumber-rails/pull/474) [cgriego])
86
+
87
+ * Restored previous compatibility around standard Rails Modules not being loaded
88
+ ([#484](https://github.com/cucumber/cucumber-rails/pull/484) [Draiken])
89
+
90
+ ## [v2.1.0](https://github.com/cucumber/cucumber-rails/compare/v2.0.0...v2.1.0) (2020-06-15)
91
+
92
+ ### New Features
93
+
94
+ * Added metadata to allow gem to be searched / indexed by rubygems
95
+ ([#447](https://github.com/cucumber/cucumber-rails/pull/447) [orien])
96
+
97
+ * Allow Cucumber 4 to be used as an option for cucumber-rails
98
+ * NB: Cucumber4 changes quite a lot of logic with auto-loaders. This means that any previous
99
+ logic that relied implicitly on load-order "may" be affected
100
+ ([#453](https://github.com/cucumber/cucumber-rails/pull/453) [luke-hill] / [deivid-rodriguez])
101
+
102
+ ### Changed
103
+
104
+ * Dropped Ruby 2.3 support (target 2.4 - 2.7) ([#466](https://github.com/cucumber/cucumber-rails/pull/466) [mvz])
105
+
106
+ * Refactored suite to remove a lot of old Rails3/4.0 "ism's"
107
+ * Also migrated a lot of old cucumber styles to cucumber4
108
+ ([#441](https://github.com/cucumber/cucumber-rails/pull/441) [luke-hill])
109
+
110
+ * Refactored alias logic for overriding Rails methods to use `Module#prepend`
111
+ ([#457](https://github.com/cucumber/cucumber-rails/pull/457) [wagenet])
112
+
113
+ * `database_cleaner` (when used), at a version `>= 1.8` will now silence all warnings
114
+ * The suite internally will only test a version `>= 1.8`, so other versions will work but are un-maintained
115
+ ([#463](https://github.com/cucumber/cucumber-rails/pull/463) [deivid-rodriguez])
12
116
 
13
117
  ### Fixed
14
118
 
15
- *
119
+ * Various rubocop / rspec styling fixes
120
+ ([#445](https://github.com/cucumber/cucumber-rails/pull/445) /
121
+ [#449](https://github.com/cucumber/cucumber-rails/pull/449) /
122
+ [#450](https://github.com/cucumber/cucumber-rails/pull/450) /
123
+ [#451](https://github.com/cucumber/cucumber-rails/pull/451) /
124
+ [#452](https://github.com/cucumber/cucumber-rails/pull/452) /
125
+ [#465](https://github.com/cucumber/cucumber-rails/pull/465)
126
+ [mvz] / [luke-hill])
127
+
128
+ * Various CI fixes
129
+ ([#444](https://github.com/cucumber/cucumber-rails/pull/444) /
130
+ [#460](https://github.com/cucumber/cucumber-rails/pull/460) /
131
+ [#464](https://github.com/cucumber/cucumber-rails/pull/464)
132
+ [mvz] / [damonjmurray] / [deivid-rodriguez])
16
133
 
17
- ## [v2.0.0](https://github.com/cucumber/cucumber-rails/compare/v1.8.0...v2.0.0) (Not yet released)
134
+ * Avoid printing a warning about `config.cache_classes` being set to `false` when
135
+ Spring is used ([#462](https://github.com/cucumber/cucumber-rails/pull/462) [janko])
136
+
137
+ ## [v2.0.0](https://github.com/cucumber/cucumber-rails/compare/v1.8.0...v2.0.0) (2019-09-13)
18
138
 
19
139
  ### New Features
20
140
 
@@ -26,7 +146,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
26
146
 
27
147
  * **Breaking change:** `web_steps` have been completely removed from cucumber-rails
28
148
  ([#437](https://github.com/cucumber/cucumber-rails/pull/437) [luke-hill])
29
-
149
+
30
150
  * Altered some branching logic in tests designed to cater for old ruby/rails versions
31
151
  ([#433](https://github.com/cucumber/cucumber-rails/pull/433) [luke-hill])
32
152
 
@@ -34,15 +154,15 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
34
154
 
35
155
  ### Changed
36
156
 
37
- * Drop Ruby 2.2 support (target 2.3 and up) ([#424](https://github.com/cucumber/cucumber-rails/pull/424) [mvz])
38
-
157
+ * Dropped Ruby 2.2 support (target 2.3 and up) ([#424](https://github.com/cucumber/cucumber-rails/pull/424) [mvz])
158
+
39
159
  * Begin to update the core runtime / development dependencies to something a little more recent
40
160
  ([#413](https://github.com/cucumber/cucumber-rails/pull/413) /
41
161
  [#431](https://github.com/cucumber/cucumber-rails/pull/431) /
42
162
  [#432](https://github.com/cucumber/cucumber-rails/pull/432)
43
- [mvz] /
163
+ [mvz] /
44
164
  [luke-hill])
45
-
165
+
46
166
  ### Fixed
47
167
 
48
168
  * Various rubocop / styling issues that had built up over time
@@ -54,21 +174,21 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
54
174
  [#421](https://github.com/cucumber/cucumber-rails/pull/434)
55
175
  [luke-hill] /
56
176
  [mvz])
57
-
177
+
58
178
  * Generic Travis Healthcheck (Fixed up polluted logs and use newer Ubuntu OS)
59
179
  ([#415](https://github.com/cucumber/cucumber-rails/pull/415) /
60
180
  [#417](https://github.com/cucumber/cucumber-rails/pull/417)
61
181
  [luke-hill])
62
-
182
+
63
183
  * Rails6 not building correctly
64
184
  ([#418](https://github.com/cucumber/cucumber-rails/pull/418)
65
185
  [luke-hill])
66
-
186
+
67
187
  * Provisional Ruby 2.7 builds not working
68
188
  ([#427](https://github.com/cucumber/cucumber-rails/pull/427)
69
189
  [amatsuda] /
70
190
  [luke-hill])
71
-
191
+
72
192
  ## [v1.7.0](https://github.com/cucumber/cucumber-rails/compare/v1.6.0...v1.7.0) (2019-04-17)
73
193
 
74
194
  ### Changed
@@ -88,7 +208,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
88
208
  [xtrasimplicity] /
89
209
  [deivid-rodriguez] /
90
210
  [mvz])
91
-
211
+
92
212
  * Various build issues that had built up over the previous year
93
213
  ([#403](https://github.com/cucumber/cucumber-rails/pull/403) /
94
214
  [#404](https://github.com/cucumber/cucumber-rails/pull/404) /
@@ -108,7 +228,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
108
228
  * Switched to Ruby 1.9 hash syntax. ([#371](https://github.com/cucumber/cucumber-rails/pull/371) [mvz](https://github.com/mvz))
109
229
  * Added support to handle rerun files with multiple lines. ([#373]((https://github.com/cucumber/cucumber-rails/pull/345)) [mvz](https://github.com/mvz))
110
230
  * Added support for Rails 5.2 and Capybara 3. ([#378](https://github.com/cucumber/cucumber-rails/pull/378/) [gobijan](https://github.com/gobijan), [radar](https://github.com/radar), [xtrasimplicity](https://github.com/xtrasimplicity))
111
-
231
+
112
232
  ### Fixed
113
233
 
114
234
  * Fix typo ([#343](https://github.com/cucumber/cucumber-rails/pull/343) Olle Jonsson)
@@ -123,7 +243,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
123
243
  ## [v1.4.5](https://github.com/cucumber/cucumber-rails/compare/1.4.4...1.4.5) (2016-09-27)
124
244
 
125
245
  * Add support for Cucumber 3+ (Steve Tooke)
126
-
246
+
127
247
  ## [v1.4.4](https://github.com/cucumber/cucumber-rails/compare/1.4.3...1.4.4) (2016-08-05)
128
248
 
129
249
  * Ensure support for Rails 5
@@ -567,3 +687,12 @@ and to celebrate that cucumber-rails now supports Capybara as an alternative to
567
687
  [luke-hill]: https://github.com/luke-hill
568
688
  [amatsuda]: https://github.com/amatsuda
569
689
  [xtrasimplicity]: https://github.com/xtrasimplicity
690
+ [janko]: https://github.com/janko
691
+ [damonjmurray]: https://github.com/damonjmurray
692
+ [orien]: https://github.com/orien
693
+ [wagenet]: https://github.com/wagenet
694
+ [cgriego]: https://github.com/cgriego
695
+ [botandrose]: https://github.com/botandrose
696
+ [Draiken]: https://github.com/Draiken
697
+ [langalex]: https://github.com/langalex
698
+ [orien]: https://github.com/orien
data/CONTRIBUTING.md CHANGED
@@ -29,11 +29,23 @@ This document is a guide for those maintaining Cucumber-Rails, and others who wo
29
29
  bundle install
30
30
  bin/install_geckodriver.sh
31
31
  bin/install_webpacker.sh
32
- # Then to run tests on one specific gemfile (i.e. Rails 4.2), run
33
- bundle exec appraisal rails_4_2 rake test
32
+ # Then to run tests on one version-specific Gemfile (e.g. gemfiles/rails_6_0.gemfile), run
33
+ bundle exec appraisal rails_6_0 rake test
34
34
  # Or run tests across the full supported stack. Note that because we support many versions. This takes 5-10 minutes
35
35
  bundle exec rake appraisal
36
36
 
37
+ ## Updating Appraisal gems / dependencies of cucumber-rails
38
+
39
+ To remove and rebuild the different gemfiles (for example, to update a rails version or its
40
+ dependencies), use the following:
41
+
42
+ [bundle exec] appraisal update
43
+
44
+ If you've changed versions of the dependencies, you may find it helpful to forcefully clean
45
+ each appraisal's gem lock file in `gemfiles/`. You can do this using:
46
+
47
+ [bundle exec] rake clean
48
+
37
49
  ## Release Process
38
50
 
39
51
  * Make sure `CHANGELOG.md` is updated with the upcoming version number, and has entries for all fixes.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2008-2019 Aslak Hellesøy and the Cucumber Team.
3
+ Copyright (c) 2008-2020 Aslak Hellesøy and the Cucumber Team.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # Cucumber-Rails
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/cucumber-rails.svg)](http://badge.fury.io/rb/cucumber-rails)
4
- [![Build Status](https://secure.travis-ci.org/cucumber/cucumber-rails.svg?branch=master)](http://travis-ci.org/cucumber/cucumber-rails)
4
+ [![Build Status](https://github.com/cucumber/cucumber-rails/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/cucumber/cucumber-rails/actions/workflows/build.yml)
5
5
  [![Code Climate](https://codeclimate.com/github/cucumber/cucumber-rails.svg)](https://codeclimate.com/github/cucumber/cucumber-rails)
6
6
  [![Open Source Helpers](https://www.codetriage.com/cucumber/cucumber-rails/badges/users.svg)](https://www.codetriage.com/cucumber/cucumber-rails)
7
+ [![pull requests](https://oselvar.com/api/badge?label=pull%20requests&csvUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fcucumber%2Foselvar-github-metrics%2Fmain%2Fdata%2Fcucumber%2Fcucumber-rails%2FpullRequests.csv)](https://oselvar.com/github/cucumber/oselvar-github-metrics/main/cucumber/cucumber-rails)
8
+ [![issues](https://oselvar.com/api/badge?label=issues&csvUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fcucumber%2Foselvar-github-metrics%2Fmain%2Fdata%2Fcucumber%2Fcucumber-rails%2Fissues.csv)](https://oselvar.com/github/cucumber/oselvar-github-metrics/main/cucumber/cucumber-rails)
7
9
 
8
- Cucumber-Rails brings Cucumber to Rails 4.2, 5.x and 6.x.
10
+ Cucumber-Rails brings Cucumber to Rails 5.x, 6.x and 7.x.
9
11
 
10
12
  ## Installation
11
13
 
@@ -108,17 +110,7 @@ all gemfiles, run the following commands:
108
110
 
109
111
  To run the suite against a named gemfile, use the following:
110
112
 
111
- [bundle exec] appraisal rails_4_2 rake test
112
-
113
- To remove and rebuild the different gemfiles (for example, to update a rails version or its
114
- dependencies), use the following:
115
-
116
- [bundle exec] appraisal update
117
-
118
- If you've changed versions of the dependencies, you may find it helpful to forcefully clean
119
- each appraisal's gem lock file in `gemfiles/`. You can do this using:
120
-
121
- [bundle exec] rake clean
113
+ [bundle exec] appraisal rails_6_0 rake test
122
114
 
123
115
  ### Adding dependencies
124
116
 
@@ -133,14 +125,3 @@ For example, rspec is a primary development dependency, so it lives in the gemsp
133
125
 
134
126
  [the helper]: https://github.com/cucumber/cucumber-rails/blob/5e37c530560ae1c1a79521c38a54bae0be94242b/features/step_definitions/cucumber_rails_steps.rb#L15
135
127
 
136
- ### NOTE
137
-
138
- If you get an error while trying to run the tests locally, similar to the one below:
139
-
140
- Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
141
-
142
- You need to install a javascript runtime.
143
-
144
- You can do that in ubuntu by using:
145
-
146
- sudo apt-get install nodejs
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActionController::Base.class_eval do
4
+ cattr_accessor :allow_rescue
5
+ end
6
+
7
+ module Cucumber
8
+ module Rails
9
+ module ActionDispatch
10
+ module ShowExceptions
11
+ def call(env)
12
+ env['action_dispatch.show_detailed_exceptions'] = !ActionController::Base.allow_rescue
13
+ env['action_dispatch.show_exceptions'] = !env['action_dispatch.show_detailed_exceptions']
14
+ super(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ ActionDispatch::ShowExceptions.prepend(Cucumber::Rails::ActionDispatch::ShowExceptions)
@@ -7,17 +7,20 @@ require 'rails/application'
7
7
  # Instead we are overriding ActionDispatch::ShowExceptions to be able to
8
8
  # toggle whether or not exceptions are raised.
9
9
 
10
- module Rails
11
- class Application
12
- alias __cucumber_orig_initialize__ initialize!
10
+ module Cucumber
11
+ module Rails
12
+ module Application
13
+ def initialize!
14
+ ad = config.action_dispatch
13
15
 
14
- def initialize!
15
- ad = config.action_dispatch
16
+ def ad.show_exceptions
17
+ true
18
+ end
16
19
 
17
- def ad.show_exceptions
18
- true
20
+ super
19
21
  end
20
- __cucumber_orig_initialize__
21
22
  end
22
23
  end
23
24
  end
25
+
26
+ Rails::Application.prepend(Cucumber::Rails::Application)
@@ -48,27 +48,38 @@ module Cucumber
48
48
  js_form['action'] = action
49
49
  js_form['method'] = method
50
50
 
51
- if emulated_method && !emulated_method.casecmp(method).zero?
52
- input = document.create_element('input')
53
- input['type'] = 'hidden'
54
- input['name'] = '_method'
55
- input['value'] = emulated_method
56
- js_form.add_child(input)
57
- end
51
+ add_hidden_method_input(document, js_form) unless same?(emulated_method, method)
58
52
 
59
- # rails will wipe the session if the CSRF token is not sent
60
- # with non-GET requests
61
- if csrf? && !emulated_method.casecmp('get').zero?
62
- input = document.create_element('input')
63
- input['type'] = 'hidden'
64
- input['name'] = csrf_param
65
- input['value'] = csrf_token
66
- js_form.add_child(input)
67
- end
53
+ # rails will wipe the session if the CSRF token is not sent with non-GET requests
54
+ add_hidden_csrf_input(document, js_form) if csrf? && !get?(emulated_method)
68
55
 
69
56
  js_form
70
57
  end
71
58
 
59
+ def same?(emulated_method, method)
60
+ emulated_method.casecmp(method).zero?
61
+ end
62
+
63
+ def add_hidden_method_input(document, js_form)
64
+ input = document.create_element('input')
65
+ input['type'] = 'hidden'
66
+ input['name'] = '_method'
67
+ input['value'] = emulated_method
68
+ js_form.add_child(input)
69
+ end
70
+
71
+ def get?(emulated_method)
72
+ same?(emulated_method, 'get')
73
+ end
74
+
75
+ def add_hidden_csrf_input(document, js_form)
76
+ input = document.create_element('input')
77
+ input['type'] = 'hidden'
78
+ input['name'] = csrf_param
79
+ input['value'] = csrf_token
80
+ js_form.add_child(input)
81
+ end
82
+
72
83
  def link_with_non_get_http_method?
73
84
  tag_name == 'a' &&
74
85
  element_node['data-method'] &&
@@ -7,31 +7,60 @@ module Cucumber
7
7
  module SelectDatesAndTimes
8
8
  # Select a Rails date. Options hash must include from: +label+
9
9
  def select_date(date, options)
10
- date = Date.parse(date)
11
- base_dom_id = get_base_dom_id_from_label_tag(options[:from])
10
+ date = Date.parse(date)
11
+ base_dom_id = get_base_dom_from_options(options)
12
12
 
13
- find(:xpath, ".//select[@id='#{base_dom_id}_1i']").select(date.year.to_s)
14
- find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l(date, format: '%B'))
15
- find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
13
+ # Rails 7 use HTML5 input type="date" by default. If input is not present fallback to plain select boxes alternative.
14
+ # It's safe to use has_css? without waiting/retry. We already know field's label is visible
15
+ if html5_input_field_present?(base_dom_id)
16
+ fill_in options[:from], with: date
17
+ else
18
+ find(:xpath, ".//select[@id='#{base_dom_id}_1i']").select(date.year.to_s)
19
+ find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l(date, format: '%B'))
20
+ find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
21
+ end
16
22
  end
17
23
 
18
24
  # Select a Rails time. Options hash must include from: +label+
19
25
  def select_time(time, options)
20
- time = Time.zone.parse(time)
21
- base_dom_id = get_base_dom_id_from_label_tag(options[:from])
26
+ time = Time.zone.parse(time)
27
+ base_dom_id = get_base_dom_from_options(options)
22
28
 
23
- find(:xpath, ".//select[@id='#{base_dom_id}_4i']").select(time.hour.to_s.rjust(2, '0'))
24
- find(:xpath, ".//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
29
+ # Rails 7 use HTML5 input type="time" by default. If input is not present fallback to plain select boxes alternative.
30
+ # It's safe to use has_css? without waiting/retry. We already know field's label is visible
31
+ if html5_input_field_present?(base_dom_id)
32
+ fill_in options[:from], with: time
33
+ else
34
+ find(:xpath, ".//select[@id='#{base_dom_id}_4i']").select(time.hour.to_s.rjust(2, '0'))
35
+ find(:xpath, ".//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
36
+ end
25
37
  end
26
38
 
27
39
  # Select a Rails datetime. Options hash must include from: +label+
28
40
  def select_datetime(datetime, options)
29
- select_date(datetime, options)
30
- select_time(datetime, options)
41
+ base_dom_id = get_base_dom_id_from_label_tag(options[:from])
42
+
43
+ # Rails 7 use HTML5 input type="datetime-local" by default. If input is not present fallback to plain select boxes alternative.
44
+ # It's safe to use has_css? without waiting/retry. We already know field's label is visible
45
+ if html5_input_field_present?(base_dom_id)
46
+ fill_in options[:from], with: DateTime.parse(datetime)
47
+ else
48
+ extended_options = options.merge(base_dom_id: base_dom_id)
49
+ select_date(datetime, extended_options)
50
+ select_time(datetime, extended_options)
51
+ end
31
52
  end
32
53
 
33
54
  private
34
55
 
56
+ def html5_input_field_present?(base_dom_id)
57
+ ::Rails::VERSION::MAJOR >= 7 && page.has_css?("##{base_dom_id}", wait: 0)
58
+ end
59
+
60
+ def get_base_dom_from_options(options)
61
+ options[:base_dom_id] || get_base_dom_id_from_label_tag(options[:from])
62
+ end
63
+
35
64
  # @example "event_starts_at_"
36
65
  def get_base_dom_id_from_label_tag(field)
37
66
  find(:xpath, ".//label[contains(., '#{field}')]")['for'].gsub(/(_[1-5]i)$/, '')
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cucumber
4
+ module Rails
5
+ module Database
6
+ class DeletionStrategy < Strategy
7
+ def before_js
8
+ super :deletion
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cucumber
4
+ module Rails
5
+ module Database
6
+ class NullStrategy
7
+ def before_js; end
8
+
9
+ def before_non_js; end
10
+
11
+ def after; end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cucumber
4
+ module Rails
5
+ module Database
6
+ class SharedConnectionStrategy < Strategy
7
+ def before_js
8
+ # Forces all threads to share a connection on a per-model basis,
9
+ # as connections may vary per model as per establish_connection. This works
10
+ # on Capybara because it starts the web server in a thread.
11
+ ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
12
+ ActiveRecord::Base.descendants.each do |model|
13
+ model.shared_connection = model.connection
14
+ end
15
+ end
16
+
17
+ def before_non_js
18
+ # Do not use a shared connection unless we're in a @javascript scenario
19
+ ActiveRecord::Base.shared_connection = nil
20
+ ActiveRecord::Base.descendants.each do |model|
21
+ model.shared_connection = nil
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cucumber
4
+ module Rails
5
+ module Database
6
+ class Strategy
7
+ def initialize(options = {})
8
+ @options = options
9
+ end
10
+
11
+ def before_js(strategy)
12
+ @original_strategy = if defined?(DatabaseCleaner::VERSION) && Gem::Version.new(DatabaseCleaner::VERSION) >= Gem::Version.new('1.8.0.beta')
13
+ raise "No DatabaseCleaner strategies found. Make sure you have required one of DatabaseCleaner's adapters" if DatabaseCleaner.cleaners.empty?
14
+
15
+ DatabaseCleaner.cleaners.values.first.strategy # that feels like a nasty hack
16
+ else
17
+ DatabaseCleaner.connections.first.strategy # that feels like a nasty hack
18
+ end
19
+ DatabaseCleaner.strategy = strategy, @options
20
+ end
21
+
22
+ def before_non_js
23
+ # no-op
24
+ end
25
+
26
+ def after
27
+ return unless @original_strategy
28
+
29
+ DatabaseCleaner.strategy = @original_strategy
30
+ @original_strategy = nil
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cucumber
4
+ module Rails
5
+ module Database
6
+ class TruncationStrategy < Strategy
7
+ def before_js
8
+ super :truncation
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end