diff --git a/.rubocop.yml b/.rubocop.yml index d4d71702..c182edef 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,9 +6,9 @@ AllCops: # This file is something which we aren't advising people to use # Probably need to consider deleting this fully at some point - 'features/support/legacy_web_steps_support.rb' - # This file is auto-generated from a load of features that need - # some love and updates to conform to rubocop - - 'tmp/aruba/rails-app/features/step_definitions/web_steps.rb' + # These are auto-generated from a load of features that we + # don't have direct control over + - 'tmp/**/*' Style/Documentation: Enabled: false @@ -25,4 +25,5 @@ Style/RegexpLiteral: BlockLength: Exclude: + - './spec/**/*_spec.rb' - 'cucumber-rails.gemspec' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e905cd95..96900260 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,19 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2019-04-18 16:01:01 +0200 using RuboCop version 0.66.0. +# on 2019-04-26 11:07:21 +0200 using RuboCop version 0.66.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Exclude: + - 'lib/cucumber/rails/database.rb' + # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment. @@ -13,11 +21,10 @@ Layout/SpaceAroundOperators: Exclude: - 'dev_tasks/yard.rake' -# Offense count: 7 +# Offense count: 5 Lint/AmbiguousRegexpLiteral: Exclude: - 'features/step_definitions/cucumber_rails_steps.rb' - - 'tmp/aruba/rails-app/features/step_definitions/rest_steps.rb' # Offense count: 2 Lint/HandleExceptions: @@ -25,21 +32,10 @@ Lint/HandleExceptions: - 'lib/cucumber/rails/hooks/database_cleaner.rb' - 'lib/cucumber/rails/world.rb' -# Offense count: 1 -Lint/UnreachableCode: - Exclude: - - 'tmp/aruba/rails-app/features/support/paths.rb' - # Offense count: 4 Metrics/AbcSize: Max: 22 -# Offense count: 5 -# Configuration parameters: CountComments, ExcludedMethods. -# ExcludedMethods: refine -Metrics/BlockLength: - Max: 39 - # Offense count: 4 # Configuration parameters: CountComments, ExcludedMethods. Metrics/MethodLength: @@ -49,36 +45,15 @@ Metrics/MethodLength: Metrics/PerceivedComplexity: Max: 8 -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Exclude: - - 'lib/cucumber/rails/action_controller.rb' - - 'lib/cucumber/rails/application.rb' - - 'lib/cucumber/rails/capybara/javascript_emulation.rb' - - 'lib/cucumber/rails/hooks/active_record.rb' - - 'tmp/aruba/rails-app/test/test_helper.rb' - # Offense count: 1 Style/DoubleNegation: Exclude: - 'lib/cucumber/rails/action_controller.rb' # Offense count: 2 -# Cop supports --auto-correct. -Style/IfUnlessModifier: - Exclude: - - 'dev_tasks/yard.rake' - - 'lib/cucumber/rails.rb' - -# Offense count: 3 Style/MixinUsage: Exclude: - 'lib/cucumber/rails/rspec.rb' - - 'tmp/aruba/rails-app/bin/setup' - - 'tmp/aruba/rails-app/bin/update' # Offense count: 1 # Cop supports --auto-correct. @@ -88,8 +63,8 @@ Style/NumericLiteralPrefix: Exclude: - 'lib/generators/cucumber/install/install_generator.rb' -# Offense count: 115 +# Offense count: 41 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: - Max: 142 + Max: 122 diff --git a/.travis.yml b/.travis.yml index 796c319e..b07f37b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,7 @@ +language: ruby + +dist: xenial + rvm: - 2.3 - 2.4 @@ -12,6 +16,9 @@ branches: only: - master +services: + - xvfb + gemfile: - gemfiles/rails_6_0.gemfile - gemfiles/rails_5_2.gemfile @@ -40,10 +47,14 @@ matrix: gemfile: gemfiles/rails_5_0.gemfile - rvm: 2.6 gemfile: gemfiles/rails_5_1.gemfile + - rvm: ruby-head + gemfile: gemfiles/rails_4_2.gemfile + - rvm: ruby-head + gemfile: gemfiles/rails_5_0.gemfile + - rvm: ruby-head + gemfile: gemfiles/rails_5_1.gemfile before_install: - gem install --remote bundler -v '~> 1.17' - bin/install_geckodriver.sh - bin/install_webpacker.sh - -before_script: geckodriver -V diff --git a/Appraisals b/Appraisals index 03bbb18c..2c73b39d 100644 --- a/Appraisals +++ b/Appraisals @@ -1,32 +1,37 @@ appraise 'rails_4_2' do - gem 'railties', '~> 4.2.1' - gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'capybara', '< 3.16.0', platform: %i[mri_23 mri_22] + gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'nokogiri', '< 1.9.1', platform: %i[mri_23 mri_22] + gem 'railties', '~> 4.2.1' + gem 'sqlite3', '~> 1.3.13' end appraise 'rails_5_0' do - gem 'railties', '~> 5.0.0' - gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'capybara', '< 3.16.0', platform: %i[mri_23 mri_22] + gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'nokogiri', '< 1.9.1', platform: %i[mri_23 mri_22] + gem 'railties', '~> 5.0.0' + gem 'sqlite3', '~> 1.3.13' end appraise 'rails_5_1' do - gem 'railties', '~> 5.1.0' - gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'capybara', '< 3.16.0', platform: %i[mri_23 mri_22] + gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'nokogiri', '< 1.9.1', platform: %i[mri_23 mri_22] + gem 'railties', '~> 5.1.0' + gem 'sqlite3', '~> 1.3.13' end appraise 'rails_5_2' do - gem 'railties', '~> 5.2' - gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'capybara', '< 3.16.0', platform: %i[mri_23 mri_22] + gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'nokogiri', '< 1.9.1', platform: %i[mri_23 mri_22] + gem 'railties', '~> 5.2.3' + gem 'sqlite3', '~> 1.3.13' end appraise 'rails_6_0' do gem 'railties', '~> 6.0.0.beta1' gem 'rails', '~> 6.0.0.beta1' + gem 'sqlite3', '~> 1.4' end diff --git a/README.md b/README.md index d9fec318..7294b66b 100644 --- a/README.md +++ b/README.md @@ -103,8 +103,6 @@ If you've changed versions of the dependencies, you may find it helpful to force [bundle exec] rake clean - - ### Adding dependencies To support the multiple-gemfile testing, when adding a new dependency the following rules apply: diff --git a/Rakefile b/Rakefile index 63e23aec..7dfe4674 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ -CUCUMBER_RAILS_VERSION = Gem::Specification.load(File.dirname(__FILE__) + '/cucumber-rails.gemspec').version.version +CUCUMBER_RAILS_VERSION = + Gem::Specification.load(File.dirname(__FILE__) + '/cucumber-rails.gemspec').version.version require 'rubygems' require 'bundler' require 'bundler/setup' diff --git a/bin/install_geckodriver.sh b/bin/install_geckodriver.sh index 082627d4..aa4488c4 100755 --- a/bin/install_geckodriver.sh +++ b/bin/install_geckodriver.sh @@ -8,7 +8,7 @@ curl --silent \ --fail \ --retry 3 \ --output /tmp/geckodriver_linux64.tar.gz \ - https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz + https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz sudo tar -C /usr/local/bin -xvzf /tmp/geckodriver_linux64.tar.gz geckodriver diff --git a/cucumber-rails.gemspec b/cucumber-rails.gemspec index 65c6bc63..2dedea9b 100644 --- a/cucumber-rails.gemspec +++ b/cucumber-rails.gemspec @@ -26,7 +26,6 @@ Gem::Specification.new do |s| s.add_development_dependency('rake', '>= 12.0') s.add_development_dependency('rspec', '~> 3.6') s.add_development_dependency('rubocop', '~> 0.66.0') - s.add_development_dependency('sqlite3', '~> 1.3.13') # For Documentation: s.add_development_dependency('rdiscount', '>= 2.2') diff --git a/dev_tasks/yard/default/layout/html/setup.rb b/dev_tasks/yard/default/layout/html/setup.rb index 3f3019ff..4c99b0af 100644 --- a/dev_tasks/yard/default/layout/html/setup.rb +++ b/dev_tasks/yard/default/layout/html/setup.rb @@ -1,4 +1,7 @@ def init super - options[:serializer].serialize('/images/bubble_32x32.png', IO.read(File.dirname(__FILE__) + '/bubble_32x32.png')) + options[:serializer].serialize( + '/images/bubble_32x32.png', + IO.read(File.dirname(__FILE__) + '/bubble_32x32.png') + ) end diff --git a/features/step_definitions/cucumber_rails_steps.rb b/features/step_definitions/cucumber_rails_steps.rb index 42edd149..f7fd5dfe 100644 --- a/features/step_definitions/cucumber_rails_steps.rb +++ b/features/step_definitions/cucumber_rails_steps.rb @@ -20,8 +20,8 @@ end Given('I have a {string} ActiveRecord model object') do |name| - run_simple("bundle exec rails g model #{name}") - run_simple('bundle exec rake db:migrate RAILS_ENV=test') + run_command_and_stop("bundle exec rails g model #{name}") + run_command_and_stop('bundle exec rake db:migrate RAILS_ENV=test') end Given('I force selenium to run Firefox in headless mode') do @@ -47,7 +47,7 @@ end When('I run the cukes') do - run_simple('bundle exec cucumber') + run_command_and_stop('bundle exec cucumber') end # Copied from Aruba diff --git a/gemfiles/rails_4_2.gemfile b/gemfiles/rails_4_2.gemfile index 3d123843..4bbc2ce6 100644 --- a/gemfiles/rails_4_2.gemfile +++ b/gemfiles/rails_4_2.gemfile @@ -6,5 +6,6 @@ gem 'capybara', '< 3.16.0', platform: %i[mri_23 mri_22] gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'nokogiri', '< 1.9.1', platform: %i[mri_23 mri_22] gem 'railties', '~> 4.2.1' +gem 'sqlite3', '~> 1.3.13' gemspec path: '../' diff --git a/gemfiles/rails_5_0.gemfile b/gemfiles/rails_5_0.gemfile index be0c123c..c4660bb2 100644 --- a/gemfiles/rails_5_0.gemfile +++ b/gemfiles/rails_5_0.gemfile @@ -6,5 +6,6 @@ gem 'capybara', '< 3.16.0', platform: %i[mri_23 mri_22] gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'nokogiri', '< 1.9.1', platform: %i[mri_23 mri_22] gem 'railties', '~> 5.0.0' +gem 'sqlite3', '~> 1.3.13' gemspec path: '../' diff --git a/gemfiles/rails_5_1.gemfile b/gemfiles/rails_5_1.gemfile index 09db2f6c..13cc0531 100644 --- a/gemfiles/rails_5_1.gemfile +++ b/gemfiles/rails_5_1.gemfile @@ -6,5 +6,6 @@ gem 'capybara', '< 3.16.0', platform: %i[mri_23 mri_22] gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'nokogiri', '< 1.9.1', platform: %i[mri_23 mri_22] gem 'railties', '~> 5.1.0' +gem 'sqlite3', '~> 1.3.13' gemspec path: '../' diff --git a/gemfiles/rails_5_2.gemfile b/gemfiles/rails_5_2.gemfile index 1af8cb7b..da48fcb6 100644 --- a/gemfiles/rails_5_2.gemfile +++ b/gemfiles/rails_5_2.gemfile @@ -2,8 +2,10 @@ source 'https://rubygems.org' +gem 'capybara', '< 3.16.0', platform: %i[mri_23 mri_22] gem 'i18n', '< 1.5.1', platform: :mri_22 gem 'nokogiri', '< 1.9.1', platform: %i[mri_23 mri_22] -gem 'railties', '~> 5.2' +gem 'railties', '~> 5.2.3' +gem 'sqlite3', '~> 1.3.13' gemspec path: '../' diff --git a/gemfiles/rails_6_0.gemfile b/gemfiles/rails_6_0.gemfile index c32fd965..fd8f907d 100644 --- a/gemfiles/rails_6_0.gemfile +++ b/gemfiles/rails_6_0.gemfile @@ -4,5 +4,6 @@ source 'https://rubygems.org' gem 'rails', '~> 6.0.0.beta1' gem 'railties', '~> 6.0.0.beta1' +gem 'sqlite3', '~> 1.4' gemspec path: '../' diff --git a/lib/cucumber/rails/action_controller.rb b/lib/cucumber/rails/action_controller.rb index 705089b1..5409fa23 100644 --- a/lib/cucumber/rails/action_controller.rb +++ b/lib/cucumber/rails/action_controller.rb @@ -2,12 +2,14 @@ cattr_accessor :allow_rescue end -class ActionDispatch::ShowExceptions - alias __cucumber_orig_call__ call +module ActionDispatch + class ShowExceptions + alias __cucumber_orig_call__ call - def call(env) - env['action_dispatch.show_exceptions'] = !!ActionController::Base.allow_rescue - env['action_dispatch.show_detailed_exceptions'] = !ActionController::Base.allow_rescue - __cucumber_orig_call__(env) + def call(env) + env['action_dispatch.show_exceptions'] = !!ActionController::Base.allow_rescue + env['action_dispatch.show_detailed_exceptions'] = !ActionController::Base.allow_rescue + __cucumber_orig_call__(env) + end end end diff --git a/lib/cucumber/rails/application.rb b/lib/cucumber/rails/application.rb index 400bb657..6cdceaf1 100644 --- a/lib/cucumber/rails/application.rb +++ b/lib/cucumber/rails/application.rb @@ -4,14 +4,18 @@ # regardless of what is in config/environments/test.rb # Instead we are overriding ActionDispatch::ShowExceptions to be able to # toggle whether or not exceptions are raised. -class Rails::Application - alias __cucumber_orig_initialize__ initialize! - def initialize! - ad = config.action_dispatch - def ad.show_exceptions - true +module Rails + class Application + alias __cucumber_orig_initialize__ initialize! + + def initialize! + ad = config.action_dispatch + + def ad.show_exceptions + true + end + __cucumber_orig_initialize__ end - __cucumber_orig_initialize__ end end diff --git a/lib/cucumber/rails/capybara/javascript_emulation.rb b/lib/cucumber/rails/capybara/javascript_emulation.rb index 9da56a8a..702ee208 100644 --- a/lib/cucumber/rails/capybara/javascript_emulation.rb +++ b/lib/cucumber/rails/capybara/javascript_emulation.rb @@ -85,8 +85,12 @@ def element_node end end -class Capybara::RackTest::Node - include ::Cucumber::Rails::Capybara::JavascriptEmulation +module Capybara + module RackTest + class Node + include ::Cucumber::Rails::Capybara::JavascriptEmulation + end + end end Before('not @no-js-emulation') do diff --git a/lib/cucumber/rails/database.rb b/lib/cucumber/rails/database.rb index 6bc9a1e0..14f1e678 100644 --- a/lib/cucumber/rails/database.rb +++ b/lib/cucumber/rails/database.rb @@ -13,7 +13,11 @@ def javascript_strategy=(args) strategy_type = case strategy when Symbol - map[strategy] || raise(InvalidStrategy, "The strategy '#{strategy}' is not understood. Please use one of #{map.keys.join(',')}") + map[strategy] || + raise( + InvalidStrategy, + "The strategy '#{strategy}' is not understood. Please use one of #{map.keys.join(',')}" + ) when Class strategy end @@ -49,7 +53,10 @@ def map def validate_interface! return if CUSTOM_STRATEGY_INTERFACE.all? { |m| @strategy.respond_to?(m) } - raise(ArgumentError, "Strategy must respond to all of: #{CUSTOM_STRATEGY_INTERFACE.map { |method| "##{method}" } * ' '} !") + raise( + ArgumentError, + "Strategy must respond to all of: #{CUSTOM_STRATEGY_INTERFACE.map { |method| "##{method}" } * ' '} !" + ) end end diff --git a/lib/cucumber/rails/hooks/active_record.rb b/lib/cucumber/rails/hooks/active_record.rb index f5607166..6a31f8a6 100644 --- a/lib/cucumber/rails/hooks/active_record.rb +++ b/lib/cucumber/rails/hooks/active_record.rb @@ -1,9 +1,11 @@ if defined?(ActiveRecord::Base) - class ActiveRecord::Base - class_attribute :shared_connection + module ActiveRecord + class Base + class_attribute :shared_connection - def self.connection - shared_connection || retrieve_connection + def self.connection + shared_connection || retrieve_connection + end end end diff --git a/spec/generators/cucumber/install/install_generator_spec.rb b/spec/generators/cucumber/install/install_generator_spec.rb index f140f2a4..b1682301 100644 --- a/spec/generators/cucumber/install/install_generator_spec.rb +++ b/spec/generators/cucumber/install/install_generator_spec.rb @@ -8,6 +8,9 @@ destination File.expand_path('../../../../tmp', __dir__) before { prepare_destination } + let(:auto_generated_message) do + '# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.' + end describe 'no arguments' do before { run_generator } @@ -26,14 +29,14 @@ describe 'features/support/env.rb' do subject { file('features/support/env.rb') } it { is_expected.to exist } - it { is_expected.to contain '# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.' } + it { is_expected.to contain auto_generated_message } it { is_expected.to contain "require 'cucumber/rails'" } end describe 'lib/tasks/cucumber.rake' do subject { file('lib/tasks/cucumber.rake') } it { is_expected.to exist } - it { is_expected.to contain '# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.' } + it { is_expected.to contain auto_generated_message } it { is_expected.to contain "task cucumber: 'cucumber:ok'" } end