cucumber-rails 1.8.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4583ae621b7346d537d3ab6e4e66da4f39b99c04e5403aab0d94a60fa9e20142
4
- data.tar.gz: 832a66009f3801b9a1efb43d7a83a853076465afbbcaf2b44fbc2b25514fae75
3
+ metadata.gz: aea01cd8d17a13c8f43f785981239c8aeb28202591bce35bedeee997ac2c25ea
4
+ data.tar.gz: f021c09f4793b9e179f80214d6572498645fd65a007a5e17121a91a73effc3a4
5
5
  SHA512:
6
- metadata.gz: ab69574710466da0405aa96555ade3c78a5013f29181534908bdfd6fc92157fe9410fc65228920a90cdfc1862079573754aa63beaeff53229fa2574b6f3a09a8
7
- data.tar.gz: 31f270978a478b0ca111271417f19325b60e7d1f6823abddc62598ae0fabcfc9c93dfc494775d7c8451e08b2dc9c3b4e9f296148552b766272dc99793487df6b
6
+ metadata.gz: b90e398bf55e9bb8d3f5eb267bd981ba16929f16c2be420829da9498ba4c077f9ba37652a6744ac57a1a96653b2bccf1d0bc57b40aa1700a89725dfd9a95179c
7
+ data.tar.gz: 80ee71f600ddff221964012001529345b769503f12b9124257ddca788e8a27e132c62a71a712b80f1d4bd7b314ddfad7c32a741a314fac386d9fad7bb0c0c3f8
data/.rspec CHANGED
@@ -1 +1,4 @@
1
- --format progress --colour
1
+ --format progress
2
+ --color
3
+ --order random
4
+ --require spec_helper
@@ -7,9 +7,6 @@ require:
7
7
  AllCops:
8
8
  TargetRubyVersion: 2.3
9
9
  Exclude:
10
- # This file is something which we aren't advising people to use
11
- # Probably need to consider deleting this fully at some point
12
- - 'features/support/legacy_web_steps_support.rb'
13
10
  # These are auto-generated from a load of features that we
14
11
  # don't have direct control over
15
12
  - 'tmp/**/*'
data/Appraisals CHANGED
@@ -17,19 +17,19 @@ end
17
17
  appraise 'rails_5_1' do
18
18
  gem 'capybara', '< 3.16.0', platform: :mri_23
19
19
  gem 'nokogiri', '< 1.9.1', platform: :mri_23
20
- gem 'railties', '~> 5.1.0'
20
+ gem 'railties', '~> 5.1.7'
21
21
  gem 'sqlite3', '~> 1.3.13'
22
22
  end
23
23
 
24
24
  appraise 'rails_5_2' do
25
25
  gem 'capybara', '< 3.16.0', platform: :mri_23
26
26
  gem 'nokogiri', '< 1.9.1', platform: :mri_23
27
- gem 'railties', '~> 5.2.3'
27
+ gem 'railties', '~> 5.2.0'
28
28
  gem 'sqlite3', '~> 1.3.13'
29
29
  end
30
30
 
31
31
  appraise 'rails_6_0' do
32
- gem 'railties', '~> 6.0.0.rc2'
33
- gem 'rails', '~> 6.0.0.rc2'
32
+ gem 'railties', '~> 6.0.0'
33
+ gem 'rails', '~> 6.0.0'
34
34
  gem 'sqlite3', '~> 1.4'
35
35
  end
@@ -1,15 +1,35 @@
1
1
  Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) on how to contribute to Cucumber.
2
2
 
3
- ## [master](https://github.com/cucumber/cucumber-rails/compare/v1.8.0...master) (Not yet released)
3
+ ## [master](https://github.com/cucumber/cucumber-rails/compare/v2.0.0...master) (Not yet released)
4
+
5
+ ### New Features
6
+
7
+ *
4
8
 
5
9
  ### Changed
6
10
 
7
11
  *
8
-
12
+
9
13
  ### Fixed
10
14
 
11
15
  *
12
16
 
