cucumber-rails 2.0.0 → 2.1.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: aea01cd8d17a13c8f43f785981239c8aeb28202591bce35bedeee997ac2c25ea
4
- data.tar.gz: f021c09f4793b9e179f80214d6572498645fd65a007a5e17121a91a73effc3a4
3
+ metadata.gz: eba00efc3e821aa337c9e16993ba558c1a5f1c795c5db9fb00104f5de38839cd
4
+ data.tar.gz: af9a02416bdeda7f9d3c1c3600df92ff2248788909c1f18ff333223c025e64cc
5
5
  SHA512:
6
- metadata.gz: b90e398bf55e9bb8d3f5eb267bd981ba16929f16c2be420829da9498ba4c077f9ba37652a6744ac57a1a96653b2bccf1d0bc57b40aa1700a89725dfd9a95179c
7
- data.tar.gz: 80ee71f600ddff221964012001529345b769503f12b9124257ddca788e8a27e132c62a71a712b80f1d4bd7b314ddfad7c32a741a314fac386d9fad7bb0c0c3f8
6
+ metadata.gz: c711b5a237e9d4e9e53936e2d9836d74f58604a864769c91758a00a742649945e2a798ea4881b26466a21307bed029dac6f36f5dc54650e406133fd27d35c82e
7
+ data.tar.gz: 499ba57f75835fc6ca390e7c313e7dd442a1b92cddb30b516841892bd15223ecd41b595e885e7bb3dbe890847f7a1e03b0c9195656b0a6e7915d19af67d5d59d
@@ -1,33 +1,68 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
1
  require:
4
2
  - rubocop-rspec
5
3
  - rubocop-performance
6
4
 
7
5
  AllCops:
8
- TargetRubyVersion: 2.3
6
+ TargetRubyVersion: 2.4
9
7
  Exclude:
10
- # These are auto-generated from a load of features that we
11
- # don't have direct control over
8
+ # These are auto-generated from a load of features that use aruba
12
9
  - 'tmp/**/*'
13
10
  # Generated by appraisal
14
11
  - 'gemfiles/*.gemfile'
15
12
 
16
- Style/Documentation:
17
- Enabled: false
13
+ # These two areas will frequently break this limit, so we ignore the limit
14
+ Metrics/BlockLength:
15
+ Exclude:
16
+ - './spec/**/*_spec.rb'
17
+ - 'cucumber-rails.gemspec'
18
+
19
+ # This allows us to read the chmod action in a more reproducible way
20
+ Style/NumericLiteralPrefix:
21
+ EnforcedOctalStyle: zero_only
22
+
23
+ # Enable new cops
24
+ Layout/EmptyLinesAroundAttributeAccessor:
25
+ Enabled: true
26
+ Layout/SpaceAroundMethodCallOperator:
27
+ Enabled: true
28
+ Lint/DeprecatedOpenSSLConstant:
29
+ Enabled: true
30
+ Lint/MixedRegexpCaptureTypes:
31
+ Enabled: true
32
+ Lint/RaiseException:
33
+ Enabled: true
34
+ Lint/StructNewOverride:
35
+ Enabled: true
36
+ Style/ExponentialNotation:
37
+ Enabled: true
38
+ Style/HashEachMethods:
39
+ Enabled: true
40
+ Style/HashTransformKeys:
41
+ Enabled: true
42
+ Style/HashTransformValues:
43
+ Enabled: true
44
+ Style/RedundantRegexpCharacterClass:
45
+ Enabled: true
46
+ Style/RedundantRegexpEscape:
47
+ Enabled: true
48
+ Style/SlicingWithRange:
49
+ Enabled: true
18
50
 
19
- Metrics/LineLength:
51
+ ## Cucumber Repo styles (Across implementations) ##
52
+
53
+ Layout/LineLength:
20
54
  Max: 200
21
55
  IgnoredPatterns:
22
56
  - '^Given'
23
57
  - '^When'
24
58
  - '^Then'
25
59
 
60
+ Style/Documentation:
61
+ Enabled: false
62
+
26
63
  Style/RegexpLiteral:
27
64
  EnforcedStyle: slashes
28
65
  AllowInnerSlashes: true
29
66
 
30
- BlockLength:
31
- Exclude:
32
- - './spec/**/*_spec.rb'
33
- - 'cucumber-rails.gemspec'
67
+ RSpec/MessageSpies:
68
+ EnforcedStyle: receive
@@ -1,12 +1,12 @@
1
1
  language: ruby
2
2
 
3
- dist: xenial
3
+ dist: bionic
4
4
 
5
5
  rvm:
6
- - 2.3
7
6
  - 2.4
8
7
  - 2.5
9
8
  - 2.6
9
+ - 2.7
10
10
  - ruby-head
11
11
 
12
12
  addons:
@@ -33,10 +33,6 @@ matrix:
33
33
  exclude:
34
34
  # Only test Rails6 on supported rubies
35
35
  # Don't test lowest rails support on maintained rubies
36
- - rvm: 2.3
37
- gemfile: gemfiles/rails_6_0.gemfile
38
- - rvm: 2.4
39
- gemfile: gemfiles/rails_4_2.gemfile
40
36
  - rvm: 2.4
41
37
  gemfile: gemfiles/rails_6_0.gemfile
42
38
  - rvm: 2.5
@@ -47,6 +43,12 @@ matrix:
47
43
  gemfile: gemfiles/rails_5_0.gemfile
48
44
  - rvm: 2.6
49
45
  gemfile: gemfiles/rails_5_1.gemfile
