Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Drop Ruby < 2.3 support #2787

Merged
merged 19 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,9 @@
### Development ### Development


Breaking Changes:

* Ruby < 2.3 is no longer supported. (Phil Pirozhkov, #2787)

Enhancements: Enhancements:


* Improve pluralisation of words ending with `s` (like process). (Joshua Pinter, #2779) * Improve pluralisation of words ending with `s` (like process). (Joshua Pinter, #2779)
Expand Down
42 changes: 2 additions & 40 deletions Gemfile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ branch = File.read(File.expand_path("../maintenance-branch", __FILE__)).chomp
end end
end end


if RUBY_VERSION < '1.9.3'
gem 'rake', '< 11.0.0' # rake 11 requires Ruby 1.9.3 or later
elsif RUBY_VERSION < '2.0.0'
gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later
else
gem 'rake', '> 12.3.2'
end

if ENV['DIFF_LCS_VERSION'] if ENV['DIFF_LCS_VERSION']
gem 'diff-lcs', ENV['DIFF_LCS_VERSION'] gem 'diff-lcs', ENV['DIFF_LCS_VERSION']
else else
Expand All @@ -34,37 +26,10 @@ group :documentation do
gem 'github-markup', :platform => :mri gem 'github-markup', :platform => :mri
end end


if RUBY_VERSION < '2.0.0' || RUBY_ENGINE == 'java'
gem 'json', '< 2.0.0'
else
gem 'json', '> 2.3.0'
end

if RUBY_VERSION < '2.2.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
gem 'ffi', '< 1.10'
elsif RUBY_VERSION < '2.0'
gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19
elsif RUBY_VERSION < '2.3.0'
gem 'ffi', '~> 1.12.0'
else
# Until 1.13.2 is released due to Rubygems usage # Until 1.13.2 is released due to Rubygems usage
gem 'ffi', '~> 1.12.0' gem 'ffi', '~> 1.12.0'
end

if RUBY_VERSION < '2.3.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
gem "childprocess", "< 1.0.0"
end


platforms :jruby do gem "jruby-openssl", platforms: :jruby
if RUBY_VERSION < '1.9.0'
# Pin jruby-openssl on older J Ruby
gem "jruby-openssl", "< 0.10.0"
# Pin child-process on older J Ruby
gem "childprocess", "< 1.0.0"
else
gem "jruby-openssl"
end
end


gem 'simplecov', '~> 0.8' gem 'simplecov', '~> 0.8'


Expand All @@ -73,14 +38,11 @@ if RUBY_VERSION >= '2.4' && RUBY_ENGINE == 'ruby'
gem "rubocop", "~> 0.52.1" gem "rubocop", "~> 0.52.1"
end end


gem 'test-unit', '~> 3.0' if RUBY_VERSION.to_f >= 2.2 gem 'test-unit', '~> 3.0'


# Version 5.12 of minitest requires Ruby 2.4 # Version 5.12 of minitest requires Ruby 2.4
if RUBY_VERSION < '2.4.0' if RUBY_VERSION < '2.4.0'
gem 'minitest', '< 5.12.0' gem 'minitest', '< 5.12.0'
end end



gem 'contracts', '< 0.16' if RUBY_VERSION < '1.9.0'

eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom') eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')
8 changes: 1 addition & 7 deletions Gemfile-custom.sample
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ group :development do
platform :mri do platform :mri do
gem 'rb-fsevent', '~> 0.9.0' gem 'rb-fsevent', '~> 0.9.0'
gem 'ruby-prof', '~> 0.13.0' gem 'ruby-prof', '~> 0.13.0'

gem 'pry-byebug'
case RUBY_VERSION
when /^1.8/
gem 'ruby-debug'
when /^1.9/
gem 'debugger'
end
end end
end end
6 changes: 1 addition & 5 deletions cucumber.yml
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,2 @@
<% default: --require features --strict --format progress --tags ~@wip features
exclusions = []
exclusions << ' --tags ~@no-jruby' if RUBY_PLATFORM == 'java'
%>
default: --require features --strict --format progress --tags ~@wip<%= exclusions.join %> features
wip: --require features --tags @wip:30 --wip features wip: --require features --tags @wip:30 --wip features
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Feature: configure expectation framework
""" """
And the output should contain "3 examples, 1 failure" And the output should contain "3 examples, 1 failure"


@broken-on-jruby-9000
Scenario: Configure minitest assertions Scenario: Configure minitest assertions
Given rspec-expectations is not installed Given rspec-expectations is not installed
And a file named "example_spec.rb" with: And a file named "example_spec.rb" with:
Expand Down
8 changes: 1 addition & 7 deletions features/step_definitions/additional_cli_steps.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -232,13 +232,7 @@


module Normalization module Normalization
def normalize_failure_output(text) def normalize_failure_output(text)
whitespace_normalized = text.lines.map { |line| line.sub(/\s+$/, '').sub(/:in .*$/, '') }.join text.lines.map { |line| line.sub(/\s+$/, '').sub(/:in .*$/, '') }.join

# 1.8.7 and JRuby produce slightly different output for `Hash#fetch` errors, so we
# convert it to the same output here to match our expectation.
whitespace_normalized.
sub("IndexError", "KeyError").
sub(/key not found.*$/, "key not found")
end end
end end


Expand Down
2 changes: 0 additions & 2 deletions features/step_definitions/core_standalone_steps.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,7 @@
Given(/^only rspec-core is installed$/) do Given(/^only rspec-core is installed$/) do
if RUBY_VERSION.to_f >= 1.9 # --disable-gems is invalid on 1.8.7
# Ensure the gem versions of rspec-mocks and rspec-expectations # Ensure the gem versions of rspec-mocks and rspec-expectations
# won't be loaded if available on the developers machine. # won't be loaded if available on the developers machine.
set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + ' --disable-gems') set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + ' --disable-gems')
end


