cucumber-rails 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/features/support/env.rb
CHANGED
@@ -1,40 +1,14 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
4
|
require 'rubygems'
|
3
5
|
require 'bundler/setup'
|
4
6
|
require 'rspec/expectations'
|
5
7
|
require 'aruba/cucumber'
|
6
8
|
|
7
|
-
if(ENV['ARUBA_REPORT_DIR'])
|
8
|
-
# Override reporting behaviour so we don't document all files, only the ones
|
9
|
-
# that have been created after @aruba_report_start (a Time object). This is
|
10
|
-
# given a value after the Rails app is generated (see cucumber_rails_steps.rb)
|
11
|
-
module Aruba
|
12
|
-
module Reporting
|
13
|
-
def children(dir)
|
14
|
-
children = Dir["#{dir}/*"].sort
|
15
|
-
|
16
|
-
# include
|
17
|
-
children = children.select do |child|
|
18
|
-
File.directory?(child) ||
|
19
|
-
(@aruba_report_start && File.stat(child).mtime > @aruba_report_start)
|
20
|
-
end
|
21
|
-
|
22
|
-
# exclude
|
23
|
-
children = children.reject do |child|
|
24
|
-
child =~ /Gemfile/ ||
|
25
|
-
child =~ /\.log$/
|
26
|
-
end
|
27
|
-
|
28
|
-
children
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
9
|
After do |scenario|
|
35
10
|
if scenario.failed?
|
36
11
|
puts last_command_stopped.stdout
|
37
12
|
puts last_command_stopped.stderr
|
38
13
|
end
|
39
|
-
|
40
|
-
|
14
|
+
end
|
data/gemfiles/rails_4_2.gemfile
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "
|
6
|
-
gem "
|
7
|
-
gem "
|
8
|
-
gem "
|
5
|
+
gem "capybara", "< 3.16.0", platform: :mri_23
|
6
|
+
gem "nokogiri", "< 1.9.1", platform: :mri_23
|
7
|
+
gem "railties", "~> 4.2.11"
|
8
|
+
gem "sqlite3", "~> 1.3.13"
|
9
9
|
|
10
10
|
gemspec path: "../"
|
data/gemfiles/rails_5_0.gemfile
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "
|
6
|
-
gem "
|
7
|
-
gem "
|
8
|
-
gem "
|
5
|
+
gem "capybara", "< 3.16.0", platform: :mri_23
|
6
|
+
gem "nokogiri", "< 1.9.1", platform: :mri_23
|
7
|
+
gem "railties", "~> 5.0.7"
|
8
|
+
gem "sqlite3", "~> 1.3.13"
|
9
9
|
|
10
10
|
gemspec path: "../"
|
data/gemfiles/rails_5_1.gemfile
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
+
gem "capybara", "< 3.16.0", platform: :mri_23
|
6
|
+
gem "nokogiri", "< 1.9.1", platform: :mri_23
|
5
7
|
gem "railties", "~> 5.1.0"
|
6
|
-
gem "
|
7
|
-
gem "capybara", "< 3.16.0", platform: [:mri_23, :mri_22]
|
8
|
-
gem "nokogiri", "< 1.9.1", platform: [:mri_23, :mri_22]
|
8
|
+
gem "sqlite3", "~> 1.3.13"
|
9
9
|
|
10
10
|
gemspec path: "../"
|
data/gemfiles/rails_5_2.gemfile
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "
|
6
|
-
gem "
|
7
|
-
gem "
|
8
|
-
gem "
|
5
|
+
gem "capybara", "< 3.16.0", platform: :mri_23
|
6
|
+
gem "nokogiri", "< 1.9.1", platform: :mri_23
|
7
|
+
gem "railties", "~> 5.2.3"
|
8
|
+
gem "sqlite3", "~> 1.3.13"
|
9
9
|
|
10
10
|
gemspec path: "../"
|
data/gemfiles/rails_6_0.gemfile
CHANGED
data/lib/cucumber/rails.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
called_from_env_rb = caller.detect { |f| f =~ /\/env\.rb:/ }
|
4
|
+
|
5
|
+
if called_from_env_rb
|
6
|
+
env_caller = File.dirname(called_from_env_rb)
|
7
|
+
|
3
8
|
require 'rails'
|
4
9
|
require 'cucumber/rails/application'
|
5
10
|
ENV['RAILS_ENV'] ||= 'test'
|
@@ -15,7 +20,9 @@ if env_caller
|
|
15
20
|
end
|
16
21
|
|
17
22
|
unless Rails.application.config.cache_classes
|
18
|
-
warn "WARNING: You have set Rails' config.cache_classes to false
|
23
|
+
warn "WARNING: You have set Rails' config.cache_classes to false
|
24
|
+
(most likely in config/environments/cucumber.rb). This setting is known to cause problems
|
25
|
+
with database transactions. Set config.cache_classes to true if you want to use transactions."
|
19
26
|
end
|
20
27
|
|
21
28
|
require 'cucumber/rails/world'
|
@@ -25,7 +32,8 @@ if env_caller
|
|
25
32
|
|
26
33
|
MultiTest.disable_autorun
|
27
34
|
else
|
28
|
-
warn "WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being deferred
|
29
|
-
To avoid this warning, move 'gem \'cucumber-rails\', require: false'
|
30
|
-
If already in the :test group, be sure you are
|
35
|
+
warn "WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being deferred
|
36
|
+
until env.rb is called. To avoid this warning, move 'gem \'cucumber-rails\', require: false'
|
37
|
+
under only group :test in your Gemfile. If already in the :test group, be sure you are
|
38
|
+
specifying 'require: false'."
|
31
39
|
end
|
@@ -1,13 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
ActionController::Base.class_eval do
|
2
4
|
cattr_accessor :allow_rescue
|
3
5
|
end
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
module ActionDispatch
|
8
|
+
class ShowExceptions
|
9
|
+
alias __cucumber_orig_call__ call
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
def call(env)
|
12
|
+
env['action_dispatch.show_exceptions'] = !!ActionController::Base.allow_rescue
|
13
|
+
env['action_dispatch.show_detailed_exceptions'] = !ActionController::Base.allow_rescue
|
14
|
+
__cucumber_orig_call__(env)
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
@@ -1,17 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/application'
|
2
4
|
|
3
5
|
# Make sure the ActionDispatch::ShowExceptions middleware is always enabled,
|
4
6
|
# regardless of what is in config/environments/test.rb
|
5
7
|
# Instead we are overriding ActionDispatch::ShowExceptions to be able to
|
6
8
|
# toggle whether or not exceptions are raised.
|
7
|
-
class Rails::Application
|
8
|
-
alias __cucumber_orig_initialize__ initialize!
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
module Rails
|
11
|
+
class Application
|
12
|
+
alias __cucumber_orig_initialize__ initialize!
|
13
|
+
|
14
|
+
def initialize!
|
15
|
+
ad = config.action_dispatch
|
16
|
+
|
17
|
+
def ad.show_exceptions
|
18
|
+
true
|
19
|
+
end
|
20
|
+
__cucumber_orig_initialize__
|
14
21
|
end
|
15
|
-
__cucumber_orig_initialize__
|
16
22
|
end
|
17
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Cucumber
|
2
4
|
module Rails
|
3
5
|
module Capybara
|
@@ -11,7 +13,9 @@ module Cucumber
|
|
11
13
|
|
12
14
|
def click_with_javascript_emulation(*)
|
13
15
|
if link_with_non_get_http_method?
|
14
|
-
::Capybara::RackTest::Form.new(
|
16
|
+
::Capybara::RackTest::Form.new(
|
17
|
+
driver, js_form(element_node.document, self[:href], emulated_method)
|
18
|
+
).submit(self)
|
15
19
|
else
|
16
20
|
click_without_javascript_emulation
|
17
21
|
end
|
@@ -44,7 +48,7 @@ module Cucumber
|
|
44
48
|
js_form['action'] = action
|
45
49
|
js_form['method'] = method
|
46
50
|
|
47
|
-
if emulated_method
|
51
|
+
if emulated_method && !emulated_method.casecmp(method).zero?
|
48
52
|
input = document.create_element('input')
|
49
53
|
input['type'] = 'hidden'
|
50
54
|
input['name'] = '_method'
|
@@ -54,7 +58,7 @@ module Cucumber
|
|
54
58
|
|
55
59
|
# rails will wipe the session if the CSRF token is not sent
|
56
60
|
# with non-GET requests
|
57
|
-
if csrf? && emulated_method.
|
61
|
+
if csrf? && !emulated_method.casecmp('get').zero?
|
58
62
|
input = document.create_element('input')
|
59
63
|
input['type'] = 'hidden'
|
60
64
|
input['name'] = csrf_param
|
@@ -66,7 +70,9 @@ module Cucumber
|
|
66
70
|
end
|
67
71
|
|
68
72
|
def link_with_non_get_http_method?
|
69
|
-
tag_name == 'a' &&
|
73
|
+
tag_name == 'a' &&
|
74
|
+
element_node['data-method'] &&
|
75
|
+
element_node['data-method'] =~ /(?:delete|put|post)/
|
70
76
|
end
|
71
77
|
|
72
78
|
def emulated_method
|
@@ -74,15 +80,19 @@ module Cucumber
|
|
74
80
|
end
|
75
81
|
|
76
82
|
def element_node
|
77
|
-
|
83
|
+
native
|
78
84
|
end
|
79
85
|
end
|
80
86
|
end
|
81
87
|
end
|
82
88
|
end
|
83
89
|
|
84
|
-
|
85
|
-
|
90
|
+
module Capybara
|
91
|
+
module RackTest
|
92
|
+
class Node
|
93
|
+
include ::Cucumber::Rails::Capybara::JavascriptEmulation
|
94
|
+
end
|
95
|
+
end
|
86
96
|
end
|
87
97
|
|
88
98
|
Before('not @no-js-emulation') do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Cucumber
|
2
4
|
module Rails
|
3
5
|
module Capybara
|
@@ -9,7 +11,7 @@ module Cucumber
|
|
9
11
|
base_dom_id = get_base_dom_id_from_label_tag(options[:from])
|
10
12
|
|
11
13
|
find(:xpath, ".//select[@id='#{base_dom_id}_1i']").select(date.year.to_s)
|
12
|
-
find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l
|
14
|
+
find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l(date, format: '%B'))
|
13
15
|
find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
|
14
16
|
end
|
15
17
|
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Cucumber
|
2
4
|
module Rails
|
3
5
|
module Database
|
4
|
-
CUSTOM_STRATEGY_INTERFACE = %w
|
6
|
+
CUSTOM_STRATEGY_INTERFACE = %w[before_js before_non_js].freeze
|
5
7
|
|
6
8
|
class InvalidStrategy < ArgumentError; end
|
7
9
|
|
@@ -13,12 +15,12 @@ module Cucumber
|
|
13
15
|
strategy_type =
|
14
16
|
case strategy
|
15
17
|
when Symbol
|
16
|
-
map[strategy] ||
|
18
|
+
map[strategy] || throw_invalid_strategy_error(strategy)
|
17
19
|
when Class
|
18
20
|
strategy
|
19
21
|
end
|
20
22
|
|
21
|
-
@strategy =
|
23
|
+
@strategy = strategy_type.new(*strategy_opts)
|
22
24
|
|
23
25
|
validate_interface!
|
24
26
|
end
|
@@ -35,7 +37,7 @@ module Cucumber
|
|
35
37
|
@strategy.after
|
36
38
|
end
|
37
39
|
|
38
|
-
|
40
|
+
private
|
39
41
|
|
40
42
|
def map
|
41
43
|
{
|
@@ -46,10 +48,25 @@ module Cucumber
|
|
46
48
|
}
|
47
49
|
end
|
48
50
|
|
51
|
+
def throw_invalid_strategy_error(strategy)
|
52
|
+
raise(InvalidStrategy, "The strategy '#{strategy}' is not understood. Please use one of #{mapped_keys}")
|
53
|
+
end
|
54
|
+
|
55
|
+
def mapped_keys
|
56
|
+
map.keys.join(',')
|
57
|
+
end
|
58
|
+
|
49
59
|
def validate_interface!
|
50
|
-
|
51
|
-
|
52
|
-
|
60
|
+
return if CUSTOM_STRATEGY_INTERFACE.all? { |m| @strategy.respond_to?(m) }
|
61
|
+
|
62
|
+
throw_invalid_strategy_interface_error
|
63
|
+
end
|
64
|
+
|
65
|
+
def throw_invalid_strategy_interface_error
|
66
|
+
raise(
|
67
|
+
ArgumentError,
|
68
|
+
"Strategy must respond to all of: #{CUSTOM_STRATEGY_INTERFACE.map { |method| "##{method}" } * ' '} !"
|
69
|
+
)
|
53
70
|
end
|
54
71
|
end
|
55
72
|
|
@@ -69,6 +86,7 @@ module Cucumber
|
|
69
86
|
|
70
87
|
def after
|
71
88
|
return unless @original_strategy
|
89
|
+
|
72
90
|
DatabaseCleaner.strategy = @original_strategy
|
73
91
|
@original_strategy = nil
|
74
92
|
end
|
data/lib/cucumber/rails/hooks.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if defined?(ActiveRecord::Base)
|
2
|
-
|
3
|
-
|
4
|
+
module ActiveRecord
|
5
|
+
class Base
|
6
|
+
class_attribute :shared_connection
|
4
7
|
|
5
|
-
|
6
|
-
|
8
|
+
def self.connection
|
9
|
+
shared_connection || retrieve_connection
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
9
13
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
begin
|
2
4
|
require 'database_cleaner'
|
3
5
|
|
@@ -8,6 +10,6 @@ begin
|
|
8
10
|
After('not @no-database-cleaner') do
|
9
11
|
DatabaseCleaner.clean if Cucumber::Rails::Database.autorun_database_cleaner
|
10
12
|
end
|
11
|
-
|
12
|
-
|
13
|
+
rescue LoadError
|
14
|
+
# database_cleaner gem not present
|
13
15
|
end
|
data/lib/cucumber/rails/rspec.rb
CHANGED
data/lib/cucumber/rails/world.rb
CHANGED
@@ -1,21 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
begin
|
2
4
|
# Try to load it so we can assign @_result below if needed.
|
3
5
|
require 'test/unit/testresult'
|
4
|
-
rescue LoadError
|
6
|
+
rescue LoadError
|
7
|
+
# Test Unit not found
|
5
8
|
end
|
6
9
|
|
7
|
-
module Cucumber
|
8
|
-
module Rails
|
9
|
-
class World < ActionDispatch::IntegrationTest
|
10
|
+
module Cucumber
|
11
|
+
module Rails
|
12
|
+
class World < ActionDispatch::IntegrationTest
|
10
13
|
include Rack::Test::Methods
|
11
14
|
include ActiveSupport::Testing::SetupAndTeardown if ActiveSupport::Testing.const_defined?('SetupAndTeardown')
|
12
15
|
|
13
|
-
def initialize
|
16
|
+
def initialize
|
14
17
|
@_result = Test::Unit::TestResult.new if defined?(Test::Unit::TestResult)
|
15
18
|
end
|
16
19
|
|
17
20
|
unless defined?(ActiveRecord::Base)
|
18
|
-
|
21
|
+
# Workaround for projects that don't use ActiveRecord
|
22
|
+
def self.fixture_table_names
|
23
|
+
[]
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|