46
+ - rvm: 2.7
47
+ gemfile: gemfiles/rails_4_2.gemfile
48
+ - rvm: 2.7
49
+ gemfile: gemfiles/rails_5_0.gemfile
50
+ - rvm: 2.7
51
+ gemfile: gemfiles/rails_5_1.gemfile
50
52
  - rvm: ruby-head
51
53
  gemfile: gemfiles/rails_4_2.gemfile
52
54
  - rvm: ruby-head
@@ -1,6 +1,7 @@
1
- Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) on how to contribute to Cucumber.
1
+ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md)
2
+ on how to contribute to Cucumber.
2
3
 
3
- ## [master](https://github.com/cucumber/cucumber-rails/compare/v2.0.0...master) (Not yet released)
4
+ ## [master](https://github.com/cucumber/cucumber-rails/compare/v2.1.0...master) (Not yet released)
4
5
 
5
6
  ### New Features
6
7
 
@@ -8,13 +9,60 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
8
9
 
9
10
  ### Changed
10
11
 
11
- *
12
+ *
12
13
 
13
14
  ### Fixed
14
15
 
15
- *
16
+ *
17
+
18
+ ## [v2.1.0](https://github.com/cucumber/cucumber-rails/compare/v2.0.0...v2.1.0) (2020-06-15)
19
+
20
+ ### New Features
21
+
22
+ * Added metadata to allow gem to be searched / indexed by rubygems
23
+ ([#447](https://github.com/cucumber/cucumber-rails/pull/447) [orien])
24
+
25
+ * Allow Cucumber 4 to be used as an option for cucumber-rails
26
+ * NB: Cucumber4 changes quite a lot of logic with auto-loaders. This means that any previous
27
+ logic that relied implicitly on load-order "may" be affected
28
+ ([#453](https://github.com/cucumber/cucumber-rails/pull/453) [luke-hill] / [deivid-rodriguez])
29
+
30
+ ### Changed
31
+
32
+ * Dropped Ruby 2.3 support (target 2.4 - 2.7) ([#466](https://github.com/cucumber/cucumber-rails/pull/466) [mvz])
33
+
34
+ * Refactored suite to remove a lot of old Rails3/4.0 "ism's"
35
+ * Also migrated a lot of old cucumber styles to cucumber4
36
+ ([#441](https://github.com/cucumber/cucumber-rails/pull/441) [luke-hill])
37
+
38
+ * Refactored alias logic for overriding Rails methods to use `Module#prepend`
39
+ ([#457](https://github.com/cucumber/cucumber-rails/pull/457) [wagenet])
40
+
41
+ * `database_cleaner` (when used), at a version `>= 1.8` will now silence all warnings
42
+ * The suite internally will only test a version `>= 1.8`, so other versions will work but are un-maintained
43
+ ([#463](https://github.com/cucumber/cucumber-rails/pull/463) [deivid-rodriguez])
44
+
45
+ ### Fixed
46
+
47
+ * Various rubocop / rspec styling fixes
48
+ ([#445](https://github.com/cucumber/cucumber-rails/pull/445) /
49
+ [#449](https://github.com/cucumber/cucumber-rails/pull/449) /
50
+ [#450](https://github.com/cucumber/cucumber-rails/pull/450) /
51
+ [#451](https://github.com/cucumber/cucumber-rails/pull/451) /
52
+ [#452](https://github.com/cucumber/cucumber-rails/pull/452) /
53
+ [#465](https://github.com/cucumber/cucumber-rails/pull/465)
54
+ [mvz] / [luke-hill])
55
+
56
+ * Various CI fixes
57
+ ([#444](https://github.com/cucumber/cucumber-rails/pull/444) /
58
+ [#460](https://github.com/cucumber/cucumber-rails/pull/460) /
59
+ [#464](https://github.com/cucumber/cucumber-rails/pull/464)
60
+ [mvz] / [damonjmurray] / [deivid-rodriguez])
61
+
62
+ * Avoid printing a warning about `config.cache_classes` being set to `false` when
63
+ Spring is used ([#462](https://github.com/cucumber/cucumber-rails/pull/462) [janko])
16
64
 
17
- ## [v2.0.0](https://github.com/cucumber/cucumber-rails/compare/v1.8.0...v2.0.0) (Not yet released)
65
+ ## [v2.0.0](https://github.com/cucumber/cucumber-rails/compare/v1.8.0...v2.0.0) (2019-09-13)
18
66
 
19
67
  ### New Features
20
68
 
@@ -34,7 +82,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
34
82
 
35
83
  ### Changed
36
84
 
37
- * Drop Ruby 2.2 support (target 2.3 and up) ([#424](https://github.com/cucumber/cucumber-rails/pull/424) [mvz])
85
+ * Dropped Ruby 2.2 support (target 2.3 and up) ([#424](https://github.com/cucumber/cucumber-rails/pull/424) [mvz])
38
86
 
39
87
  * Begin to update the core runtime / development dependencies to something a little more recent
40
88
  ([#413](https://github.com/cucumber/cucumber-rails/pull/413) /
@@ -567,3 +615,7 @@ and to celebrate that cucumber-rails now supports Capybara as an alternative to
567
615
  [luke-hill]: https://github.com/luke-hill
568
616
  [amatsuda]: https://github.com/amatsuda
569
617
  [xtrasimplicity]: https://github.com/xtrasimplicity
618
+ [janko]: https://github.com/janko
619
+ [damonjmurray]: https://github.com/damonjmurray
620
+ [orien]: https://github.com/orien
621
+ [wagenet]: https://github.com/wagenet
data/Rakefile CHANGED
@@ -29,7 +29,7 @@ namespace :test do
29
29
  desc 'Run tests against specified gemfile, e.g. rake test:gemfile[rails_3_0]'
30
30
  task :gemfile, :name do |_task, args|
31
31
  unless args.name && Pathname.new("gemfiles/#{args.name}.gemfile").exist?
32
- raise ArgumentError "You must provide the name of an existing Appraisal gemfile,
32
+ raise ArgumentError, "You must provide the name of an existing Appraisal gemfile,
33
33
  e.g. 'rake test:gemfile[rails_4_2]'"
34
34
  end
35
35
 
@@ -4,39 +4,46 @@ $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 = '2.0.0'
7
+ s.version = '2.1.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}"
11
11
  s.email = 'cukes@googlegroups.com'
12
- s.homepage = 'http://cukes.info'
12
+ s.homepage = 'https://cucumber.io'
13
13
 
14
14
  s.license = 'MIT'
15
15
 
16
+ s.metadata = {
17
+ 'bug_tracker_uri' => 'https://github.com/cucumber/cucumber-rails/issues',
18
+ 'changelog_uri' => "https://github.com/cucumber/cucumber-rails/blob/v#{s.version}/CHANGELOG.md",
19
+ 'documentation_uri' => 'https://cucumber.io/docs',
20
+ 'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/cukes',
21
+ 'source_code_uri' => "https://github.com/cucumber/cucumber-rails/tree/v#{s.version}"
22
+ }
23
+
16
24
  s.add_runtime_dependency('capybara', ['>= 2.12', '< 4'])
17
- s.add_runtime_dependency('cucumber', ['>= 3.0.2', '< 4'])
25
+ s.add_runtime_dependency('cucumber', ['>= 3.0.2', '< 5'])
18
26
  s.add_runtime_dependency('mime-types', ['>= 2.0', '< 4'])
19
27
  s.add_runtime_dependency('nokogiri', '~> 1.8')
20
- s.add_runtime_dependency('railties', ['>= 4.2', '< 7'])
28
+ s.add_runtime_dependency('rails', ['>= 4.2', '< 7'])
21
29
 
22
30
  # Main development dependencies
23
31
  s.add_development_dependency('ammeter', '>= 1.1.4')
24
- s.add_development_dependency('aruba', '~> 0.14.4')
25
32
  s.add_development_dependency('appraisal', '~> 2.2')
33
+ s.add_development_dependency('aruba', '~> 1.0')
26
34
  s.add_development_dependency('bundler', '>= 1.17')
27
- s.add_development_dependency('rails', ['>= 4.2', '< 7'])
28
35
  s.add_development_dependency('rake', '>= 12.0')
29
36
  s.add_development_dependency('rspec', '~> 3.6')
30
- s.add_development_dependency('rubocop', '~> 0.72.0')
31
- s.add_development_dependency('rubocop-performance', '~> 1.4.0')
32
- s.add_development_dependency('rubocop-rspec', '~> 1.33.0')
37
+ s.add_development_dependency('rubocop', '~> 0.85.0')
38
+ s.add_development_dependency('rubocop-performance', '~> 1.6.1')
39
+ s.add_development_dependency('rubocop-rspec', '~> 1.39.0')
33
40
  s.add_development_dependency('sqlite3', '~> 1.3')
34
41
 
35
42
  # For Documentation:
36
43
  s.add_development_dependency('rdoc', '>= 6.0')
37
44
  s.add_development_dependency('yard', '~> 0.9.10')
38
45
 
39
- s.required_ruby_version = '>= 2.3.0'
46
+ s.required_ruby_version = '>= 2.4.0'
40
47
  s.rubygems_version = '>= 1.6.1'
41
48
  s.files = `git ls-files`.split("\n")
42
49
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
@@ -23,14 +23,6 @@ namespace :api do
23
23
  end
24
24
  task yard: :dir
25
25
 
26
- task :release do
27
- Dir.chdir(SITE_DIR) do
28
- sh('git add .')
29
- sh("git commit -m 'Update API docs for cucumber-rails v#{cucumber-rails::VERSION}'")
30
- sh('git push origin master')
31
- end
32
- end
33
-
34
26
  desc "Generate YARD docs for Cucumber-Rails' API"
35
- task doc: %i[yard release]
27
+ task doc: :yard
36
28
  end
@@ -20,7 +20,7 @@ Feature: Allow Cucumber to rescue exceptions
20
20
  Scenario: Allow rescue
21
21
  When I write to "features/posts.feature" with:
22
22
  """
23
- Feature: posts
23
+ Feature: Posts
24
24
  @allow-rescue
25
25
  Scenario: See posts
26
26
  When I look at the posts
@@ -31,6 +31,7 @@ Feature: Allow Cucumber to rescue exceptions
31
31
  When('I look at the posts') do
32
32
  visit '/posts'
33
33
  end
34
+
34
35
  Then('I should see the public error page') do
35
36
  expect(page).to have_content "We're sorry, but something went wrong."
36
37
  end
@@ -46,7 +47,7 @@ Feature: Allow Cucumber to rescue exceptions
46
47
  Scenario: Don't allow rescue
47
48
  When I write to "features/posts.feature" with:
48
49
  """
49
- Feature: posts
50
+ Feature: Posts
50
51
  Scenario: See them
51
52
  When I look at the posts
52
53
  """
@@ -37,7 +37,7 @@ Feature: Choose javascript database strategy
37
37
  end
38
38
 
39
39
  Then('the DatabaseCleaner strategy should be {word}') do |strategy_name|
40
- expect(DatabaseCleaner.connections.first.strategy.to_s).to match(/#{strategy_name}/i)
40
+ expect(DatabaseCleaner.cleaners.values.first.strategy.to_s).to match(/#{strategy_name}/i)
41
41
  end
42
42
  """
43
43
 
@@ -26,7 +26,7 @@ Given('I remove the {string} gem from the Gemfile') do |gem_name|
26
26
  new_content = []
27
27
 
28
28
  content.each do |line|
29
- next if line =~ /gem ["|']#{gem_name}["|'].*/
29
+ next if /gem ["|']#{gem_name}["|'].*/.match?(line)
30
30
 
31
31
  new_content << line
32
32
  end
@@ -61,7 +61,7 @@ When('I run the cukes') do
61
61
  end
62
62
 
63
63
  # Copied from Aruba
64
- Then(/^the feature run should pass with:$/) do |string|
64
+ Then('the feature run should pass with:') do |string|
65
65
  step 'the output should not contain " failed)"'
66
66
  step 'the output should not contain " undefined)"'
67
67
  step 'the exit status should be 0'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Aruba.configure do |config|
4
- config.exit_timeout = 120
4
+ config.exit_timeout = 360
5
5
  end
@@ -2,45 +2,32 @@
2
2
 
3
3
  module CucumberRailsHelper
4
4
  def rails_new(options = {})
5
- options[:name] ||= 'test_app'
6
- command_result =
7
- run_command "bundle exec rails new #{options[:name]} --skip-bundle --skip-test-unit --skip-spring --skip-bootsnap #{options[:args]}"
8
- expect(command_result).to have_output(/README/)
9
- expect(last_command_started).to be_successfully_executed
10
- cd options[:name]
11
- delete_environment_variable 'RUBYOPT'
12
- delete_environment_variable 'BUNDLE_BIN_PATH'
13
- delete_environment_variable 'BUNDLE_GEMFILE'
5
+ validate_rails_new_success(run_rails_new_command(options))
6
+ clear_bundle_env_vars(options[:name])
14
7
  end
15
8
 
16
9
  def install_cucumber_rails(*options)
17
10
  add_conditional_gems(options)
18
11
 
19
- gem 'selenium-webdriver', '~> 3.11', group: :test
20
- gem 'rspec-expectations', '~> 3.7', group: :test
21
- gem 'database_cleaner', '>= 1.1', group: :test unless options.include?(:no_database_cleaner)
22
- gem 'factory_bot', '>= 3.2', group: :test unless options.include?(:no_factory_bot)
12
+ add_gem 'capybara', group: :test
13
+ add_gem 'selenium-webdriver', '~> 3.11', group: :test
14
+ add_gem 'rspec-expectations', '~> 3.7', group: :test
15
+ add_gem 'database_cleaner', '>= 1.8.0', group: :test unless options.include?(:no_database_cleaner)
16
+ add_gem 'factory_bot', '>= 3.2', group: :test unless options.include?(:no_factory_bot)
23
17
 
24
18
  run_command_and_stop 'bundle install'
25
19
  run_command_and_stop 'bundle exec rails webpacker:install' if rails6?
26
20
  run_command_and_stop 'bundle exec rails generate cucumber:install'
27
21
  end
28
22
 
29
- def gem(name, *args)
30
- options = args.last.is_a?(Hash) ? args.pop : {}
31
-
32
- parts = ["'#{name}'"]
33
- parts << args.map(&:inspect) if args.any?
34
- parts << options.inspect[1..-2] if options.any?
35
-
36
- line = "gem #{parts.join(', ')}\n"
37
-
23
+ def add_gem(name, *args)
24
+ line = convert_gem_opts_to_string(name, *args)
38
25
  gem_regexp = /gem ["']#{name}["'].*$/
39
26
  gemfile_content = File.read(expand_path('Gemfile'))
40
27
 
41
- if gemfile_content =~ gem_regexp
42
- gemfile_content.gsub!(gem_regexp, line)
43
- overwrite_file('Gemfile', gemfile_content)
28
+ if gemfile_content&.match?(gem_regexp)
29
+ updated_gemfile_content = gemfile_content.gsub(gem_regexp, line)
30
+ overwrite_file('Gemfile', updated_gemfile_content)
44
31
  else
45
32
  append_to_file('Gemfile', line)
46
33
  end
@@ -48,28 +35,50 @@ module CucumberRailsHelper
48
35
 
49
36
  private
50
37
 
38
+ def run_rails_new_command(options)
39
+ options[:name] ||= 'test_app'
40
+ flags = '--skip-bundle --skip-test-unit --skip-spring --skip-bootsnap'
41
+ flags += ' --skip-webpack-install' if rails6?
42
+ run_command "bundle exec rails new #{options[:name]} #{flags} #{options[:args]}"
43
+ end
44
+
45
+ def validate_rails_new_success(result)
46
+ expect(result).to have_output(/README/)
47
+ expect(last_command_started).to be_successfully_executed
48
+ end
49
+
50
+ def clear_bundle_env_vars(dir)
51
+ cd dir
52
+ delete_environment_variable 'RUBYOPT'
53
+ delete_environment_variable 'BUNDLE_BIN_PATH'
54
+ delete_environment_variable 'BUNDLE_GEMFILE'
55
+ end
56
+
51
57
  def rails6?
52
58
  `bundle exec rails -v`.start_with?('Rails 6')
53
59
  end
54
60
 
55
61
  def add_conditional_gems(options)
56
62
  if options.include?(:not_in_test_group)
57
- gem 'cucumber-rails', path: File.expand_path('.').to_s
63
+ add_gem 'cucumber-rails', path: File.expand_path('.').to_s
58
64
  else
59
- gem 'cucumber-rails', group: :test, require: false, path: File.expand_path('.').to_s
65
+ add_gem 'cucumber-rails', group: :test, require: false, path: File.expand_path('.').to_s
60
66
  end
61
67
 
62
68
  if rails6?
63
- gem 'sqlite3', '~> 1.4'
69
+ add_gem 'sqlite3', '~> 1.4'
64
70
  else
65
- gem 'sqlite3', '~> 1.3.13'
71
+ add_gem 'sqlite3', '~> 1.3.13'
66
72
  end
73
+ end
67
74
 
68
- if RUBY_VERSION < '2.4.0'
69
- gem 'capybara', '< 3.16.0', group: :test
70
- else
71
- gem 'capybara', group: :test
72
- end
75
+ def convert_gem_opts_to_string(name, *args)
76
+ options = args.last.is_a?(Hash) ? args.pop : {}
77
+ parts = ["'#{name}'"]
78
+ parts << args.map(&:inspect) if args.any?
79
+ parts << options.inspect[1..-2] if options.any?
80
+ new_parts = parts.flatten.map { |part| part.gsub(/:(\w+)=>/, '\1: ') }
81
+ "gem #{new_parts.join(', ')}\n"
73
82
  end
74
83
  end
75
84
 
@@ -10,18 +10,12 @@ if called_from_env_rb
10
10
  ENV['RAILS_ENV'] ||= 'test'
11
11
  ENV['RAILS_ROOT'] ||= File.expand_path(env_caller + '/../..')
12
12
  require File.expand_path(ENV['RAILS_ROOT'] + '/config/environment')
13
- require 'cucumber/rails/action_controller'
13
+ require 'cucumber/rails/action_dispatch'
14
+ require 'rails/test_help'
14
15
 
15
- if defined?(ActiveRecord::Base)
16
- require 'rails/test_help'
17
- else
18
- require 'action_dispatch/testing/test_process'
19
- require 'action_dispatch/testing/integration'
20
- end
21
-
22
- unless Rails.application.config.cache_classes
16
+ unless Rails.application.config.cache_classes || defined?(Spring)
23
17
  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
18
+ (Spring needs cache_classes set to false). This is known to cause problems
25
19
  with database transactions. Set config.cache_classes to true if you want to use transactions."
26
20
  end
27
21
 
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActionController::Base.class_eval do
4
+ cattr_accessor :allow_rescue
5
+ end
6
+
7
+ module Cucumber
8
+ module Rails
9
+ module ActionDispatch
10
+ module ShowExceptions
11
+ def call(env)
12
+ env['action_dispatch.show_detailed_exceptions'] = !ActionController::Base.allow_rescue
13
+ env['action_dispatch.show_exceptions'] = !env['action_dispatch.show_detailed_exceptions']
14
+ super(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ ActionDispatch::ShowExceptions.prepend(Cucumber::Rails::ActionDispatch::ShowExceptions)
@@ -7,17 +7,20 @@ require 'rails/application'
7
7
  # Instead we are overriding ActionDispatch::ShowExceptions to be able to
8
8
  # toggle whether or not exceptions are raised.
9
9
 
10
- module Rails
11
- class Application
12
- alias __cucumber_orig_initialize__ initialize!
10
+ module Cucumber
11
+ module Rails
12
+ module Application
13
+ def initialize!
14
+ ad = config.action_dispatch
13
15
 
14
- def initialize!
15
- ad = config.action_dispatch
16
+ def ad.show_exceptions
17
+ true
18
+ end
16
19
 
17
- def ad.show_exceptions
18
- true
20
+ super
19
21
  end
20
- __cucumber_orig_initialize__
21
22
  end
22
23
  end
23
24
  end
25
+
26
+ Rails::Application.prepend(Cucumber::Rails::Application)
@@ -48,27 +48,38 @@ module Cucumber
48
48
  js_form['action'] = action
49
49
  js_form['method'] = method
50
50
 
51
- if emulated_method && !emulated_method.casecmp(method).zero?
52
- input = document.create_element('input')
53
- input['type'] = 'hidden'
54
- input['name'] = '_method'
55
- input['value'] = emulated_method
56
- js_form.add_child(input)
57
- end
51
+ add_hidden_method_input(document, js_form) unless same?(emulated_method, method)
58
52
 
59
- # rails will wipe the session if the CSRF token is not sent
60
- # with non-GET requests
61
- if csrf? && !emulated_method.casecmp('get').zero?
62
- input = document.create_element('input')
63
- input['type'] = 'hidden'
64
- input['name'] = csrf_param
65
- input['value'] = csrf_token
66
- js_form.add_child(input)
67
- end
53
+ # rails will wipe the session if the CSRF token is not sent with non-GET requests
54
+ add_hidden_csrf_input(document, js_form) if csrf? && !get?(emulated_method)
68
55
 
69
56
  js_form
70
57
  end
71
58
 
59
+ def same?(emulated_method, method)
60
+ emulated_method.casecmp(method).zero?
61
+ end
62
+
63
+ def add_hidden_method_input(document, js_form)
64
+ input = document.create_element('input')
65
+ input['type'] = 'hidden'
66
+ input['name'] = '_method'
67
+ input['value'] = emulated_method
68
+ js_form.add_child(input)
69
+ end
70
+
71
+ def get?(emulated_method)
72
+ same?(emulated_method, 'get')
73
+ end
74
+
75
+ def add_hidden_csrf_input(document, js_form)
76
+ input = document.create_element('input')
77
+ input['type'] = 'hidden'
78
+ input['name'] = csrf_param
79
+ input['value'] = csrf_token
80
+ js_form.add_child(input)
81
+ end
82
+
72
83
  def link_with_non_get_http_method?
73
84
  tag_name == 'a' &&
74
85
  element_node['data-method'] &&
@@ -53,7 +53,7 @@ module Cucumber
53
53
  end
54
54
 
55
55
  def mapped_keys
56
- map.keys.join(',')
56
+ map.keys.join(', ')
57
57
  end
58
58
 
59
59
  def validate_interface!
@@ -76,7 +76,11 @@ module Cucumber
76
76
  end
77
77
 
78
78
  def before_js(strategy)
79
- @original_strategy = DatabaseCleaner.connections.first.strategy # that feels like a nasty hack
79
+ @original_strategy = if Gem::Version.new(DatabaseCleaner::VERSION) >= Gem::Version.new('1.8.0.beta')
80
+ DatabaseCleaner.cleaners.values.first.strategy # that feels like a nasty hack
81
+ else
82
+ DatabaseCleaner.connections.first.strategy # that feels like a nasty hack
83
+ end
80
84
  DatabaseCleaner.strategy = strategy, @options
81
85
  end
82
86
 
@@ -1,25 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if defined?(ActiveRecord::Base)
4
- module ActiveRecord
5
- class Base
6
- class_attribute :shared_connection
3
+ module ActiveRecord
4
+ class Base
5
+ class_attribute :shared_connection
7
6
 
8
- def self.connection
9
- shared_connection || retrieve_connection
10
- end
7
+ def self.connection
8
+ shared_connection || retrieve_connection
11
9
  end
12
10
  end
11
+ end
13
12
 
14
- Before('@javascript') do
15
- Cucumber::Rails::Database.before_js if Cucumber::Rails::Database.autorun_database_cleaner
16
- end
13
+ Before('@javascript') do
14
+ Cucumber::Rails::Database.before_js if Cucumber::Rails::Database.autorun_database_cleaner
15
+ end
17
16
 
18
- Before('not @javascript') do
19
- Cucumber::Rails::Database.before_non_js if Cucumber::Rails::Database.autorun_database_cleaner
20
- end
17
+ Before('not @javascript') do
18
+ Cucumber::Rails::Database.before_non_js if Cucumber::Rails::Database.autorun_database_cleaner
19
+ end
21
20
 
22
- After do
23
- Cucumber::Rails::Database.after if Cucumber::Rails::Database.autorun_database_cleaner
24
- end
21
+ After do
22
+ Cucumber::Rails::Database.after if Cucumber::Rails::Database.autorun_database_cleaner
25
23
  end
@@ -11,5 +11,5 @@ begin
11
11
  DatabaseCleaner.clean if Cucumber::Rails::Database.autorun_database_cleaner
12
12
  end
13
13
  rescue LoadError
14
- # database_cleaner gem not present
14
+ Cucumber.logger.debug('database_cleaner gem not present.')
15
15
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if defined?(ActionMailer::Base)
4
- Before do
5
- ActionMailer::Base.deliveries = []
6
- end
3
+ Before do
4
+ ActionMailer::Base.deliveries = []
7
5
  end
@@ -4,7 +4,7 @@ begin
4
4
  # Try to load it so we can assign @_result below if needed.
5
5
  require 'test/unit/testresult'
6
6
  rescue LoadError
7
- # Test Unit not found
7
+ Cucumber.logger.debug('Minitest not found.')
8
8
  end
9
9
 
10
10
  module Cucumber
@@ -20,7 +20,7 @@ end
20
20
 
21
21
  module Cucumber
22
22
  module Rails
23
- class World < ActionDispatch::IntegrationTest
23
+ class World < ::ActionDispatch::IntegrationTest
24
24
  include Rack::Test::Methods if Cucumber::Rails.include_rack_test_helpers?
25
25
  include ActiveSupport::Testing::SetupAndTeardown if ActiveSupport::Testing.const_defined?('SetupAndTeardown')
26
26
 
@@ -8,54 +8,63 @@ describe Cucumber::Rails::Database do
8
8
  let(:strategy) { instance_double(strategy_type, before_js: nil, before_non_js: nil) }
9
9
  let(:strategy_type) { Cucumber::Rails::Database::TruncationStrategy }
10
10
 
11
- it 'forwards events to the selected strategy' do
12
- described_class.javascript_strategy = :truncation
11
+ context 'when using a valid pre-determined strategy' do
12
+ before { described_class.javascript_strategy = :truncation }
13
13
 
14
- expect(strategy).to receive(:before_non_js)
15
- described_class.before_non_js
14
+ it 'forwards a `before_non_js` event to the selected strategy' do
15
+ expect(strategy).to receive(:before_non_js)
16
+
17
+ described_class.before_non_js
18
+ end
16
19
 
17
- expect(strategy).to receive(:before_js)
18
- described_class.before_js
20
+ it 'forwards a `before_js` event to the selected strategy' do
21
+ expect(strategy).to receive(:before_js)
22
+
23
+ described_class.before_js
24
+ end
19
25
  end
20
26
 
21
- it 'raises an error if you use a non-understood strategy' do
22
- expect { described_class.javascript_strategy = :invalid }
23
- .to raise_error(Cucumber::Rails::Database::InvalidStrategy)
27
+ context 'when using an invalid pre-determined strategy' do
28
+ it 'raises an error if you use a non-understood strategy' do
29
+ expect { described_class.javascript_strategy = :invalid }
30
+ .to raise_error(Cucumber::Rails::Database::InvalidStrategy)
31
+ end
24
32
  end
25
33
 
26
- context 'using a custom strategy' do
27
- let(:strategy_type) { ValidStrategy }
34
+ context 'when using a valid custom strategy' do
35
+ before { described_class.javascript_strategy = strategy_type }
28
36
 
29
- class ValidStrategy
30
- def before_js
31
- # Anything
32
- end
37
+ let(:strategy_type) do
38
+ Class.new do
39
+ def before_js
40
+ # Anything
41
+ end
33
42
 
34
- def before_non_js
35
- # Likewise
43
+ def before_non_js
44
+ # Likewise
45
+ end
36
46
  end
37
47
  end
38
48
 
39
- class InvalidStrategy; end
49
+ it 'forwards a `before_non_js` event to the strategy' do
50
+ expect(strategy).to receive(:before_non_js)
40
51
 
41
- it 'raises an error if the strategy does not have a valid interface' do
42
- expect { described_class.javascript_strategy = InvalidStrategy }
43
- .to raise_error(ArgumentError)
52
+ described_class.before_non_js
44
53
  end
45
54
 
46
- it 'accepts the strategy if it has a valid interface' do
47
- expect { described_class.javascript_strategy = ValidStrategy }
48
- .not_to raise_error
49
- end
55
+ it 'forwards a `before_js` event to the strategy' do
56
+ expect(strategy).to receive(:before_js)
50
57
 
51
- it 'forwards events to the strategy' do
52
- described_class.javascript_strategy = ValidStrategy
58
+ described_class.before_js
59
+ end
60
+ end
53
61
 
54
- expect(strategy).to receive(:before_non_js)
55
- described_class.before_non_js
62
+ context 'when using an invalid custom strategy' do
63
+ let(:invalid_strategy) { Class.new }
56
64
 
57
- expect(strategy).to receive(:before_js)
58
- described_class.before_js
65
+ it 'raises an error if the strategy does not have a valid interface' do
66
+ expect { described_class.javascript_strategy = invalid_strategy }
67
+ .to raise_error(ArgumentError)
59
68
  end
60
69
  end
61
70
  end
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: 2.0.0
4
+ version: 2.1.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-11-01 00:00:00.000000000 Z
13
+ date: 2020-06-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: capybara
@@ -41,7 +41,7 @@ dependencies:
41
41
  version: 3.0.2
42
42
  - - "<"
43
43
  - !ruby/object:Gem::Version
44
- version: '4'
44
+ version: '5'
45
45
  type: :runtime
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,7 +51,7 @@ dependencies:
51
51
  version: 3.0.2
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
- version: '4'
54
+ version: '5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mime-types
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -87,7 +87,7 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '1.8'
89
89
  - !ruby/object:Gem::Dependency
90
- name: railties
90
+ name: rails
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
@@ -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: aruba
124
+ name: appraisal
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: 0.14.4
129
+ version: '2.2'
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: 0.14.4
136
+ version: '2.2'
137
137
  - !ruby/object:Gem::Dependency
138
- name: appraisal
138
+ name: aruba
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: '2.2'
143
+ version: '1.0'
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: '2.2'
150
+ version: '1.0'
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: bundler
153
153
  requirement: !ruby/object:Gem::Requirement
@@ -162,26 +162,6 @@ dependencies:
162
162
  - - ">="
163
163
  - !ruby/object:Gem::Version
164
164
  version: '1.17'
165
- - !ruby/object:Gem::Dependency
166
- name: rails
167
- requirement: !ruby/object:Gem::Requirement
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- version: '4.2'
172
- - - "<"
173
- - !ruby/object:Gem::Version
174
- version: '7'
175
- type: :development
176
- prerelease: false
177
- version_requirements: !ruby/object:Gem::Requirement
178
- requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- version: '4.2'
182
- - - "<"
183
- - !ruby/object:Gem::Version
184
- version: '7'
185
165
  - !ruby/object:Gem::Dependency
186
166
  name: rake
187
167
  requirement: !ruby/object:Gem::Requirement
@@ -216,42 +196,42 @@ dependencies:
216
196
  requirements:
217
197
  - - "~>"
218
198
  - !ruby/object:Gem::Version
219
- version: 0.72.0
199
+ version: 0.85.0
220
200
  type: :development
221
201
  prerelease: false
222
202
  version_requirements: !ruby/object:Gem::Requirement
223
203
  requirements:
224
204
  - - "~>"
225
205
  - !ruby/object:Gem::Version
226
- version: 0.72.0
206
+ version: 0.85.0
227
207
  - !ruby/object:Gem::Dependency
228
208
  name: rubocop-performance
229
209
  requirement: !ruby/object:Gem::Requirement
230
210
  requirements:
231
211
  - - "~>"
232
212
  - !ruby/object:Gem::Version
233
- version: 1.4.0
213
+ version: 1.6.1
234
214
  type: :development
235
215
  prerelease: false
236
216
  version_requirements: !ruby/object:Gem::Requirement
237
217
  requirements:
238
218
  - - "~>"
239
219
  - !ruby/object:Gem::Version
240
- version: 1.4.0
220
+ version: 1.6.1
241
221
  - !ruby/object:Gem::Dependency
242
222
  name: rubocop-rspec
243
223
  requirement: !ruby/object:Gem::Requirement
244
224
  requirements:
245
225
  - - "~>"
246
226
  - !ruby/object:Gem::Version
247
- version: 1.33.0
227
+ version: 1.39.0
248
228
  type: :development
249
229
  prerelease: false
250
230
  version_requirements: !ruby/object:Gem::Requirement
251
231
  requirements:
252
232
  - - "~>"
253
233
  - !ruby/object:Gem::Version
254
- version: 1.33.0
234
+ version: 1.39.0
255
235
  - !ruby/object:Gem::Dependency
256
236
  name: sqlite3
257
237
  requirement: !ruby/object:Gem::Requirement
@@ -305,7 +285,6 @@ files:
305
285
  - ".gitignore"
306
286
  - ".rspec"
307
287
  - ".rubocop.yml"
308
- - ".rubocop_todo.yml"
309
288
  - ".travis.yml"
310
289
  - Appraisals
311
290
  - CHANGELOG.md
@@ -352,7 +331,7 @@ files:
352
331
  - gemfiles/rails_5_2.gemfile
353
332
  - gemfiles/rails_6_0.gemfile
354
333
  - lib/cucumber/rails.rb
355
- - lib/cucumber/rails/action_controller.rb
334
+ - lib/cucumber/rails/action_dispatch.rb
356
335
  - lib/cucumber/rails/application.rb
357
336
  - lib/cucumber/rails/capybara.rb
358
337
  - lib/cucumber/rails/capybara/javascript_emulation.rb
@@ -379,10 +358,15 @@ files:
379
358
  - spec/cucumber/rails/database_spec.rb
380
359
  - spec/generators/cucumber/install_generator_spec.rb
381
360
  - spec/spec_helper.rb
382
- homepage: http://cukes.info
361
+ homepage: https://cucumber.io
383
362
  licenses:
384
363
  - MIT
385
- metadata: {}
364
+ metadata:
365
+ bug_tracker_uri: https://github.com/cucumber/cucumber-rails/issues
366
+ changelog_uri: https://github.com/cucumber/cucumber-rails/blob/v2.1.0/CHANGELOG.md
367
+ documentation_uri: https://cucumber.io/docs
368
+ mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
369
+ source_code_uri: https://github.com/cucumber/cucumber-rails/tree/v2.1.0
386
370
  post_install_message:
387
371
  rdoc_options: []
388
372
  require_paths:
@@ -391,16 +375,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
391
375
  requirements:
392
376
  - - ">="
393
377
  - !ruby/object:Gem::Version
394
- version: 2.3.0
378
+ version: 2.4.0
395
379
  required_rubygems_version: !ruby/object:Gem::Requirement
396
380
  requirements:
397
381
  - - ">="
398
382
  - !ruby/object:Gem::Version
399
383
  version: '0'
400
384
  requirements: []
401
- rubyforge_project:
402
- rubygems_version: 2.7.9
385
+ rubygems_version: 3.1.2
403
386
  signing_key:
404
387
  specification_version: 4
405
- summary: cucumber-rails-2.0.0
388
+ summary: cucumber-rails-2.1.0
406
389
  test_files: []
@@ -1,59 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2019-07-31 11:34:26 +0200 using RuboCop version 0.72.0.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: AllowForAlignment.
12
- Layout/SpaceAroundOperators:
13
- Exclude:
14
- - 'dev_tasks/yard.rake'
15
-
16
- # Offense count: 2
17
- # Configuration parameters: AllowComments.
18
- Lint/HandleExceptions:
19
- Exclude:
20
- - 'lib/cucumber/rails/hooks/database_cleaner.rb'
21
- - 'lib/cucumber/rails/world.rb'
22
-
23
- # Offense count: 3
24
- Metrics/AbcSize:
25
- Max: 19
26
-
27
- # Offense count: 3
28
- # Configuration parameters: CountComments, ExcludedMethods.
29
- Metrics/MethodLength:
30
- Max: 18
31
-
32
- # Offense count: 4
33
- # Configuration parameters: .
34
- # SupportedStyles: have_received, receive
35
- RSpec/MessageSpies:
36
- EnforcedStyle: receive
37
-
38
- # Offense count: 2
39
- # Configuration parameters: AggregateFailuresByDefault.
40
- RSpec/MultipleExpectations:
41
- Max: 2
42
-
43
- # Offense count: 1
44
- Style/DoubleNegation:
45
- Exclude:
46
- - 'lib/cucumber/rails/action_controller.rb'
47
-
48
- # Offense count: 1
49
- Style/MixinUsage:
50
- Exclude:
51
- - 'lib/cucumber/rails/rspec.rb'
52
-
53
- # Offense count: 1
54
- # Cop supports --auto-correct.
55
- # Configuration parameters: EnforcedOctalStyle.
56
- # SupportedOctalStyles: zero_with_o, zero_only
57
- Style/NumericLiteralPrefix:
58
- Exclude:
59
- - 'lib/generators/cucumber/install_generator.rb'
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ActionController::Base.class_eval do
4
- cattr_accessor :allow_rescue
5
- end
6
-
7
- module ActionDispatch
8
- class ShowExceptions
9
- alias __cucumber_orig_call__ call
10
-
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
16
- end
17
- end