# This will make `require_expect_syntax_in_aruba_specs.rb` (loaded # This will make `require_expect_syntax_in_aruba_specs.rb` (loaded
# automatically when the specs run) remove rspec-mocks and # automatically when the specs run) remove rspec-mocks and
Expand Down
4 changes: 0 additions & 4 deletions features/support/jruby.rb

This file was deleted.

6 changes: 2 additions & 4 deletions lib/rspec/core.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
warnings warnings


set set
flat_map
filter_manager filter_manager
dsl dsl
notifications notifications
Expand Down Expand Up @@ -101,10 +100,9 @@ def self.configure
# The example being executed. # The example being executed.
# #
# The primary audience for this method is library authors who need access # The primary audience for this method is library authors who need access
# to the example currently being executed and also want to support all # to the example currently being executed and also want to support RSpec 2.
# versions of RSpec 2 and 3.
# #
# @example # @example support for RSpec version 2
# #
# RSpec.configure do |c| # RSpec.configure do |c|
# # context.example is deprecated, but RSpec.current_example is not # # context.example is deprecated, but RSpec.current_example is not
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/core/bisect/shell_command.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,5 @@
RSpec::Support.require_rspec_core "shell_escape" RSpec::Support.require_rspec_core "shell_escape"
RSpec::Support.require_rspec_support 'ruby_features'
require 'shellwords' require 'shellwords'


module RSpec module RSpec
Expand Down Expand Up @@ -63,6 +64,7 @@ def spec_opts_without_bisect
private private


include RSpec::Core::ShellEscape include RSpec::Core::ShellEscape

# On JRuby, Open3.popen3 does not handle shellescaped args properly: # On JRuby, Open3.popen3 does not handle shellescaped args properly:
# https://github.com/jruby/jruby/issues/2767 # https://github.com/jruby/jruby/issues/2767
if RSpec::Support::Ruby.jruby? if RSpec::Support::Ruby.jruby?
Expand Down
23 changes: 0 additions & 23 deletions lib/rspec/core/bisect/shell_runner.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,32 +41,9 @@ def run_locations(*capture_args)
end end
end end


# `Open3.capture2e` does not work on JRuby:
# https://github.com/jruby/jruby/issues/2766
if Open3.respond_to?(:capture2e) && !RSpec::Support::Ruby.jruby?
def run_command(cmd) def run_command(cmd)
Open3.capture2e(@shell_command.bisect_environment_hash, cmd).first Open3.capture2e(@shell_command.bisect_environment_hash, cmd).first
end end
else # for 1.8.7
# :nocov:
def run_command(cmd)
out = err = nil

original_spec_opts = ENV['SPEC_OPTS']
ENV['SPEC_OPTS'] = @shell_command.spec_opts_without_bisect

Open3.popen3(cmd) do |_, stdout, stderr|
# Reading the streams blocks until the process is complete
out = stdout.read
err = stderr.read
end

"Stdout:\n#{out}\n\nStderr:\n#{err}"
ensure
ENV['SPEC_OPTS'] = original_spec_opts
end
# :nocov:
end
end end
end end
end end
Expand Down
31 changes: 8 additions & 23 deletions lib/rspec/core/configuration.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
RSpec::Support.require_rspec_core "ruby_project" RSpec::Support.require_rspec_core "ruby_project"
RSpec::Support.require_rspec_core "formatters/deprecation_formatter" RSpec::Support.require_rspec_core "formatters/deprecation_formatter"
RSpec::Support.require_rspec_core "output_wrapper" RSpec::Support.require_rspec_core "output_wrapper"
RSpec::Support.require_rspec_support 'ruby_features'


module RSpec module RSpec
module Core module Core
Expand Down Expand Up @@ -842,8 +843,8 @@ def expect_with(*frameworks)


# Tag this exception class so our exception formatting logic knows # Tag this exception class so our exception formatting logic knows
# that it satisfies the `MultipleExceptionError` interface. # that it satisfies the `MultipleExceptionError` interface.
::RSpec::Expectations::MultipleExpectationsNotMetError.__send__( ::RSpec::Expectations::MultipleExpectationsNotMetError.include(
:include, MultipleExceptionError::InterfaceTag MultipleExceptionError::InterfaceTag
) )


