cucumber-rails 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +35 -0
- data/.rubocop_todo.yml +14 -398
- data/.travis.yml +23 -8
- data/Appraisals +26 -23
- data/CHANGELOG.md +70 -15
- data/CONTRIBUTING.md +4 -14
- data/Gemfile +2 -4
- data/README.md +4 -7
- data/Rakefile +17 -13
- data/bin/install_geckodriver.sh +1 -1
- data/cucumber-rails.gemspec +24 -24
- data/dev_tasks/cucumber.rake +2 -0
- data/dev_tasks/rspec.rake +2 -0
- data/dev_tasks/yard.rake +6 -5
- data/dev_tasks/yard/default/layout/html/setup.rb +6 -1
- data/features/allow_rescue.feature +11 -11
- data/features/annotations.feature +2 -2
- data/features/capybara_javascript_drivers.feature +11 -22
- data/features/choose_javascript_database_strategy.feature +36 -56
- data/features/database_cleaner.feature +12 -12
- data/features/disable_automatic_database_cleaning.feature +10 -16
- data/features/emulate_javascript.feature +16 -16
- data/features/no_database.feature +5 -6
- data/features/raising_errors.feature +2 -2
- data/features/rerun_profile.feature +4 -4
- data/features/rest_api.feature +10 -10
- data/features/step_definitions/cucumber_rails_steps.rb +20 -101
- data/features/support/aruba.rb +2 -0
- data/features/support/cucumber_rails_helper.rb +80 -0
- data/features/support/env.rb +4 -30
- data/features/support/legacy_web_steps_support.rb +1 -1
- data/gemfiles/rails_4_2.gemfile +4 -4
- data/gemfiles/rails_5_0.gemfile +4 -4
- data/gemfiles/rails_5_1.gemfile +3 -3
- data/gemfiles/rails_5_2.gemfile +4 -4
- data/gemfiles/rails_6_0.gemfile +3 -2
- data/lib/cucumber/rails.rb +14 -6
- data/lib/cucumber/rails/action_controller.rb +10 -6
- data/lib/cucumber/rails/application.rb +13 -7
- data/lib/cucumber/rails/capybara.rb +2 -0
- data/lib/cucumber/rails/capybara/javascript_emulation.rb +17 -7
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +3 -1
- data/lib/cucumber/rails/database.rb +25 -7
- data/lib/cucumber/rails/hooks.rb +2 -0
- data/lib/cucumber/rails/hooks/active_record.rb +8 -4
- data/lib/cucumber/rails/hooks/allow_rescue.rb +2 -0
- data/lib/cucumber/rails/hooks/database_cleaner.rb +4 -2
- data/lib/cucumber/rails/hooks/mail.rb +2 -0
- data/lib/cucumber/rails/rspec.rb +3 -1
- data/lib/cucumber/rails/world.rb +12 -6
- data/lib/generators/cucumber/{install/USAGE → USAGE} +0 -0
- data/lib/generators/cucumber/{install/install_generator.rb → install_generator.rb} +18 -9
- data/lib/generators/cucumber/{install/templates → templates}/config/cucumber.yml.erb +0 -0
- data/lib/generators/cucumber/{install/templates → templates}/script/cucumber +1 -0
- data/lib/generators/cucumber/{install/templates → templates}/support/_rails_each_run.rb.erb +0 -0
- 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 +0 -0
- data/spec/cucumber/rails/database_spec.rb +20 -16
- data/spec/generators/cucumber/{install/install_generator_spec.rb → install_generator_spec.rb} +16 -6
- data/spec/spec_helper.rb +4 -2
- metadata +99 -96
- 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/dev_tasks/cucumber.rake
CHANGED
data/dev_tasks/rspec.rake
CHANGED
data/dev_tasks/yard.rake
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yard'
|
2
4
|
require 'yard/rake/yardoc_task'
|
3
5
|
|
@@ -6,9 +8,8 @@ API_DIR = File.join(SITE_DIR, 'api', 'cucumber-rails', 'ruby', 'yardoc')
|
|
6
8
|
|
7
9
|
namespace :api do
|
8
10
|
file :dir do
|
9
|
-
unless File.directory?(SITE_DIR)
|
10
|
-
|
11
|
-
end
|
11
|
+
raise "You need to git clone git@github.com:cucumber/cucumber.github.com.git #{SITE_DIR}" unless File.directory?(SITE_DIR)
|
12
|
+
|
12
13
|
sh('git pull origin master')
|
13
14
|
mkdir_p API_DIR
|
14
15
|
end
|
@@ -18,7 +19,7 @@ namespace :api do
|
|
18
19
|
YARD::Rake::YardocTask.new(:yard) do |yard|
|
19
20
|
dir = API_DIR
|
20
21
|
mkdir_p dir
|
21
|
-
yard.options = [
|
22
|
+
yard.options = ['--out', dir]
|
22
23
|
end
|
23
24
|
task yard: :dir
|
24
25
|
|
@@ -31,5 +32,5 @@ namespace :api do
|
|
31
32
|
end
|
32
33
|
|
33
34
|
desc "Generate YARD docs for Cucumber-Rails' API"
|
34
|
-
task doc: [
|
35
|
+
task doc: %i[yard release]
|
35
36
|
end
|
@@ -1,4 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
def init
|
2
4
|
super
|
3
|
-
options[:serializer].serialize(
|
5
|
+
options[:serializer].serialize(
|
6
|
+
'/images/bubble_32x32.png',
|
7
|
+
IO.read(File.dirname(__FILE__) + '/bubble_32x32.png')
|
8
|
+
)
|
4
9
|
end
|
@@ -1,37 +1,37 @@
|
|
1
1
|
Feature: Allow Cucumber to rescue exceptions
|
2
2
|
|
3
3
|
Background: A controller that raises an exception
|
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
|
-
raise
|
9
|
+
raise 'There is an error in index'
|
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
|
"""
|
19
19
|
|
20
20
|
Scenario: Allow rescue
|
21
|
-
|
21
|
+
When I write to "features/posts.feature" with:
|
22
22
|
"""
|
23
23
|
Feature: posts
|
24
24
|
@allow-rescue
|
25
25
|
Scenario: See posts
|
26
|
-
|
27
|
-
|
26
|
+
When I look at the posts
|
27
|
+
Then I should see the public error page
|
28
28
|
"""
|
29
29
|
And I write to "features/step_definitions/posts_steps.rb" with:
|
30
30
|
"""
|
31
|
-
When
|
31
|
+
When('I look at the posts') do
|
32
32
|
visit '/posts'
|
33
33
|
end
|
34
|
-
Then
|
34
|
+
Then('I should see the public error page') do
|
35
35
|
expect(page).to have_content "We're sorry, but something went wrong."
|
36
36
|
end
|
37
37
|
"""
|
@@ -44,7 +44,7 @@ Feature: Allow Cucumber to rescue exceptions
|
|
44
44
|
"""
|
45
45
|
|
46
46
|
Scenario: Don't allow rescue
|
47
|
-
|
47
|
+
When I write to "features/posts.feature" with:
|
48
48
|
"""
|
49
49
|
Feature: posts
|
50
50
|
Scenario: See them
|
@@ -52,7 +52,7 @@ Feature: Allow Cucumber to rescue exceptions
|
|
52
52
|
"""
|
53
53
|
And I write to "features/step_definitions/posts_steps.rb" with:
|
54
54
|
"""
|
55
|
-
When
|
55
|
+
When('I look at the posts') do
|
56
56
|
visit '/posts'
|
57
57
|
end
|
58
58
|
"""
|
@@ -5,8 +5,8 @@ Feature: Annotations
|
|
5
5
|
I should be able to list annotations in my features
|
6
6
|
|
7
7
|
Background:
|
8
|
-
Given I have created a new Rails app
|
9
|
-
|
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:
|
10
10
|
"""
|
11
11
|
Feature: Tests
|
12
12
|
Scenario: Tests
|
@@ -4,37 +4,28 @@ Feature: Capybara Javascript Drivers
|
|
4
4
|
Background: A simple calendar app
|
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
8
|
And I write to "features/step_definitions/date_time_steps.rb" with:
|
9
9
|
"""
|
10
|
-
When
|
11
|
-
select_time(time, from: selector)
|
12
|
-
end
|
13
|
-
|
14
|
-
When /^(?:|I )select "([^"]+)" as the "([^"]+)" date$/ do |date, selector|
|
15
|
-
select_date(date, from: selector)
|
16
|
-
end
|
17
|
-
|
18
|
-
When /^(?:|I )select "([^"]+)" as the "([^"]+)" date and time$/ do |datetime, selector|
|
10
|
+
When('I select {string} as the {string} date and time') do |datetime, selector|
|
19
11
|
select_datetime(datetime, from: selector)
|
20
12
|
end
|
21
13
|
"""
|
22
14
|
|
23
15
|
Scenario: Use a particular driver
|
24
|
-
|
16
|
+
When I write to "features/create_appointment.feature" with:
|
25
17
|
"""
|
26
18
|
@javascript
|
27
19
|
Feature: Create appointments
|
28
|
-
Scenario: Constitution on May 17
|
20
|
+
Scenario: Visit the Constitution on May 17
|
29
21
|
Given I am on the new appointment page
|
30
22
|
And I fill in "Norway's constitution" for "Name"
|
31
23
|
And I select "2015-02-20 15:10:00 UTC" as the "When" date and time
|
32
24
|
And I press "Create Appointment"
|
33
25
|
Then I should see "Norway's constitution"
|
34
26
|
And I should see "2015-02-20 15:10:00 UTC"
|
35
|
-
|
36
27
|
"""
|
37
|
-
|
28
|
+
And I run `bundle exec rake db:migrate`
|
38
29
|
And I run `bundle exec rake cucumber`
|
39
30
|
Then the feature run should pass with:
|
40
31
|
"""
|
@@ -43,28 +34,26 @@ Feature: Capybara Javascript Drivers
|
|
43
34
|
"""
|
44
35
|
|
45
36
|
Scenario: Mixed DB access
|
46
|
-
|
37
|
+
When I write to "features/create_appointment.feature" with:
|
47
38
|
"""
|
48
39
|
@javascript
|
49
40
|
Feature: Create appointments
|
50
|
-
Scenario: Constitution on May 17
|
41
|
+
Scenario: Visit the Constitution on May 17
|
51
42
|
Given a random appointment
|
52
|
-
And I am viewing random appointment
|
43
|
+
And I am viewing a random appointment
|
53
44
|
Then I should see "Random appointment"
|
54
|
-
|
55
45
|
"""
|
56
46
|
And I write to "features/step_definitions/custom_steps.rb" with:
|
57
47
|
"""
|
58
|
-
Given
|
48
|
+
Given('a random appointment') do
|
59
49
|
@appointment = Appointment.create!(name: 'Random appointment', when: DateTime.now)
|
60
50
|
end
|
61
51
|
|
62
|
-
Given
|
52
|
+
Given('I am viewing a random appointment') do
|
63
53
|
visit appointment_path(@appointment)
|
64
54
|
end
|
65
55
|
"""
|
66
|
-
|
67
|
-
When I run `bundle exec rake db:migrate`
|
56
|
+
And I run `bundle exec rake db:migrate`
|
68
57
|
And I run `bundle exec rake cucumber`
|
69
58
|
Then the feature run should pass with:
|
70
59
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Feature: Choose javascript database strategy
|
2
2
|
|
3
|
-
|
3
|
+
Whilst running a scenario with the @javascript tag, Capybara will fire up a web server
|
4
4
|
in the same process in a separate thread to your cukes. By default, this means ActiveRecord will give it a
|
5
5
|
separate database connection, which in turn means data you put into your database from
|
6
6
|
Cucumber step definitions (e.g. using FactoryBot) won't be visible to the web server
|
@@ -26,9 +26,23 @@ Feature: Choose javascript database strategy
|
|
26
26
|
Background:
|
27
27
|
Given I have created a new Rails app and installed cucumber-rails
|
28
28
|
And I have a "Widget" ActiveRecord model object
|
29
|
+
When I write to "features/step_definitions/widget_steps.rb" with:
|
30
|
+
"""
|
31
|
+
When('I create {int} widgets') do |number|
|
32
|
+
number.times { Widget.create! }
|
33
|
+
end
|
34
|
+
|
35
|
+
Then('I should have {int} widgets') do |number|
|
36
|
+
expect(Widget.count).to eq(number)
|
37
|
+
end
|
38
|
+
|
39
|
+
Then('the DatabaseCleaner strategy should be {word}') do |strategy_name|
|
40
|
+
expect(DatabaseCleaner.connections.first.strategy.to_s).to match(/#{strategy_name}/i)
|
41
|
+
end
|
42
|
+
"""
|
29
43
|
|
30
44
|
Scenario: Set the strategy to truncation and run a javascript scenario.
|
31
|
-
|
45
|
+
When I append to "features/env.rb" with:
|
32
46
|
"""
|
33
47
|
DatabaseCleaner.strategy = :transaction
|
34
48
|
Cucumber::Rails::Database.javascript_strategy = :truncation
|
@@ -37,13 +51,13 @@ Feature: Choose javascript database strategy
|
|
37
51
|
"""
|
38
52
|
Feature:
|
39
53
|
Background:
|
40
|
-
|
54
|
+
When I create 2 widgets
|
41
55
|
|
42
56
|
@javascript
|
43
57
|
Scenario:
|
44
|
-
Then the DatabaseCleaner strategy should be truncation
|
45
58
|
When I create 3 widgets
|
46
|
-
Then
|
59
|
+
Then the DatabaseCleaner strategy should be truncation
|
60
|
+
And I should have 5 widgets
|
47
61
|
|
48
62
|
@javascript
|
49
63
|
Scenario:
|
@@ -54,29 +68,15 @@ Feature: Choose javascript database strategy
|
|
54
68
|
Then the DatabaseCleaner strategy should be transaction
|
55
69
|
And I should have 2 widgets
|
56
70
|
"""
|
57
|
-
And I
|
71
|
+
And I run the cukes
|
72
|
+
Then the feature run should pass with:
|
58
73
|
"""
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
Then /should have (\d) widgets/ do |num|
|
64
|
-
Widget.count.should == num.to_i
|
65
|
-
end
|
66
|
-
|
67
|
-
Then /^the DatabaseCleaner strategy should be (\w+)$/ do |strategy_name|
|
68
|
-
DatabaseCleaner.connections.first.strategy.to_s.should =~ /#{strategy_name}/i
|
69
|
-
end
|
74
|
+
3 scenarios (3 passed)
|
75
|
+
10 steps (10 passed)
|
70
76
|
"""
|
71
|
-
When I run the cukes
|
72
|
-
Then the feature run should pass with:
|
73
|
-
"""
|
74
|
-
3 scenarios (3 passed)
|
75
|
-
10 steps (10 passed)
|
76
|
-
"""
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
Scenario: Set the strategy to deletion and run a javascript scenario.
|
79
|
+
When I append to "features/env.rb" with:
|
80
80
|
"""
|
81
81
|
Cucumber::Rails::Database.javascript_strategy = :deletion
|
82
82
|
"""
|
@@ -85,7 +85,7 @@ Feature: Choose javascript database strategy
|
|
85
85
|
@javascript
|
86
86
|
Feature:
|
87
87
|
Background:
|
88
|
-
|
88
|
+
When I create 2 widgets
|
89
89
|
|
90
90
|
Scenario:
|
91
91
|
When I create 3 widgets
|
@@ -94,27 +94,17 @@ Feature: Choose javascript database strategy
|
|
94
94
|
Scenario:
|
95
95
|
Then I should have 2 widgets
|
96
96
|
"""
|
97
|
-
And I
|
97
|
+
And I run the cukes
|
98
|
+
Then the feature run should pass with:
|
98
99
|
"""
|
99
|
-
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
Then /should have (\d) widgets/ do |num|
|
104
|
-
Widget.count.should == num.to_i
|
105
|
-
end
|
100
|
+
2 scenarios (2 passed)
|
101
|
+
5 steps (5 passed)
|
106
102
|
"""
|
107
|
-
When I run the cukes
|
108
|
-
Then the feature run should pass with:
|
109
|
-
"""
|
110
|
-
2 scenarios (2 passed)
|
111
|
-
5 steps (5 passed)
|
112
|
-
"""
|
113
103
|
|
114
104
|
Scenario: Set the strategy to truncation with an except option and run a javascript scenario.
|
115
|
-
|
105
|
+
When I append to "features/env.rb" with:
|
116
106
|
"""
|
117
|
-
|
107
|
+
Cucumber::Rails::Database.javascript_strategy = :truncation, { except: %w[widgets] }
|
118
108
|
"""
|
119
109
|
And I write to "features/widgets.feature" with:
|
120
110
|
"""
|
@@ -127,19 +117,9 @@ Feature: Choose javascript database strategy
|
|
127
117
|
Scenario:
|
128
118
|
Then I should have 3 widgets
|
129
119
|
"""
|
130
|
-
And I
|
120
|
+
And I run the cukes
|
121
|
+
Then the feature run should pass with:
|
131
122
|
"""
|
132
|
-
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
Then /should have (\d) widgets/ do |num|
|
137
|
-
Widget.count.should == num.to_i
|
138
|
-
end
|
123
|
+
2 scenarios (2 passed)
|
124
|
+
3 steps (3 passed)
|
139
125
|
"""
|
140
|
-
When I run the cukes
|
141
|
-
Then the feature run should pass with:
|
142
|
-
"""
|
143
|
-
2 scenarios (2 passed)
|
144
|
-
3 steps (3 passed)
|
145
|
-
"""
|
@@ -2,10 +2,10 @@ Feature: DatabaseCleaner
|
|
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
|
8
|
+
Background: some widgets
|
9
9
|
Given I have 2 widgets
|
10
10
|
|
11
11
|
Scenario: Add 3
|
@@ -19,26 +19,26 @@ Feature: DatabaseCleaner
|
|
19
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
|
-
|
22
|
+
Given('I have {int} widgets') do |number|
|
23
|
+
number.times do |i|
|
24
24
|
Widget.create! name: "Widget #{Widget.count + i}"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
When
|
29
|
-
|
28
|
+
When('I create {int} more widgets') do |number|
|
29
|
+
number.times do |i|
|
30
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
|
"""
|
@@ -30,26 +30,20 @@ Feature: Disable automatic database cleaning
|
|
30
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
|
-
|
33
|
+
When('I create {int} widgets') do |number|
|
34
|
+
number.times do |i|
|
35
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
|
+
"""
|