Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Ruby < 2.3 support #1231

Merged
merged 13 commits into from
Dec 12, 2020
Merged
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2020-12-08T09:53:27+00:00 from the rspec-dev repo.
# This file was generated on 2020-12-10T09:00:24+00:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

name: RSpec CI
Expand All @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
ruby:
- 3.0.0-preview1
- 3.0.0-preview2
- 2.7
- 2.6
- 2.5
Expand Down
2 changes: 1 addition & 1 deletion .rubocop_rspec_base.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2020-12-08T09:53:27+00:00 from the rspec-dev repo.
# This file was generated on 2020-12-10T09:00:24+00:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

# This file contains defaults for RSpec projects. Individual projects
Expand Down
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
### Development
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.10.0...main)

Breaking Changes:

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

Enhancements:

* Return `true` from `aggregate_failures` when no exception occurs. (Jon Rowe, #1225)
Expand Down
48 changes: 2 additions & 46 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ branch = File.read(File.expand_path("../maintenance-branch", __FILE__)).chomp
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']
gem 'diff-lcs', ENV['DIFF_LCS_VERSION']
else
Expand All @@ -37,50 +29,14 @@ end

gem 'simplecov'

if RUBY_VERSION < '2.0.0' || RUBY_ENGINE == 'java'
gem 'json', '< 2.0.0' # is a dependency of simplecov
else
gem 'json', '> 2.3.0'
end

# allow gems to be installed on older rubies and/or windows
if RUBY_VERSION < '2.2.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
gem 'ffi', '< 1.10'
elsif RUBY_VERSION < '1.9'
gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19
elsif RUBY_VERSION < '2.0'
gem 'ffi', '< 1.11.0' # ffi dropped Ruby 1.9 support in 1.11.0
else
gem 'ffi', '> 1.9.24' # prevent Github security vulnerability warning
end

# on windows
if !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
if RUBY_VERSION.to_f < 2.3
# Ruby 2.2,2.1 etc require this
gem "childprocess", "< 1.0.0"
end
end

if RUBY_VERSION < '1.9.2'
gem 'contracts', '~> 0.15.0' # is a dependency of aruba
end
gem 'ffi', '~> 1.12.0'

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

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

if RUBY_VERSION >= '2.4' && RUBY_ENGINE == 'ruby'
gem 'rubocop', "~> 0.52.1"
Expand Down
8 changes: 0 additions & 8 deletions Gemfile-custom.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@ group :development do
gem 'relish', '~> 0.6.0'
gem 'guard-rspec', '~> 1.2.1'
gem 'growl', '1.0.3'
gem 'spork', '0.9.0'

platform :mri do
gem 'rb-fsevent', '~> 0.9.0'
gem 'ruby-prof', '~> 0.10.0'

case RUBY_VERSION
when /^1.8/
gem 'ruby-debug'
when /^1.9/
gem 'debugger'
end
end
end
10 changes: 1 addition & 9 deletions cucumber.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
<%
def tags(tag)
tags = [tag]
tags << "~@ruby-1.9" if RUBY_VERSION.to_f < 1.9
tags.join(" --tags ")
end
%>

default: --require features --tags <%= tags("~@wip") %> --format progress
default: --require features --tags ~@wip --format progress
wip: --require features --tags @wip:3 --wip features
2 changes: 1 addition & 1 deletion features/built_in_matchers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ e.g.
expect([1, 2, 3]).to contain_exactly(2, 1, 3)
expect([1, 2, 3]).to match_array([3, 2, 1])

## Ranges (1.9+ only)
## Ranges

expect(1..10).to cover(3)

Expand Down
1 change: 0 additions & 1 deletion features/built_in_matchers/cover.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@ruby-1.9
Feature: `cover` matcher

Use the `cover` matcher to specify that a range covers one or more
Expand Down
5 changes: 0 additions & 5 deletions features/built_in_matchers/respond_to.feature
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ Feature: `respond_to` matcher
| expected 7 to respond to :between? with 7 arguments |
| expected 7 not to respond to :between? with 2 arguments |

@skip-when-splat-args-unsupported
Scenario: specify arguments range
Given a file named "respond_to_matcher_argument_range_checking_spec.rb" with:
"""ruby
Expand Down Expand Up @@ -127,7 +126,6 @@ Feature: `respond_to` matcher
| expected my_object to respond to :build with 2..3 arguments |
| expected my_object to respond to :build with 0..3 arguments |

@skip-when-splat-args-unsupported
Scenario: specify unlimited arguments
Given a file named "respond_to_matcher_unlimited_argument_checking_spec.rb" with:
"""ruby
Expand Down Expand Up @@ -164,7 +162,6 @@ Feature: `respond_to` matcher
| expected my_object to respond to :hail with unlimited arguments |
| expected my_object to respond to :hail with 1 argument and unlimited arguments |

@skip-when-keyword-args-unsupported
Scenario: specify keywords
Given a file named "respond_to_matcher_keyword_checking_spec.rb" with:
"""ruby
Expand Down Expand Up @@ -201,7 +198,6 @@ Feature: `respond_to` matcher
| expected my_object not to respond to :find with keywords :limit and :offset |
| expected my_object not to respond to :find with 1 argument and keywords :limit and :offset |

@skip-when-keyword-args-unsupported
Scenario: specify any keywords
Given a file named "respond_to_matcher_any_keywords_checking_spec.rb" with:
"""ruby
Expand Down Expand Up @@ -238,7 +234,6 @@ Feature: `respond_to` matcher
| expected my_object to respond to :create with any keywords |
| expected my_object to respond to :create with keyword :name and any keywords |

@skip-when-required-keyword-args-unsupported
Scenario: specify required keywords
Given a file named "respond_to_matcher_required_keyword_checking_spec.rb" with:
"""ruby
Expand Down
6 changes: 1 addition & 5 deletions features/step_definitions/additional_cli_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

Then /^the output should contain all of these:$/ do |table|
table.raw.flatten.each do |string|
if RUBY_VERSION == '1.8.7' && string =~ /\{.+=>.+\}/
warn "Skipping checking #{string} on 1.8.7 because hash ordering is not consistent"
else
expect(all_output).to include_output_string string
end
expect(all_output).to include_output_string string
end
end

Expand Down
30 changes: 0 additions & 30 deletions features/support/ruby_features.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
Around "@skip-when-splat-args-unsupported" do |scenario, block|
require 'rspec/support/ruby_features'

if ::RSpec::Support::RubyFeatures.optional_and_splat_args_supported?
block.call
else
warn "Skipping scenario #{scenario.title} because splat arguments are not supported"
end
end

Around "@skip-when-keyword-args-unsupported" do |scenario, block|
require 'rspec/support/ruby_features'

if ::RSpec::Support::RubyFeatures.kw_args_supported?
block.call
else
warn "Skipping scenario #{scenario.title} because keyword arguments are not supported"
end
end

Around "@skip-when-required-keyword-args-unsupported" do |scenario, block|
require 'rspec/support/ruby_features'

if ::RSpec::Support::RubyFeatures.required_kw_args_supported?
block.call
else
warn "Skipping scenario #{scenario.title} because required keyword arguments are not supported"
end
end

Around "@skip-when-ripper-unsupported" do |scenario, block|
require 'rspec/support/ruby_features'

Expand Down
3 changes: 1 addition & 2 deletions lib/rspec/expectations/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ def color?

# Adds `should` and `should_not` to the given classes
# or modules. This can be used to ensure `should` works
# properly on things like proxy objects (particular
# `Delegator`-subclassed objects on 1.8).
# properly on things like proxy objects.
#
# @param [Array<Module>] modules the list of classes or modules
# to add `should` and `should_not` to.
Expand Down
56 changes: 27 additions & 29 deletions lib/rspec/expectations/syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,33 +100,31 @@ def expect_enabled?(syntax_host=::RSpec::Matchers)
end
end

if defined?(BasicObject)
# The legacy `:should` syntax adds the following methods directly to
# `BasicObject` so that they are available off of any object. Note, however,
# that this syntax does not always play nice with delegate/proxy objects.
# We recommend you use the non-monkeypatching `:expect` syntax instead.
class BasicObject
# @method should(matcher, message)
# Passes if `matcher` returns true. Available on every `Object`.
# @example
# actual.should eq expected
# actual.should match /expression/
# @param [Matcher]
# matcher
# @param [String] message optional message to display when the expectation fails
# @return [Boolean] true if the expectation succeeds (else raises)
# @note This is only available when you have enabled the `:should` syntax.
# @see RSpec::Matchers

# @method should_not(matcher, message)
# Passes if `matcher` returns false. Available on every `Object`.
# @example
# actual.should_not eq expected
# @param [Matcher]
# matcher
# @param [String] message optional message to display when the expectation fails
# @return [Boolean] false if the negative expectation succeeds (else raises)
# @note This is only available when you have enabled the `:should` syntax.
# @see RSpec::Matchers
end
# The legacy `:should` syntax adds the following methods directly to
# `BasicObject` so that they are available off of any object. Note, however,
# that this syntax does not always play nice with delegate/proxy objects.
# We recommend you use the non-monkeypatching `:expect` syntax instead.
class BasicObject
# @method should(matcher, message)
# Passes if `matcher` returns true. Available on every `Object`.
# @example
# actual.should eq expected
# actual.should match /expression/
# @param [Matcher]
# matcher
# @param [String] message optional message to display when the expectation fails
# @return [Boolean] true if the expectation succeeds (else raises)
# @note This is only available when you have enabled the `:should` syntax.
# @see RSpec::Matchers

# @method should_not(matcher, message)
# Passes if `matcher` returns false. Available on every `Object`.
# @example
# actual.should_not eq expected
# @param [Matcher]
# matcher
# @param [String] message optional message to display when the expectation fails
# @return [Boolean] false if the negative expectation succeeds (else raises)
# @note This is only available when you have enabled the `:should` syntax.
# @see RSpec::Matchers
end
49 changes: 3 additions & 46 deletions lib/rspec/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ module RSpec
# best to find a more positive name for the negated form, such as
# `avoid_changing` rather than `not_change`.
#
module Matchers # rubocop:disable Metrics/ModuleLength
module Matchers
extend ::RSpec::Matchers::DSL

# @!macro [attach] alias_matcher
Expand Down Expand Up @@ -524,7 +524,6 @@ def contain_exactly(*items)
# expect(1..10).not_to cover(11)
# expect(1..10).not_to cover(5) # fails
#
# ### Warning:: Ruby >= 1.9 only
def cover(*values)
BuiltIn::Cover.new(*values)
end
Expand Down Expand Up @@ -967,18 +966,8 @@ def method_missing(method, *args, &block)
end
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)

if RUBY_VERSION.to_f >= 1.9
def respond_to_missing?(method, *)
method =~ DYNAMIC_MATCHER_REGEX || super
end
else # for 1.8.7
# :nocov:
def respond_to?(method, *)
method = method.to_s
method =~ DYNAMIC_MATCHER_REGEX || super
end
public :respond_to?
# :nocov:
def respond_to_missing?(method, *)
method =~ DYNAMIC_MATCHER_REGEX || super
end

# @api private
Expand All @@ -1005,37 +994,5 @@ def self.is_a_matcher?(obj)
def self.is_a_describable_matcher?(obj)
is_a_matcher?(obj) && obj.respond_to?(:description)
end

class << self
private

if RSpec::Support::Ruby.mri? && RUBY_VERSION[0, 3] == '1.9'
# Note that `included` doesn't work for this because it is triggered
# _after_ `RSpec::Matchers` is an ancestor of the inclusion host, rather
# than _before_, like `append_features`. It's important we check this before
# in order to find the cases where it was already previously included.
# @api private
def append_features(mod)
return super if mod < self # `mod < self` indicates a re-inclusion.

subclasses = ObjectSpace.each_object(Class).select { |c| c < mod && c < self }
return super unless subclasses.any?

subclasses.reject! { |s| subclasses.any? { |s2| s < s2 } } # Filter to the root ancestor.
subclasses = subclasses.map { |s| "`#{s}`" }.join(", ")

RSpec.warning "`#{self}` has been included in a superclass (`#{mod}`) " \
"after previously being included in subclasses (#{subclasses}), " \
"which can trigger infinite recursion from `super` due to an MRI 1.9 bug " \
"(https://redmine.ruby-lang.org/issues/3351). To work around this, " \
"either upgrade to MRI 2.0+, include a dup of the module (e.g. " \
"`include #{self}.dup`), or find a way to include `#{self}` in `#{mod}` " \
"before it is included in subclasses (#{subclasses}). See " \
"https://github.com/rspec/rspec-expectations/issues/814 for more info"

super
end
end
end
end
end
Loading