::RSpec::Matchers ::RSpec::Matchers
Expand Down Expand Up @@ -1495,7 +1496,6 @@ def extend(mod, *filters)
end end
end end


if RSpec::Support::RubyFeatures.module_prepends_supported?
# Tells RSpec to prepend example groups with `mod`. Methods defined in # Tells RSpec to prepend example groups with `mod`. Methods defined in
# `mod` are exposed to examples (not example groups). Use `filters` to # `mod` are exposed to examples (not example groups). Use `filters` to
# constrain the groups in which to prepend the module. # constrain the groups in which to prepend the module.
Expand Down Expand Up @@ -1533,7 +1533,6 @@ def prepend(mod, *filters)
safe_prepend(mod, group) safe_prepend(mod, group)
end end
end end
end


# @private # @private
# #
Expand Down Expand Up @@ -1586,14 +1585,14 @@ def in_project_source_dir_regex


# @private # @private
def configure_mock_framework def configure_mock_framework
RSpec::Core::ExampleGroup.__send__(:include, mock_framework) RSpec::Core::ExampleGroup.include(mock_framework)
conditionally_disable_mocks_monkey_patching conditionally_disable_mocks_monkey_patching
end end


# @private # @private
def configure_expectation_framework def configure_expectation_framework
expectation_frameworks.each do |framework| expectation_frameworks.each do |framework|
RSpec::Core::ExampleGroup.__send__(:include, framework) RSpec::Core::ExampleGroup.include(framework)
end end
conditionally_disable_expectations_monkey_patching conditionally_disable_expectations_monkey_patching
end end
Expand Down Expand Up @@ -2155,7 +2154,7 @@ def run_suite_hooks(hook_description, hooks)
end end


def get_files_to_run(paths) def get_files_to_run(paths)
files = FlatMap.flat_map(paths_to_check(paths)) do |path| files = paths_to_check(paths).flat_map do |path|
path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
File.directory?(path) ? gather_directories(path) : extract_location(path) File.directory?(path) ? gather_directories(path) : extract_location(path)
end.uniq end.uniq
Expand Down Expand Up @@ -2331,31 +2330,17 @@ def metadata_applies_to_group?(meta, group)
meta.empty? || MetadataFilter.apply?(:any?, meta, group.metadata) meta.empty? || MetadataFilter.apply?(:any?, meta, group.metadata)
end end


if RSpec::Support::RubyFeatures.module_prepends_supported?
def safe_prepend(mod, host) def safe_prepend(mod, host)
host.__send__(:prepend, mod) unless host < mod host.prepend(mod) unless host < mod
end
end end


if RUBY_VERSION.to_f >= 1.9
def safe_include(mod, host) def safe_include(mod, host)
host.__send__(:include, mod) unless host < mod host.include(mod) unless host < mod
end end


def safe_extend(mod, host) def safe_extend(mod, host)
host.extend(mod) unless host.singleton_class < mod host.extend(mod) unless host.singleton_class < mod
end end
else # for 1.8.7
# :nocov:
def safe_include(mod, host)
host.__send__(:include, mod) unless host.included_modules.include?(mod)
end

def safe_extend(mod, host)
host.extend(mod) unless (class << host; self; end).included_modules.include?(mod)
end
# :nocov:
end


def define_mixed_in_module(mod, filters, mod_list, config_method, &block) def define_mixed_in_module(mod, filters, mod_list, config_method, &block)
unless Module === mod unless Module === mod
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/configuration_options.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def parse_args_ignoring_files_or_dirs_to_run(args, source)
def args_from_options_file(path) def args_from_options_file(path)
return [] unless path && File.exist?(path) return [] unless path && File.exist?(path)
config_string = options_file_as_erb_string(path) config_string = options_file_as_erb_string(path)
FlatMap.flat_map(config_string.split(/\n+/), &:shellsplit) config_string.split(/\n+/).flat_map(&:shellsplit)
end end


def options_file_as_erb_string(path) def options_file_as_erb_string(path)
Expand Down
4 changes: 3 additions & 1 deletion lib/rspec/core/example.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,5 @@
RSpec::Support.require_rspec_support 'ruby_features'

module RSpec module RSpec
module Core module Core
# Wrapper for an instance of a subclass of {ExampleGroup}. An instance of # Wrapper for an instance of a subclass of {ExampleGroup}. An instance of
Expand Down Expand Up @@ -294,7 +296,7 @@ def run(example_group_instance, reporter)
RSpec.current_example = nil RSpec.current_example = nil
end end


if RSpec::Support::Ruby.jruby? || RUBY_VERSION.to_f < 1.9 if RSpec::Support::Ruby.jruby?
# :nocov: # :nocov:
# For some reason, rescuing `Support::AllExceptionsExceptOnesWeMustNotRescue` # For some reason, rescuing `Support::AllExceptionsExceptOnesWeMustNotRescue`
# in place of `Exception` above can cause the exit status to be the wrong # in place of `Exception` above can cause the exit status to be the wrong
Expand Down
Loading