Skip to content

Commit

Permalink
Merge branch 'master' into feature/tidy_feature_code
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-hill committed Apr 29, 2019
2 parents bd96c03 + 67562ad commit 9d50756
Show file tree
Hide file tree
Showing 21 changed files with 104 additions and 83 deletions.
7 changes: 4 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,4 +25,5 @@ Style/RegexpLiteral:

BlockLength:
Exclude:
- './spec/**/*_spec.rb'
- 'cucumber-rails.gemspec'
49 changes: 12 additions & 37 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,41 @@
# 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.
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:
Exclude:
- '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:
Expand All @@ -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.
Expand All @@ -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
15 changes: 13 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
language: ruby

dist: xenial

rvm:
- 2.3
- 2.4
Expand All @@ -12,6 +16,9 @@ branches:
only:
- master

services:
- xvfb

gemfile:
- gemfiles/rails_6_0.gemfile
- gemfiles/rails_5_2.gemfile
Expand Down Expand Up @@ -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
21 changes: 13 additions & 8 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion bin/install_geckodriver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion cucumber-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
5 changes: 4 additions & 1 deletion dev_tasks/yard/default/layout/html/setup.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions features/step_definitions/cucumber_rails_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_4_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: '../'
1 change: 1 addition & 0 deletions gemfiles/rails_5_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: '../'
1 change: 1 addition & 0 deletions gemfiles/rails_5_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: '../'
4 changes: 3 additions & 1 deletion gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: '../'
1 change: 1 addition & 0 deletions gemfiles/rails_6_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: '../'
14 changes: 8 additions & 6 deletions lib/cucumber/rails/action_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 11 additions & 7 deletions lib/cucumber/rails/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions lib/cucumber/rails/capybara/javascript_emulation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions lib/cucumber/rails/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading

0 comments on commit 9d50756

Please sign in to comment.