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.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +52 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +42 -0
- data/.gitignore +3 -1
- data/.rspec +4 -1
- data/.rubocop.yml +68 -0
- data/.travis.yml +43 -33
- data/Appraisals +25 -92
- data/{History.md → CHANGELOG.md} +242 -40
- data/CONTRIBUTING.md +15 -24
- data/Gemfile +2 -4
- data/LICENSE +1 -1
- data/README.md +57 -27
- data/Rakefile +18 -14
- data/bin/install_geckodriver.sh +19 -0
- data/bin/install_webpacker.sh +9 -0
- data/config/cucumber.yml +2 -5
- data/cucumber-rails.gemspec +35 -28
- data/dev_tasks/cucumber.rake +2 -0
- data/dev_tasks/rspec.rake +2 -0
- data/dev_tasks/yard.rake +7 -14
- data/dev_tasks/yard/default/layout/html/setup.rb +6 -1
- data/features/allow_rescue.feature +16 -11
- data/features/annotations.feature +8 -11
- data/features/capybara_javascript_drivers.feature +38 -28
- data/features/choose_javascript_database_strategy.feature +37 -57
- data/features/configuration.feature +48 -0
- data/features/database_cleaner.feature +18 -18
- data/features/disable_automatic_database_cleaning.feature +12 -18
- data/features/emulate_javascript.feature +64 -47
- data/features/install_cucumber_rails.feature +4 -4
- data/features/no_database.feature +8 -19
- data/features/raising_errors.feature +9 -3
- data/features/rerun_profile.feature +17 -7
- data/features/rest_api.feature +12 -12
- data/features/step_definitions/cucumber_rails_steps.rb +44 -88
- data/features/support/aruba.rb +3 -1
- data/features/support/cucumber_rails_helper.rb +85 -0
- data/features/support/env.rb +4 -30
- data/features/support/hooks.rb +8 -0
- data/gemfiles/rails_4_2.gemfile +5 -13
- data/gemfiles/rails_5_0.gemfile +5 -12
- data/gemfiles/rails_5_1.gemfile +4 -9
- data/gemfiles/rails_5_2.gemfile +10 -0
- data/gemfiles/rails_6_0.gemfile +9 -0
- data/lib/cucumber/rails.rb +17 -15
- data/lib/cucumber/rails/action_dispatch.rb +21 -0
- data/lib/cucumber/rails/application.rb +16 -7
- data/lib/cucumber/rails/capybara.rb +2 -0
- data/lib/cucumber/rails/capybara/javascript_emulation.rb +45 -37
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +6 -4
- data/lib/cucumber/rails/database.rb +30 -8
- data/lib/cucumber/rails/hooks.rb +2 -0
- data/lib/cucumber/rails/hooks/active_record.rb +14 -12
- data/lib/cucumber/rails/hooks/allow_rescue.rb +2 -0
- data/lib/cucumber/rails/hooks/database_cleaner.rb +6 -4
- data/lib/cucumber/rails/hooks/mail.rb +4 -4
- data/lib/cucumber/rails/rspec.rb +3 -1
- data/lib/cucumber/rails/world.rb +24 -7
- data/lib/generators/cucumber/{install/USAGE → USAGE} +0 -0
- data/lib/generators/cucumber/{install/install_generator.rb → install_generator.rb} +23 -10
- data/lib/generators/cucumber/{install/templates → templates}/config/cucumber.yml.erb +4 -3
- data/lib/generators/cucumber/{install/templates → templates}/script/cucumber +1 -0
- data/lib/generators/cucumber/{install/templates → templates}/support/_rails_each_run.rb.erb +2 -2
- data/lib/generators/cucumber/{install/templates → templates}/support/_rails_prefork.rb.erb +0 -0
- data/lib/generators/cucumber/{install/templates → templates}/support/capybara.rb +2 -0
- data/lib/generators/cucumber/{install/templates → templates}/support/edit_warning.txt +0 -0
- data/lib/generators/cucumber/{install/templates → templates}/support/rails.rb.erb +0 -0
- data/lib/generators/cucumber/{install/templates → templates}/support/rails_spork.rb.erb +0 -0
- data/lib/generators/cucumber/{install/templates → templates}/tasks/cucumber.rake.erb +9 -9
- data/spec/cucumber/rails/database_spec.rb +46 -33
- data/spec/generators/cucumber/{install/install_generator_spec.rb → install_generator_spec.rb} +17 -9
- data/spec/spec_helper.rb +13 -4
- metadata +105 -139
- data/Gemfile.appraisal +0 -3
- data/features/support/bundler_pre_support.rb +0 -28
- data/features/support/fixtures/bundler-1.0.21.gem +0 -0
- data/features/support/fixtures/bundler-1.1.rc.gem +0 -0
- data/features/support/legacy_web_steps_support.rb +0 -289
- data/gemfiles/lowest_version_bounds.gemfile +0 -26
- data/gemfiles/rails_4_0.gemfile +0 -19
- data/gemfiles/rails_4_1.gemfile +0 -18
- data/lib/cucumber/rails/action_controller.rb +0 -12
@@ -1,44 +1,44 @@
|
|
1
|
-
Feature:
|
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:
|
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
|
"""
|
19
|
-
And I
|
19
|
+
And I run `rails generate model widget name:string`
|
20
20
|
And I write to "features/step_definitions/widget_steps.rb" with:
|
21
21
|
"""
|
22
|
-
Given
|
23
|
-
|
24
|
-
Widget.create! :
|
22
|
+
Given('I have {int} widgets') do |number|
|
23
|
+
number.times do |i|
|
24
|
+
Widget.create! name: "Widget #{Widget.count + i}"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
When
|
29
|
-
|
30
|
-
Widget.create! :
|
28
|
+
When('I create {int} more widgets') do |number|
|
29
|
+
number.times do |i|
|
30
|
+
Widget.create! name: "Widget #{Widget.count + i}"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
Then
|
35
|
-
Widget.count.
|
34
|
+
Then('I should have {int} widgets') do |number|
|
35
|
+
expect(Widget.count).to eq(number)
|
36
36
|
end
|
37
37
|
"""
|
38
38
|
And I run `bundle exec rake db:migrate`
|
39
39
|
And I run `bundle exec rake cucumber`
|
40
40
|
Then the feature run should pass with:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
"""
|
42
|
+
2 scenarios (2 passed)
|
43
|
+
6 steps (6 passed)
|
44
|
+
"""
|
@@ -12,7 +12,7 @@ Feature: Disable automatic database cleaning
|
|
12
12
|
|
13
13
|
Scenario: Disabling automatic cleaning
|
14
14
|
Given I have created a new Rails app and installed cucumber-rails
|
15
|
-
|
15
|
+
When I append to "features/env.rb" with:
|
16
16
|
"""
|
17
17
|
Cucumber::Rails::Database.autorun_database_cleaner = false
|
18
18
|
"""
|
@@ -27,29 +27,23 @@ Feature: Disable automatic database cleaning
|
|
27
27
|
When I create 5 widgets
|
28
28
|
Then I should have 8 widgets
|
29
29
|
"""
|
30
|
-
And I
|
30
|
+
And I run `rails generate model widget name:string`
|
31
31
|
And I write to "features/step_definitions/widget_steps.rb" with:
|
32
32
|
"""
|
33
|
-
|
34
|
-
|
35
|
-
Widget.create! :
|
33
|
+
When('I create {int} widgets') do |number|
|
34
|
+
number.times do |i|
|
35
|
+
Widget.create! name: "Widget #{Widget.count + i}"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
Widget.create! :name => "Widget #{Widget.count + i}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
Then /^I should have (\d+) widgets$/ do |n|
|
46
|
-
Widget.count.should == n.to_i
|
39
|
+
Then('I should have {int} widgets') do |number|
|
40
|
+
expect(Widget.count).to eq(number)
|
47
41
|
end
|
48
|
-
|
42
|
+
"""
|
49
43
|
And I run `bundle exec rake db:migrate`
|
50
44
|
And I run `bundle exec rake cucumber`
|
51
45
|
Then the feature run should pass with:
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
"""
|
47
|
+
2 scenarios (2 passed)
|
48
|
+
4 steps (4 passed)
|
49
|
+
"""
|
@@ -1,44 +1,53 @@
|
|
1
1
|
Feature: Emulate Javascript
|
2
2
|
|
3
|
-
|
3
|
+
Background:
|
4
4
|
Given I have created a new Rails app and installed cucumber-rails
|
5
|
-
And I
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
5
|
+
And I force selenium to run Firefox in headless mode
|
6
|
+
When I run `rails generate scaffold widget name:string`
|
7
|
+
And I write to "features/step_definitions/widget_steps.rb" with:
|
8
|
+
"""
|
9
|
+
Given('there is a widget named {string}') do |name|
|
10
|
+
FactoryBot.create(:widget, name: name)
|
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
19
|
end
|
20
20
|
"""
|
21
|
-
And I write to "features/support/factories.rb" with:
|
21
|
+
And I write to "features/support/factories/widget.rb" with:
|
22
22
|
"""
|
23
|
-
|
23
|
+
FactoryBot.define do
|
24
24
|
factory :widget do
|
25
|
-
name 'testwidget'
|
25
|
+
name { 'testwidget' }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
"""
|
29
|
-
|
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
|
+
"""
|
40
|
+
And I run `bundle exec rake db:migrate`
|
30
41
|
And I run `bundle exec rake cucumber`
|
31
42
|
Then the feature run should pass with:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
43
|
+
"""
|
44
|
+
1 scenario (1 passed)
|
45
|
+
3 steps (3 passed)
|
46
|
+
"""
|
36
47
|
|
37
48
|
Scenario: Pass on the CSRF token
|
38
|
-
|
39
|
-
And I
|
40
|
-
And I successfully run `sed -i -e 's/forgery_protection *= false/forgery_protection = true/' config/environments/test.rb`
|
41
|
-
And I successfully run `rails generate controller session establish`
|
49
|
+
When I run `sed -i -e 's/forgery_protection *= false/forgery_protection = true/' config/environments/test.rb`
|
50
|
+
And I run `rails generate controller session establish`
|
42
51
|
And I write to "app/controllers/session_controller.rb" with:
|
43
52
|
"""
|
44
53
|
class SessionController < ApplicationController
|
@@ -51,42 +60,50 @@ Feature: Emulate Javascript
|
|
51
60
|
"""
|
52
61
|
class ApplicationController < ActionController::Base
|
53
62
|
protect_from_forgery
|
54
|
-
|
55
|
-
|
63
|
+
|
64
|
+
before_action except: :establish do
|
65
|
+
render text: 'denied', status: :forbidden and return false unless session[:verified]
|
56
66
|
end
|
57
67
|
end
|
58
68
|
"""
|
59
|
-
And I write to "features/
|
69
|
+
And I write to "features/widgets.feature" with:
|
60
70
|
"""
|
61
71
|
Feature: Widget inventory
|
62
72
|
Scenario: Delete a widget
|
63
73
|
Given there is a widget named "wrench"
|
64
|
-
|
65
|
-
And I
|
74
|
+
And I am on the session establish page
|
75
|
+
And I am on the widgets page
|
66
76
|
Then I should see "wrench"
|
67
77
|
When I follow "Destroy"
|
68
78
|
Then I should not see "denied"
|
69
79
|
And I should be on the widgets page
|
70
80
|
And I should not see "wrench"
|
71
81
|
"""
|
72
|
-
And I
|
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
|
73
84
|
"""
|
74
|
-
|
75
|
-
|
85
|
+
|
86
|
+
Given('I am on the session establish page') do
|
87
|
+
visit session_establish_path
|
76
88
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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)
|
84
101
|
end
|
85
102
|
"""
|
86
|
-
|
103
|
+
And I run `bundle exec rake db:migrate`
|
87
104
|
And I run `bundle exec rake cucumber`
|
88
105
|
Then the feature run should pass with:
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
106
|
+
"""
|
107
|
+
1 scenario (1 passed)
|
108
|
+
8 steps (8 passed)
|
109
|
+
"""
|
@@ -1,7 +1,7 @@
|
|
1
|
-
Feature: Rails
|
2
|
-
|
3
|
-
Cucumber-Rails should work on
|
4
|
-
of
|
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,11 +1,11 @@
|
|
1
1
|
Feature: No Database
|
2
|
+
|
2
3
|
Allow Cucumber to work with a Rails app without a database
|
3
4
|
|
4
|
-
@fails-on-travis
|
5
5
|
Scenario: No ActiveRecord and DatabaseCleaner
|
6
6
|
Given I have created a new Rails app with no database and installed cucumber-rails
|
7
7
|
# Turn off ActiveRecord
|
8
|
-
|
8
|
+
When I write to "config/application.rb" with:
|
9
9
|
"""
|
10
10
|
require File.expand_path('../boot', __FILE__)
|
11
11
|
|
@@ -17,7 +17,7 @@ Feature: No Database
|
|
17
17
|
|
18
18
|
module TestApp
|
19
19
|
class Application < Rails::Application
|
20
|
-
config.encoding =
|
20
|
+
config.encoding = 'utf-8'
|
21
21
|
config.filter_parameters += [:password]
|
22
22
|
end
|
23
23
|
end
|
@@ -26,24 +26,13 @@ Feature: No Database
|
|
26
26
|
"""
|
27
27
|
require 'cucumber/rails'
|
28
28
|
"""
|
29
|
-
|
30
|
-
And I
|
31
|
-
"""
|
32
|
-
source 'http://rubygems.org'
|
33
|
-
gem 'rails'
|
34
|
-
gem "cucumber-rails", :group => :test, :path => "../../.."
|
35
|
-
gem "capybara", :group => :test
|
36
|
-
gem "rspec-rails", :group => :test
|
37
|
-
if RUBY_VERSION >= '2.0.0'
|
38
|
-
gem 'sass-rails'
|
39
|
-
gem 'uglifier'
|
40
|
-
end
|
41
|
-
"""
|
29
|
+
And I remove the 'database_cleaner' gem from the Gemfile
|
30
|
+
And I remove the 'sqlite' gem from the Gemfile
|
42
31
|
And I write to "app/controllers/posts_controller.rb" with:
|
43
32
|
"""
|
44
33
|
class PostsController < ApplicationController
|
45
34
|
def index
|
46
|
-
raise
|
35
|
+
raise 'There is an error in index'
|
47
36
|
end
|
48
37
|
end
|
49
38
|
"""
|
@@ -57,11 +46,11 @@ Feature: No Database
|
|
57
46
|
"""
|
58
47
|
Feature: posts
|
59
48
|
Scenario: See them
|
60
|
-
When I
|
49
|
+
When I view the posts
|
61
50
|
"""
|
62
51
|
And I write to "features/step_definitions/posts_steps.rb" with:
|
63
52
|
"""
|
64
|
-
When
|
53
|
+
When('I view the posts') do
|
65
54
|
visit '/posts'
|
66
55
|
end
|
67
56
|
"""
|
@@ -1,12 +1,18 @@
|
|
1
1
|
Feature: Raise Errors
|
2
2
|
|
3
3
|
Scenario: Raise error for undefined route
|
4
|
-
Given I have created a new Rails app
|
5
|
-
|
4
|
+
Given I have created a new Rails app with no database and installed cucumber-rails
|
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
|
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
|
@@ -8,6 +9,7 @@ Feature: Rerun profile
|
|
8
9
|
And a file named "rerun.txt" with:
|
9
10
|
"""
|
10
11
|
features/rerun_test.feature:2
|
12
|
+
features/rerun_test.feature:5
|
11
13
|
"""
|
12
14
|
And a file named "features/rerun_test.feature" with:
|
13
15
|
"""
|
@@ -15,23 +17,31 @@ Feature: Rerun profile
|
|
15
17
|
Scenario: failing before
|
16
18
|
Given fixed now
|
17
19
|
|
20
|
+
Scenario: still failing
|
21
|
+
Given broken
|
22
|
+
|
18
23
|
Scenario: always passing
|
19
24
|
Given passing
|
20
25
|
"""
|
21
26
|
And a file named "features/step_definitions/rerun_steps.rb" with:
|
22
27
|
"""
|
23
|
-
Given
|
24
|
-
puts
|
28
|
+
Given('fixed now') do
|
29
|
+
puts 'All fixed now'
|
30
|
+
end
|
31
|
+
|
32
|
+
Given('broken') do
|
33
|
+
raise "I'm broken"
|
25
34
|
end
|
26
35
|
|
27
|
-
Given
|
36
|
+
Given('passing') do
|
28
37
|
puts "I've always been passing"
|
29
38
|
end
|
30
39
|
"""
|
31
|
-
When I
|
32
|
-
Then
|
40
|
+
When I run `bundle exec cucumber -p rerun`
|
41
|
+
Then it should fail with:
|
33
42
|
"""
|
34
|
-
|
35
|
-
|
43
|
+
2 scenarios (1 failed, 1 passed)
|
44
|
+
2 steps (1 failed, 1 passed)
|
36
45
|
"""
|
37
46
|
And the file "rerun.txt" should not contain "features/rerun_test.feature:2"
|
47
|
+
And the file "rerun.txt" should contain "features/rerun_test.feature:5"
|
data/features/rest_api.feature
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
Feature: REST API
|
2
2
|
|
3
3
|
Scenario: Compare JSON
|
4
|
-
Given I have created a new Rails app
|
5
|
-
|
4
|
+
Given I have created a new Rails app and installed cucumber-rails
|
5
|
+
When I write to "app/controllers/posts_controller.rb" with:
|
6
6
|
"""
|
7
7
|
class PostsController < ApplicationController
|
8
8
|
def index
|
9
|
-
render :
|
9
|
+
render json: {'hello' => 'world'}.to_json
|
10
10
|
end
|
11
11
|
end
|
12
12
|
"""
|
13
13
|
And I write to "config/routes.rb" with:
|
14
14
|
"""
|
15
|
-
|
15
|
+
TestApp::Application.routes.draw do
|
16
16
|
resources :posts
|
17
17
|
end
|
18
18
|
"""
|
@@ -28,20 +28,20 @@ Feature: REST API
|
|
28
28
|
}
|
29
29
|
\"\"\"
|
30
30
|
"""
|
31
|
-
And I write to "features/step_definitions/
|
31
|
+
And I write to "features/step_definitions/post_steps.rb" with:
|
32
32
|
"""
|
33
|
-
When
|
33
|
+
When('the client requests GET /{word}') do |path|
|
34
34
|
get(path)
|
35
35
|
end
|
36
36
|
|
37
|
-
Then
|
38
|
-
JSON.parse(last_response.body).
|
37
|
+
Then('the response should be JSON:') do |json|
|
38
|
+
expect(JSON.parse(last_response.body)).to eq(JSON.parse(json))
|
39
39
|
end
|
40
40
|
"""
|
41
41
|
And I run `bundle exec rake db:migrate`
|
42
42
|
And I run `bundle exec rake cucumber`
|
43
43
|
Then the feature run should pass with:
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
"""
|
45
|
+
1 scenario (1 passed)
|
46
|
+
2 steps (2 passed)
|
47
|
+
"""
|