Skip to content

Commit

Permalink
Remove mime-types, rexml, and webrick runtime dependencies (#559)
Browse files Browse the repository at this point in the history
* Remove runtime dependencies: `mime-types` and `rexml`

* Allow the latest selenium-webdriver in feature tests for Rails 6+

* Rubocop resolutions

* Remove `webrick` runtime dependency

* Constrain the selenium-webdriver dependency to >=4.0, <5

* Avoid using 'step' in step definitions

* Rubocop: remove superfluous code
  • Loading branch information
orien authored Jan 11, 2023
1 parent 37cf54f commit 8363873
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This file is intended to be modified using the [`changelog`](github.com/cucumber/changelog) command-line tool.

## [Unreleased]
### Removed
- Removed runtime dependencies: `mime-types`, `rexml`, and `webrick` [#559](https://github.com/cucumber/cucumber-rails/pull/559)

## [2.6.1] - 2022-10-12
### Changed
Expand Down
3 changes: 0 additions & 3 deletions cucumber-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ Gem::Specification.new do |s|

s.add_runtime_dependency('capybara', ['>= 2.18', '< 4'])
s.add_runtime_dependency('cucumber', '>= 3.2', '< 9')
s.add_runtime_dependency('mime-types', ['~> 3.3'])
s.add_runtime_dependency('nokogiri', '~> 1.10')
s.add_runtime_dependency('railties', ['>= 5.0', '< 8'])
s.add_runtime_dependency('rexml', '~> 3.0') # rexml is a bundled gem from ruby 3
s.add_runtime_dependency('webrick', '~> 1.7') # webrick is a bundled gem from ruby 3

# Main development dependencies
s.add_development_dependency('ammeter', '>= 1.1.4')
Expand Down
5 changes: 3 additions & 2 deletions features/step_definitions/cucumber_rails_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@
Capybara.server = :webrick
}

step 'I append to "features/support/env.rb" with:', selenium_config
append_to_file('features/support/env.rb', selenium_config)
append_to_file('Gemfile', "gem 'webrick', group: :test\n")
run_command_and_stop('bundle install --jobs 4')
end

Given('I force {string} to use select boxes for dates') do |file|
Expand Down
23 changes: 11 additions & 12 deletions features/support/cucumber_rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def rails_new(options = {})

def install_cucumber_rails(*options)
add_conditional_gems(options)
add_rails_specific_gems

add_gem 'cucumber', Cucumber::VERSION, group: :test
add_gem 'capybara', Capybara::VERSION, group: :test
add_gem 'selenium-webdriver', '~> 3.11', group: :test
add_gem 'rspec-expectations', '~> 3.7', group: :test
add_gem 'database_cleaner', '>= 1.8.0', group: :test unless options.include?(:no_database_cleaner)
add_gem 'database_cleaner-active_record', '>= 2.0.0.beta2', group: :test if options.include?(:database_cleaner_active_record)
Expand Down Expand Up @@ -79,8 +79,8 @@ def run_rails_new_command(options)
options[:name] ||= 'test_app'
flags = %w[ --skip-action-cable --skip-action-mailer --skip-active-job --skip-bootsnap --skip-bundle --skip-javascript
--skip-jbuilder --skip-listen --skip-spring --skip-sprockets --skip-test-unit --skip-turbolinks ]
flags += %w[--skip-active-storage] if rails_5_2_or_higher?
flags += %w[--skip-action-mailbox --skip-action-text] if rails_6_0_or_higher?
flags += %w[--skip-active-storage] if rails_equal_or_higher_than?('5.2')
flags += %w[--skip-action-mailbox --skip-action-text] if rails_equal_or_higher_than?('6.0')
run_command "bundle exec rails new #{options[:name]} #{flags.join(' ')} #{options[:args]}"
end

Expand All @@ -94,12 +94,8 @@ def clear_bundle_env_vars
delete_environment_variable 'BUNDLE_GEMFILE'
end

def rails_5_2_or_higher?
Rails.gem_version >= Gem::Version.new('5.2')
end

def rails_6_0_or_higher?
Rails.gem_version >= Gem::Version.new('6.0')
def rails_equal_or_higher_than?(version)
Rails.gem_version >= Gem::Version.new(version)
end

def add_conditional_gems(options)
Expand All @@ -108,11 +104,15 @@ def add_conditional_gems(options)
else
add_gem 'cucumber-rails', group: :test, require: false, path: File.expand_path('.').to_s
end
end

if rails_6_0_or_higher?
def add_rails_specific_gems
if rails_equal_or_higher_than?('6.0')
add_gem 'sqlite3', '~> 1.4'
add_gem 'selenium-webdriver', '~> 4.0', group: :test
else
add_gem 'sqlite3', '~> 1.3.13'
add_gem 'selenium-webdriver', '~> 3.11', group: :test
end
end

Expand All @@ -121,8 +121,7 @@ def convert_gem_opts_to_string(name, *args)
parts = ["'#{name}'"]
parts << args.map(&:inspect) if args.any?
parts << options.inspect[1..-2] if options.any?
new_parts = parts.flatten.map { |part| part.gsub(/:(\w+)=>/, '\1: ') }
"gem #{new_parts.join(', ')}\n"
"gem #{parts.flatten.join(', ')}\n"
end
end

Expand Down

0 comments on commit 8363873

Please sign in to comment.