17
+ ## [v2.0.0](https://github.com/cucumber/cucumber-rails/compare/v1.8.0...v2.0.0) (Not yet released)
18
+
19
+ ### New Features
20
+
21
+ * New functionality allows users to Configure whether `Rack::Test` methods get auto-mixed in
22
+ * Setting `ENV['CR_REMOVE_RACK_TEST_HELPERS] = "true"` will remove these methods from the `World`
23
+ ([#440](https://github.com/cucumber/cucumber-rails/pull/440) [luke-hill])
24
+
25
+ ### Changed
26
+
27
+ * **Breaking change:** `web_steps` have been completely removed from cucumber-rails
28
+ ([#437](https://github.com/cucumber/cucumber-rails/pull/437) [luke-hill])
29
+
30
+ * Altered some branching logic in tests designed to cater for old ruby/rails versions
31
+ ([#433](https://github.com/cucumber/cucumber-rails/pull/433) [luke-hill])
32
+
13
33
  ## [v1.8.0](https://github.com/cucumber/cucumber-rails/compare/v1.7.0..v1.8.0) (2019-08-06)
14
34
 
15
35
  ### Changed
data/README.md CHANGED
@@ -5,7 +5,7 @@
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
7
 
8
- Cucumber-Rails brings Cucumber to Rails 4.2, Rails 5.x and Rails 6.0.
8
+ Cucumber-Rails brings Cucumber to Rails 4.2, 5.x and 6.x.
9
9
 
10
10
  ## Installation
11
11
 
@@ -43,7 +43,8 @@ Without Rake:
43
43
 
44
44
  ## Configuration options
45
45
 
46
- By default, cucumber-rails runs `DatabaseCleaner.start` and `DatabaseCleaner.clean` before and after your scenarios. You can disable this behaviour like so:
46
+ By default, cucumber-rails runs `DatabaseCleaner.start` and `DatabaseCleaner.clean`
47
+ before and after your scenarios. You can disable this behaviour like so:
47
48
 
48
49
  ```ruby
49
50
  # features/support/env.rb
@@ -51,6 +52,12 @@ By default, cucumber-rails runs `DatabaseCleaner.start` and `DatabaseCleaner.cle
51
52
  Cucumber::Rails::Database.autorun_database_cleaner = false
52
53
  ```
53
54
 
55
+ By default, cucumber-rails will auto mix-in the helpers from `Rack::Test` into your default Cucumber World instance. You can prevent this behaviour like so:
56
+ ```ruby
57
+ # features/support/env.rb
58
+ ENV['CR_REMOVE_RACK_TEST_HELPERS'] = 'true'
59
+ ```
60
+
54
61
  ## Upgrading from a previous version
55
62
 
56
63
  When upgrading from a previous version it is recommended that you rerun:
@@ -59,14 +66,20 @@ When upgrading from a previous version it is recommended that you rerun:
59
66
 
60
67
  ## Bugs and feature requests
61
68
 
62
- The *only* way to have a bug fixed or a new feature accepted is to describe it with a Cucumber feature. Let's say you think you have found a bug in the cucumber:install generator. Fork this project, clone it to your workstation and check out a branch with a descriptive name:
69
+ The *only* way to have a bug fixed or a new feature accepted is to describe it with a
70
+ Cucumber feature. Let's say you think you have found a bug in the cucumber:install generator.
71
+ Fork this project, clone it to your workstation and check out a branch with a descriptive name:
63
72
 
64
73
  git clone git@github.com:you/cucumber-rails.git
65
74
  git checkout -b bugfix/generator-fails-on-ruby-25
66
75
 
67
- Start by making sure you can run the existing features. Now, create a feature that demonstrates what's wrong. See the existing features for examples. When you have a failing feature that reproduces the bug, commit, push and send a pull request. Someone from the Cucumber-Rails team will review it and hopefully create a fix.
76
+ Start by making sure you can run the existing features. Now, create a feature that demonstrates
77
+ what's wrong. See the existing features for examples. When you have a failing feature that
78
+ reproduces the bug, commit, push and send a pull request. Someone from the Cucumber-Rails team
79
+ will review it and hopefully create a fix.
68
80
 
69
- If you know how to fix the bug yourself, make a second commit (after committing the failing feature) before you send the pull request.
81
+ If you know how to fix the bug yourself, make a second commit (after committing the failing
82
+ feature) before you send the pull request.
70
83
 
71
84
  ### Setting up your environment
72
85
 
@@ -85,7 +98,10 @@ With all dependencies installed, all specs and features should pass:
85
98
 
86
99
  ### Running Appraisal suite
87
100
 
88
- In order to test against multiple versions of key dependencies, the [Appraisal](https://github.com/thoughtbot/appraisal) is used to generate multiple gemfiles, stored in the `gemfiles/` directory. Normally these will only run on Travis; however, if you want to run the full test suite against all gemfiles, run the following commands:
101
+ In order to test against multiple versions of key dependencies, the [Appraisal](https://github.com/thoughtbot/appraisal)
102
+ gem is used to generate multiple gemfiles, stored in the `gemfiles/` directory.
103
+ Normally these will only run on Travis; however, if you want to run the full test suite against
104
+ all gemfiles, run the following commands:
89
105
 
90
106
  [bundle exec] appraisal install
91
107
  [bundle exec] appraisal rake test
@@ -94,11 +110,13 @@ To run the suite against a named gemfile, use the following:
94
110
 
95
111
  [bundle exec] appraisal rails_4_2 rake test
96
112
 
97
- To remove and rebuild the different gemfiles (for example, to update a rails version or its dependencies), use the following:
113
+ To remove and rebuild the different gemfiles (for example, to update a rails version or its
114
+ dependencies), use the following:
98
115
 
99
116
  [bundle exec] appraisal update
100
117
 
101
- If you've changed versions of the dependencies, you may find it helpful to forcefully clean each appraisal's gem lock file in `gemfiles/`. You can do this using:
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:
102
120
 
103
121
  [bundle exec] rake clean
104
122
 
@@ -108,7 +126,8 @@ To support the multiple-gemfile testing, when adding a new dependency the follow
108
126
 
109
127
  1. If it's a runtime dependency of the gem, add it to the gemspec
110
128
  2. If it's a primary development dependency, add it to the gemspec
111
- 3. If it's a dependency of a generated rails app in a test, add it to [the helper] that modifies that Gemfile.
129
+ 3. If it's a dependency of a generated rails app in a test, add it to [the helper] that
130
+ modifies the `Gemfile`.
112
131
 
113
132
  For example, rspec is a primary development dependency, so it lives in the gemspec.
114
133
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'cucumber-rails'
7
- s.version = '1.8.0'
7
+ s.version = '2.0.0'
8
8
  s.authors = ['Aslak Hellesøy', 'Dennis Blöte', 'Rob Holland']
9
9
  s.description = 'Cucumber Generator and Runtime for Rails'
10
10
  s.summary = "#{s.name}-#{s.version}"
@@ -21,8 +21,8 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # Main development dependencies
23
23
  s.add_development_dependency('ammeter', '>= 1.1.4')
24
- s.add_development_dependency('appraisal', '~> 2.2')
25
24
  s.add_development_dependency('aruba', '~> 0.14.4')
25
+ s.add_development_dependency('appraisal', '~> 2.2')
26
26
  s.add_development_dependency('bundler', '>= 1.17')
27
27
  s.add_development_dependency('rails', ['>= 4.2', '< 7'])
28
28
  s.add_development_dependency('rake', '>= 12.0')
@@ -1,22 +1,20 @@
1
1
  Feature: Annotations
2
2
 
3
- I order to track my development progress
3
+ In order to track my development progress
4
4
  As a developer
5
5
  I should be able to list annotations in my features
6
6
 
7
- Background:
7
+ Scenario: See annotations in feature file
8
8
  Given I have created a new Rails app with no database and installed cucumber-rails
9
- When I write to "features/tests.feature" with:
9
+ When I write to "features/products.feature" with:
10
10
  """
11
- Feature: Tests
12
- Scenario: Tests
11
+ Feature: Products
12
+ Scenario: Test a Product
13
13
  # TODO: When I go to the products page
14
14
  """
15
-
16
- Scenario: See annotations in .feature file
17
15
  When I run `bundle exec rake notes`
18
16
  Then it should pass with:
19
17
  """
20
- features/tests.feature:
21
- * [ 3] [TODO] When I go to the products page
18
+ features/products.feature:
19
+ * [3] [TODO] When I go to the products page
22
20
  """
@@ -5,12 +5,6 @@ Feature: Capybara Javascript Drivers
5
5
  Given I have created a new Rails app and installed cucumber-rails
6
6
  And I force selenium to run Firefox in headless mode
7
7
  When I run `bundle exec rails g scaffold appointment name:string when:datetime`
8
- And I write to "features/step_definitions/date_time_steps.rb" with:
9
- """
10
- When('I select {string} as the {string} date and time') do |datetime, selector|
11
- select_datetime(datetime, from: selector)
12
- end
13
- """
14
8
 
15
9
  Scenario: Use a particular driver
16
10
  When I write to "features/create_appointment.feature" with:
@@ -25,6 +19,28 @@ Feature: Capybara Javascript Drivers
25
19
  Then I should see "Norway's constitution"
26
20
  And I should see "2015-02-20 15:10:00 UTC"
27
21
  """
22
+ And I write to "features/create_appointment_steps.rb" with:
23
+ """
24
+ Given('I am on the new appointment page') do
25
+ visit new_appointment_path
26
+ end
27
+
28
+ When('I fill in {string} for {string}') do |value, field|
29
+ fill_in(field, with: value)
30
+ end
31
+
32
+ When('I press {string}') do |button|
33
+ click_button(button)
34
+ end
35
+
36
+ Then('I should see {string}') do |text|
37
+ expect(page).to have_content(text)
38
+ end
39
+
40
+ When('I select {string} as the {string} date and time') do |datetime, selector|
41
+ select_datetime(datetime, from: selector)
42
+ end
43
+ """
28
44
  And I run `bundle exec rake db:migrate`
29
45
  And I run `bundle exec rake cucumber`
30
46
  Then the feature run should pass with:
@@ -40,18 +56,22 @@ Feature: Capybara Javascript Drivers
40
56
  Feature: Create appointments
41
57
  Scenario: Visit the Constitution on May 17
42
58
  Given a random appointment
43
- And I am viewing a random appointment
59
+ And I am viewing the appointment
44
60
  Then I should see "Random appointment"
45
61
  """
46
- And I write to "features/step_definitions/custom_steps.rb" with:
62
+ And I write to "features/step_definitions/create_appointment_steps.rb" with:
47
63
  """
48
64
  Given('a random appointment') do
49
65
  @appointment = Appointment.create!(name: 'Random appointment', when: DateTime.now)
50
66
  end
51
67
 
52
- Given('I am viewing a random appointment') do
68
+ Given('I am viewing the appointment') do
53
69
  visit appointment_path(@appointment)
54
70
  end
71
+
72
+ Then('I should see {string}') do |text|
73
+ expect(page).to have_content(text)
74
+ end
55
75
  """
56
76
  And I run `bundle exec rake db:migrate`
57
77
  And I run `bundle exec rake cucumber`
@@ -0,0 +1,48 @@
1
+ Feature: Cucumber Rails Configuration
2
+
3
+ In order to configure how Cucumber-Rails runs
4
+ As a developer
5
+ I should be able to alter the settings of my project
6
+
7
+ Scenario: Default configuration
8
+ Given I have created a new Rails app with no database and installed cucumber-rails
9
+ When I write to "features/config.feature" with:
10
+ """
11
+ Feature: Rack Test Methods
12
+ Scenario: Default Methods are added to the World
13
+ Then Rack Test should be mixed into the Cucumber World
14
+ """
15
+ When I write to "features/step_definitions/config_steps.rb" with:
16
+ """
17
+ Then('Rack Test should be mixed into the Cucumber World') do
18
+ expect(self.class.ancestors).to include(Rack::Test::Methods)
19
+ end
20
+ """
21
+ And I run `bundle exec rake cucumber`
22
+ Then the feature run should pass with:
23
+ """
24
+ 1 scenario (1 passed)
25
+ 1 step (1 passed)
26
+ """
27
+
28
+ Scenario: Altered configuration
29
+ Given I have created a new Rails app with no database and installed cucumber-rails
30
+ And I set the environment variable "CR_REMOVE_RACK_TEST_HELPERS" to "true"
31
+ When I write to "features/config.feature" with:
32
+ """
33
+ Feature: Rack Test Methods
34
+ Scenario: Rack Test Methods can be removed from the world
35
+ Then Rack Test should not be mixed into the Cucumber World
36
+ """
37
+ When I write to "features/step_definitions/config_steps.rb" with:
38
+ """
39
+ Then('Rack Test should not be mixed into the Cucumber World') do
40
+ expect(self.class.ancestors).not_to include(Rack::Test::Methods)
41
+ end
42
+ """
43
+ And I run `bundle exec rake cucumber`
44
+ Then the feature run should pass with:
45
+ """
46
+ 1 scenario (1 passed)
47
+ 1 step (1 passed)
48
+ """
@@ -1,18 +1,18 @@
1
- Feature: DatabaseCleaner
1
+ Feature: Database Cleaner
2
2
 
3
3
  Scenario: Create records in background
4
4
  Given I have created a new Rails app and installed cucumber-rails
5
5
  When I write to "features/widgets.feature" with:
6
6
  """
7
7
  Feature: Create widgets
8
- Background: some widgets
8
+ Background: 2 initial widgets
9
9
  Given I have 2 widgets
10
10
 
11
- Scenario: Add 3
11
+ Scenario: Add 3 widgets
12
12
  When I create 3 more widgets
13
13
  Then I should have 5 widgets
14
14
 
15
- Scenario: Add 7
15
+ Scenario: Add 7 widgets
16
16
  When I create 7 more widgets
17
17
  Then I should have 9 widgets
18
18
  """
@@ -1,25 +1,24 @@
1
1
  Feature: Emulate Javascript
2
2
 
3
- Scenario: See a widget
3
+ Background:
4
4
  Given I have created a new Rails app and installed cucumber-rails
5
5
  And I force selenium to run Firefox in headless mode
6
6
  When I run `rails generate scaffold widget name:string`
7
- And I write to "features/f.feature" with:
8
- """
9
- @javascript
10
- Feature: Widget inventory
11
- Scenario: Delete a widget
12
- Given there is a widget named "wrench"
13
- When I go to the widgets page
14
- Then I should see "wrench"
15
- """
16
- And I write to "features/step_definitions/s.rb" with:
17
- """
7
+ And I write to "features/step_definitions/widget_steps.rb" with:
8
+ """
18
9
  Given('there is a widget named {string}') do |name|
19
10
  FactoryBot.create(:widget, name: name)
20
11
  end
12
+
13
+ When('I am on the widgets page') do
14
+ visit widgets_path
15
+ end
16
+
17
+ Then('I should see {string}') do |text|
18
+ expect(page).to have_content(text)
19
+ end
21
20
  """
22
- And I write to "features/support/factories.rb" with:
21
+ And I write to "features/support/factories/widget.rb" with:
23
22
  """
24
23
  FactoryBot.define do
25
24
  factory :widget do
@@ -27,6 +26,17 @@ Feature: Emulate Javascript
27
26
  end
28
27
  end
29
28
  """
29
+
30
+ Scenario: See a widget
31
+ When I write to "features/widgets.feature" with:
32
+ """
33
+ @javascript
34
+ Feature: Widget inventory
35
+ Scenario: Delete a widget
36
+ Given there is a widget named "wrench"
37
+ And I am on the widgets page
38
+ Then I should see "wrench"
39
+ """
30
40
  And I run `bundle exec rake db:migrate`
31
41
  And I run `bundle exec rake cucumber`
32
42
  Then the feature run should pass with:
@@ -36,9 +46,7 @@ Feature: Emulate Javascript
36
46
  """
37
47
 
38
48
  Scenario: Pass on the CSRF token
39
- Given I have created a new Rails app and installed cucumber-rails
40
- When I run `rails generate scaffold widget name:string`
41
- And I run `sed -i -e 's/forgery_protection *= false/forgery_protection = true/' config/environments/test.rb`
49
+ When I run `sed -i -e 's/forgery_protection *= false/forgery_protection = true/' config/environments/test.rb`
42
50
  And I run `rails generate controller session establish`
43
51
  And I write to "app/controllers/session_controller.rb" with:
44
52
  """
@@ -58,31 +66,38 @@ Feature: Emulate Javascript
58
66
  end
59
67
  end
60
68
  """
61
- And I write to "features/f.feature" with:
69
+ And I write to "features/widgets.feature" with:
62
70
  """
63
71
  Feature: Widget inventory
64
72
  Scenario: Delete a widget
65
73
  Given there is a widget named "wrench"
66
- When I go to the session establish page
67
- And I go to the widgets page
74
+ And I am on the session establish page
75
+ And I am on the widgets page
68
76
  Then I should see "wrench"
69
77
  When I follow "Destroy"
70
78
  Then I should not see "denied"
71
79
  And I should be on the widgets page
72
80
  And I should not see "wrench"
73
81
  """
74
- And I write to "features/step_definitions/s.rb" with:
82
+ And I append to "features/step_definitions/widget_steps.rb" with:
83
+ # TODO: Remove the newline below (Required) once bug is fixed: https://github.com/cucumber/aruba/issues/662
75
84
  """
76
- Given('there is a widget named {string}') do |name|
77
- FactoryBot.create(:widget, name: name)
85
+
86
+ Given('I am on the session establish page') do
87
+ visit session_establish_path
78
88
  end
79
- """
80
- And I write to "features/support/factories.rb" with:
81
- """
82
- FactoryBot.define do
83
- factory :widget do
84
- name { 'testwidget' }
85
- end
89
+
90
+ When('I follow {string}') do |link|
91
+ click_link(link)
92
+ end
93
+
94
+ Then('I should not see {string}') do |text|
95
+ expect(page).not_to have_content(text)
96
+ end
97
+
98
+ Then('I should be on the widgets page') do
99
+ current_path = URI.parse(current_url).path
100
+ expect(current_path).to eq(widgets_path)
86
101
  end
87
102
  """
88
103
  And I run `bundle exec rake db:migrate`
@@ -1,7 +1,7 @@
1
- Feature: Rails
2
- In order to take over the world
3
- Cucumber-Rails should work on major versions
4
- of Rails and Ruby, with Capybara, Spork and DatabaseCleaner
1
+ Feature: Install Cucumber Rails
2
+
3
+ Cucumber-Rails should work on supported versions
4
+ of Ruby on Rails, with Capybara and DatabaseCleaner
5
5
 
6
6
  Scenario: Install Cucumber-Rails
7
7
  Given I have created a new Rails app and installed cucumber-rails
@@ -1,4 +1,5 @@
1
1
  Feature: No Database
2
+
2
3
  Allow Cucumber to work with a Rails app without a database
3
4
 
4
5
  Scenario: No ActiveRecord and DatabaseCleaner
@@ -2,11 +2,17 @@ Feature: Raise Errors
2
2
 
3
3
  Scenario: Raise error for undefined route
4
4
  Given I have created a new Rails app with no database and installed cucumber-rails
5
- When I write to "features/tests.feature" with:
5
+ When I write to "features/home.feature" with:
6
6
  """
7
7
  Feature: Tests
8
8
  Scenario: Tests
9
- When I go to the products page
9
+ When I go to the home page
10
+ """
11
+ And I write to "features/home_steps.rb" with:
12
+ """
13
+ When('I go to the home page') do
14
+ visit('/')
15
+ end
10
16
  """
11
17
  And I run `bundle exec cucumber`
12
18
  Then it should fail with:
@@ -1,4 +1,5 @@
1
1
  Feature: Rerun profile
2
+
2
3
  In order to concentrate on failing features
3
4
  As a Rails developer working with Cucumber
4
5
  I want to rerun only failing features
@@ -28,13 +28,13 @@ Feature: REST API
28
28
  }
29
29
  \"\"\"
30
30
  """
31
- And I write to "features/step_definitions/rest_steps.rb" with:
31
+ And I write to "features/step_definitions/post_steps.rb" with:
32
32
  """
33
33
  When('the client requests GET /{word}') do |path|
34
34
  get(path)
35
35
  end
36
36
 
37
- Then(/^the response should be JSON:$/) do |json|
37
+ Then('the response should be JSON:') do |json|
38
38
  expect(JSON.parse(last_response.body)).to eq(JSON.parse(json))
39
39
  end
40
40
  """
@@ -3,20 +3,17 @@
3
3
  Given('I have created a new Rails app and installed cucumber-rails, accidentally outside of the test group in my Gemfile') do
4
4
  rails_new
5
5
  install_cucumber_rails :not_in_test_group
6
- create_web_steps
7
6
  end
8
7
 
9
8
  Given('I have created a new Rails app and installed cucumber-rails') do
10
9
  rails_new
11
10
  install_cucumber_rails
12
- create_web_steps
13
11
  end
14
12
 
15
13
  Given('I have created a new Rails app with no database and installed cucumber-rails') do
16
14
  rails_new args: '--skip-active-record'
17
15
  install_cucumber_rails :no_database_cleaner, :no_factory_bot
18
16
  overwrite_file('features/support/env.rb', "require 'cucumber/rails'\n")
19
- create_web_steps
20
17
  end
21
18
 
22
19
  Given('I have a {string} ActiveRecord model object') do |name|
@@ -24,6 +21,19 @@ Given('I have a {string} ActiveRecord model object') do |name|
24
21
  run_command_and_stop('bundle exec rake db:migrate RAILS_ENV=test')
25
22
  end
26
23
 
24
+ Given('I remove the {string} gem from the Gemfile') do |gem_name|
25
+ content = File.open(expand_path('Gemfile'), 'r').readlines
26
+ new_content = []
27
+
28
+ content.each do |line|
29
+ next if line =~ /gem ["|']#{gem_name}["|'].*/
30
+
31
+ new_content << line
32
+ end
33
+
34
+ overwrite_file('Gemfile', new_content.join("\r\n"))
35
+ end
36
+
27
37
  Given('I force selenium to run Firefox in headless mode') do
28
38
  selenium_config = %{
29
39
  Capybara.register_driver :selenium do |app|
@@ -57,16 +67,3 @@ Then(/^the feature run should pass with:$/) do |string|
57
67
  step 'the exit status should be 0'
58
68
  step 'the output should contain:', string
59
69
  end
60
-
61
- Given('I remove the {string} gem from the Gemfile') do |gem_name|
62
- content = File.open(expand_path('Gemfile'), 'r').readlines
63
- new_content = []
64
-
65
- content.each do |line|
66
- next if line =~ /gem ["|']#{gem_name}["|'].*/
67
-
68
- new_content << line
69
- end
70
-
71
- overwrite_file('Gemfile', new_content.join("\r\n"))
72
- end
@@ -46,10 +46,6 @@ module CucumberRailsHelper
46
46
  end
47
47
  end
48
48
 
49
- def fixture(path)
50
- File.expand_path(File.dirname(__FILE__) + "./../support/fixtures/#{path}")
51
- end
52
-
53
49
  private
54
50
 
55
51
  def rails6?
@@ -1,14 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
4
- require 'rubygems'
5
- require 'bundler/setup'
4
+
6
5
  require 'rspec/expectations'
7
6
  require 'aruba/cucumber'
8
-
9
- After do |scenario|
10
- if scenario.failed?
11
- puts last_command_stopped.stdout
12
- puts last_command_stopped.stderr
13
- end
14
- end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ After do |scenario|
4
+ if scenario.failed?
5
+ puts last_command_stopped.stdout
6
+ puts last_command_stopped.stderr
7
+ end
8
+ end
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "capybara", "< 3.16.0", platform: :mri_23
6
6
  gem "nokogiri", "< 1.9.1", platform: :mri_23
7
- gem "railties", "~> 5.1.0"
7
+ gem "railties", "~> 5.1.7"
8
8
  gem "sqlite3", "~> 1.3.13"
9
9
 
10
10
  gemspec path: "../"
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "capybara", "< 3.16.0", platform: :mri_23
6
6
  gem "nokogiri", "< 1.9.1", platform: :mri_23
7
- gem "railties", "~> 5.2.3"
7
+ gem "railties", "~> 5.2.0"
8
8
  gem "sqlite3", "~> 1.3.13"
9
9
 
10
10
  gemspec path: "../"
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "railties", "~> 6.0.0.rc2"
6
- gem "rails", "~> 6.0.0.rc2"
5
+ gem "railties", "~> 6.0.0"
6
+ gem "rails", "~> 6.0.0"
7
7
  gem "sqlite3", "~> 1.4"
8
8
 
9
9
  gemspec path: "../"
@@ -7,10 +7,21 @@ rescue LoadError
7
7
  # Test Unit not found
8
8
  end
9
9
 
10
+ module Cucumber
11
+ module Rails
12
+ class << self
13
+ def include_rack_test_helpers?
14
+ # Using ActiveModel Boolean casting here will give false positives more often than not!
15
+ !ENV['CR_REMOVE_RACK_TEST_HELPERS']&.casecmp('true')&.zero?
16
+ end
17
+ end
18
+ end
19
+ end
20
+
10
21
  module Cucumber
11
22
  module Rails
12
23
  class World < ActionDispatch::IntegrationTest
13
- include Rack::Test::Methods
24
+ include Rack::Test::Methods if Cucumber::Rails.include_rack_test_helpers?
14
25
  include ActiveSupport::Testing::SetupAndTeardown if ActiveSupport::Testing.const_defined?('SetupAndTeardown')
15
26
 
16
27
  def initialize
@@ -11,10 +11,10 @@ describe Cucumber::Rails::Database do
11
11
  it 'forwards events to the selected strategy' do
12
12
  described_class.javascript_strategy = :truncation
13
13
 
14
- expect(strategy).to receive(:before_non_js).ordered
14
+ expect(strategy).to receive(:before_non_js)
15
15
  described_class.before_non_js
16
16
 
17
- expect(strategy).to receive(:before_js).ordered
17
+ expect(strategy).to receive(:before_js)
18
18
  described_class.before_js
19
19
  end
20
20
 
@@ -23,7 +23,7 @@ describe Cucumber::Rails::Database do
23
23
  .to raise_error(Cucumber::Rails::Database::InvalidStrategy)
24
24
  end
25
25
 
26
- describe 'using a custom strategy' do
26
+ context 'using a custom strategy' do
27
27
  let(:strategy_type) { ValidStrategy }
28
28
 
29
29
  class ValidStrategy
@@ -38,23 +38,23 @@ describe Cucumber::Rails::Database do
38
38
 
39
39
  class InvalidStrategy; end
40
40
 
41
- it 'raises an error if the strategy doens\'t support the protocol' do
41
+ it 'raises an error if the strategy does not have a valid interface' do
42
42
  expect { described_class.javascript_strategy = InvalidStrategy }
43
43
  .to raise_error(ArgumentError)
44
44
  end
45
45
 
46
- it 'accepts a custom strategy with a valid interface' do
46
+ it 'accepts the strategy if it has a valid interface' do
47
47
  expect { described_class.javascript_strategy = ValidStrategy }
48
48
  .not_to raise_error
49
49
  end
50
50
 
51
- it 'forwards events to a custom strategy' do
51
+ it 'forwards events to the strategy' do
52
52
  described_class.javascript_strategy = ValidStrategy
53
53
 
54
- expect(strategy).to receive(:before_non_js).ordered
54
+ expect(strategy).to receive(:before_non_js)
55
55
  described_class.before_non_js
56
56
 
57
- expect(strategy).to receive(:before_js).ordered
57
+ expect(strategy).to receive(:before_js)
58
58
  described_class.before_js
59
59
  end
60
60
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
-
5
3
  # Generators are not automatically loaded by Rails
6
4
  require 'generators/cucumber/install_generator'
7
5
 
@@ -15,7 +13,7 @@ describe Cucumber::InstallGenerator do
15
13
  '# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.'
16
14
  end
17
15
 
18
- describe 'no arguments' do
16
+ context 'without arguments' do
19
17
  before { run_generator }
20
18
 
21
19
  describe 'config/cucumber.yml' do
@@ -7,7 +7,7 @@ ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
7
7
 
8
8
  module CucumberRails
9
9
  class Application < ::Rails::Application
10
- config.secret_key_base = 'ASecretString' if config.respond_to? :secret_key_base
10
+ config.secret_key_base = 'ASecretString'
11
11
  end
12
12
  end
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-07 00:00:00.000000000 Z
13
+ date: 2019-11-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: capybara
@@ -121,33 +121,33 @@ dependencies:
121
121
  - !ruby/object:Gem::Version
122
122
  version: 1.1.4
123
123
  - !ruby/object:Gem::Dependency
124
- name: appraisal
124
+ name: aruba
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '2.2'
129
+ version: 0.14.4
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '2.2'
136
+ version: 0.14.4
137
137
  - !ruby/object:Gem::Dependency
138
- name: aruba
138
+ name: appraisal
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: 0.14.4
143
+ version: '2.2'
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: 0.14.4
150
+ version: '2.2'
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: bundler
153
153
  requirement: !ruby/object:Gem::Requirement
@@ -332,6 +332,7 @@ files:
332
332
  - features/annotations.feature
333
333
  - features/capybara_javascript_drivers.feature
334
334
  - features/choose_javascript_database_strategy.feature
335
+ - features/configuration.feature
335
336
  - features/database_cleaner.feature
336
337
  - features/disable_automatic_database_cleaning.feature
337
338
  - features/emulate_javascript.feature
@@ -344,7 +345,7 @@ files:
344
345
  - features/support/aruba.rb
345
346
  - features/support/cucumber_rails_helper.rb
346
347
  - features/support/env.rb
347
- - features/support/legacy_web_steps_support.rb
348
+ - features/support/hooks.rb
348
349
  - gemfiles/rails_4_2.gemfile
349
350
  - gemfiles/rails_5_0.gemfile
350
351
  - gemfiles/rails_5_1.gemfile
@@ -397,28 +398,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
397
398
  - !ruby/object:Gem::Version
398
399
  version: '0'
399
400
  requirements: []
400
- rubygems_version: 3.0.3
401
+ rubyforge_project:
402
+ rubygems_version: 2.7.9
401
403
  signing_key:
402
404
  specification_version: 4
403
- summary: cucumber-rails-1.8.0
404
- test_files:
405
- - features/allow_rescue.feature
406
- - features/annotations.feature
407
- - features/capybara_javascript_drivers.feature
408
- - features/choose_javascript_database_strategy.feature
409
- - features/database_cleaner.feature
410
- - features/disable_automatic_database_cleaning.feature
411
- - features/emulate_javascript.feature
412
- - features/install_cucumber_rails.feature
413
- - features/no_database.feature
414
- - features/raising_errors.feature
415
- - features/rerun_profile.feature
416
- - features/rest_api.feature
417
- - features/step_definitions/cucumber_rails_steps.rb
418
- - features/support/aruba.rb
419
- - features/support/cucumber_rails_helper.rb
420
- - features/support/env.rb
421
- - features/support/legacy_web_steps_support.rb
422
- - spec/cucumber/rails/database_spec.rb
423
- - spec/generators/cucumber/install_generator_spec.rb
424
- - spec/spec_helper.rb
405
+ summary: cucumber-rails-2.0.0
406
+ test_files: []
@@ -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)