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

Commit 7329163

Browse files
authored
Merge pull request #2787 from rspec/drop-old-rubies
Drop Ruby < 2.3 support
2 parents e124e47 + f41dc2f commit 7329163

File tree

67 files changed

+364
-1009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+364
-1009
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
### Development
22

3+
Breaking Changes:
4+
5+
* Ruby < 2.3 is no longer supported. (Phil Pirozhkov, #2787)
6+
37
Enhancements:
48

59
* Improve pluralisation of words ending with `s` (like process). (Joshua Pinter, #2779)

Gemfile

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ branch = File.read(File.expand_path("../maintenance-branch", __FILE__)).chomp
1212
end
1313
end
1414

15-
if RUBY_VERSION < '1.9.3'
16-
gem 'rake', '< 11.0.0' # rake 11 requires Ruby 1.9.3 or later
17-
elsif RUBY_VERSION < '2.0.0'
18-
gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later
19-
else
20-
gem 'rake', '> 12.3.2'
21-
end
22-
2315
if ENV['DIFF_LCS_VERSION']
2416
gem 'diff-lcs', ENV['DIFF_LCS_VERSION']
2517
else
@@ -34,37 +26,10 @@ group :documentation do
3426
gem 'github-markup', :platform => :mri
3527
end
3628

37-
if RUBY_VERSION < '2.0.0' || RUBY_ENGINE == 'java'
38-
gem 'json', '< 2.0.0'
39-
else
40-
gem 'json', '> 2.3.0'
41-
end
29+
# Until 1.13.2 is released due to Rubygems usage
30+
gem 'ffi', '~> 1.12.0'
4231

43-
if RUBY_VERSION < '2.2.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
44-
gem 'ffi', '< 1.10'
45-
elsif RUBY_VERSION < '2.0'
46-
gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19
47-
elsif RUBY_VERSION < '2.3.0'
48-
gem 'ffi', '~> 1.12.0'
49-
else
50-
# Until 1.13.2 is released due to Rubygems usage
51-
gem 'ffi', '~> 1.12.0'
52-
end
53-
54-
if RUBY_VERSION < '2.3.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
55-
gem "childprocess", "< 1.0.0"
56-
end
57-
58-
platforms :jruby do
59-
if RUBY_VERSION < '1.9.0'
60-
# Pin jruby-openssl on older J Ruby
61-
gem "jruby-openssl", "< 0.10.0"
62-
# Pin child-process on older J Ruby
63-
gem "childprocess", "< 1.0.0"
64-
else
65-
gem "jruby-openssl"
66-
end
67-
end
32+
gem "jruby-openssl", platforms: :jruby
6833

6934
gem 'simplecov', '~> 0.8'
7035

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

76-
gem 'test-unit', '~> 3.0' if RUBY_VERSION.to_f >= 2.2
41+
gem 'test-unit', '~> 3.0'
7742

7843
# Version 5.12 of minitest requires Ruby 2.4
7944
if RUBY_VERSION < '2.4.0'
8045
gem 'minitest', '< 5.12.0'
8146
end
8247

83-
84-
gem 'contracts', '< 0.16' if RUBY_VERSION < '1.9.0'
85-
8648
eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')

Gemfile-custom.sample

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ group :development do
88
platform :mri do
99
gem 'rb-fsevent', '~> 0.9.0'
1010
gem 'ruby-prof', '~> 0.13.0'
11-
12-
case RUBY_VERSION
13-
when /^1.8/
14-
gem 'ruby-debug'
15-
when /^1.9/
16-
gem 'debugger'
17-
end
11+
gem 'pry-byebug'
1812
end
1913
end

cucumber.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
<%
2-
exclusions = []
3-
exclusions << ' --tags ~@no-jruby' if RUBY_PLATFORM == 'java'
4-
%>
5-
default: --require features --strict --format progress --tags ~@wip<%= exclusions.join %> features
1+
default: --require features --strict --format progress --tags ~@wip features
62
wip: --require features --tags @wip:30 --wip features

features/expectation_framework_integration/configure_expectation_framework.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ Feature: configure expectation framework
7272
"""
7373
And the output should contain "3 examples, 1 failure"
7474

75-
@broken-on-jruby-9000
7675
Scenario: Configure minitest assertions
7776
Given rspec-expectations is not installed
7877
And a file named "example_spec.rb" with:

features/step_definitions/additional_cli_steps.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,7 @@
232232

233233
module Normalization
234234
def normalize_failure_output(text)
235-
whitespace_normalized = text.lines.map { |line| line.sub(/\s+$/, '').sub(/:in .*$/, '') }.join
236-
237-
# 1.8.7 and JRuby produce slightly different output for `Hash#fetch` errors, so we
238-
# convert it to the same output here to match our expectation.
239-
whitespace_normalized.
240-
sub("IndexError", "KeyError").
241-
sub(/key not found.*$/, "key not found")
235+
text.lines.map { |line| line.sub(/\s+$/, '').sub(/:in .*$/, '') }.join
242236
end
243237
end
244238

features/step_definitions/core_standalone_steps.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
Given(/^only rspec-core is installed$/) do
2-
if RUBY_VERSION.to_f >= 1.9 # --disable-gems is invalid on 1.8.7
3-
# Ensure the gem versions of rspec-mocks and rspec-expectations
4-
# won't be loaded if available on the developers machine.
5-
set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + ' --disable-gems')
6-
end
2+
# Ensure the gem versions of rspec-mocks and rspec-expectations
3+
# won't be loaded if available on the developers machine.
4+
set_environment_variable('RUBYOPT', ENV['RUBYOPT'] + ' --disable-gems')
75

86
# This will make `require_expect_syntax_in_aruba_specs.rb` (loaded
97
# automatically when the specs run) remove rspec-mocks and

features/support/jruby.rb

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/rspec/core.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
warnings
1313

1414
set
15-
flat_map
1615
filter_manager
1716
dsl
1817
notifications
@@ -101,10 +100,9 @@ def self.configure
101100
# The example being executed.
102101
#
103102
# The primary audience for this method is library authors who need access
104-
# to the example currently being executed and also want to support all
105-
# versions of RSpec 2 and 3.
103+
# to the example currently being executed and also want to support RSpec 2.
106104
#
107-
# @example
105+
# @example support for RSpec version 2
108106
#
109107
# RSpec.configure do |c|
110108
# # context.example is deprecated, but RSpec.current_example is not

lib/rspec/core/bisect/shell_command.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
RSpec::Support.require_rspec_core "shell_escape"
2+
RSpec::Support.require_rspec_support 'ruby_features'
23
require 'shellwords'
34

45
module RSpec
@@ -63,6 +64,7 @@ def spec_opts_without_bisect
6364
private
6465

6566
include RSpec::Core::ShellEscape
67+
6668
# On JRuby, Open3.popen3 does not handle shellescaped args properly:
6769
# https://github.com/jruby/jruby/issues/2767
6870
if RSpec::Support::Ruby.jruby?

lib/rspec/core/bisect/shell_runner.rb

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,8 @@ def run_locations(*capture_args)
4141
end
4242
end
4343

44-
# `Open3.capture2e` does not work on JRuby:
45-
# https://github.com/jruby/jruby/issues/2766
46-
if Open3.respond_to?(:capture2e) && !RSpec::Support::Ruby.jruby?
47-
def run_command(cmd)
48-
Open3.capture2e(@shell_command.bisect_environment_hash, cmd).first
49-
end
50-
else # for 1.8.7
51-
# :nocov:
52-
def run_command(cmd)
53-
out = err = nil
54-
55-
original_spec_opts = ENV['SPEC_OPTS']
56-
ENV['SPEC_OPTS'] = @shell_command.spec_opts_without_bisect
57-
58-
Open3.popen3(cmd) do |_, stdout, stderr|
59-
# Reading the streams blocks until the process is complete
60-
out = stdout.read
61-
err = stderr.read
62-
end
63-
64-
"Stdout:\n#{out}\n\nStderr:\n#{err}"
65-
ensure
66-
ENV['SPEC_OPTS'] = original_spec_opts
67-
end
68-
# :nocov:
44+
def run_command(cmd)
45+
Open3.capture2e(@shell_command.bisect_environment_hash, cmd).first
6946
end
7047
end
7148
end

lib/rspec/core/configuration.rb

Lines changed: 48 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
RSpec::Support.require_rspec_core "ruby_project"
33
RSpec::Support.require_rspec_core "formatters/deprecation_formatter"
44
RSpec::Support.require_rspec_core "output_wrapper"
5+
RSpec::Support.require_rspec_support 'ruby_features'
56

67
module RSpec
78
module Core
@@ -842,8 +843,8 @@ def expect_with(*frameworks)
842843

843844
# Tag this exception class so our exception formatting logic knows
844845
# that it satisfies the `MultipleExceptionError` interface.
845-
::RSpec::Expectations::MultipleExpectationsNotMetError.__send__(
846-
:include, MultipleExceptionError::InterfaceTag
846+
::RSpec::Expectations::MultipleExpectationsNotMetError.include(
847+
MultipleExceptionError::InterfaceTag
847848
)
848849

849850
::RSpec::Matchers
@@ -1495,43 +1496,41 @@ def extend(mod, *filters)
14951496
end
14961497
end
14971498

1498-
if RSpec::Support::RubyFeatures.module_prepends_supported?
1499-
# Tells RSpec to prepend example groups with `mod`. Methods defined in
1500-
# `mod` are exposed to examples (not example groups). Use `filters` to
1501-
# constrain the groups in which to prepend the module.
1502-
#
1503-
# Similar to `include`, but module is included before the example group's class
1504-
# in the ancestor chain.
1505-
#
1506-
# @example
1507-
#
1508-
# module OverrideMod
1509-
# def override_me
1510-
# "overridden"
1511-
# end
1512-
# end
1513-
#
1514-
# RSpec.configure do |config|
1515-
# config.prepend(OverrideMod, :method => :prepend)
1516-
# end
1517-
#
1518-
# describe "overriding example's class", :method => :prepend do
1519-
# it "finds the user" do
1520-
# self.class.class_eval do
1521-
# def override_me
1522-
# end
1523-
# end
1524-
# override_me # => "overridden"
1525-
# # ...
1526-
# end
1527-
# end
1528-
#
1529-
# @see #include
1530-
# @see #extend
1531-
def prepend(mod, *filters)
1532-
define_mixed_in_module(mod, filters, @prepend_modules, :prepend) do |group|
1533-
safe_prepend(mod, group)
1534-
end
1499+
# Tells RSpec to prepend example groups with `mod`. Methods defined in
1500+
# `mod` are exposed to examples (not example groups). Use `filters` to
1501+
# constrain the groups in which to prepend the module.
1502+
#
1503+
# Similar to `include`, but module is included before the example group's class
1504+
# in the ancestor chain.
1505+
#
1506+
# @example
1507+
#
1508+
# module OverrideMod
1509+
# def override_me
1510+
# "overridden"
1511+
# end
1512+
# end
1513+
#
1514+
# RSpec.configure do |config|
1515+
# config.prepend(OverrideMod, :method => :prepend)
1516+
# end
1517+
#
1518+
# describe "overriding example's class", :method => :prepend do
1519+
# it "finds the user" do
1520+
# self.class.class_eval do
1521+
# def override_me
1522+
# end
1523+
# end
1524+
# override_me # => "overridden"
1525+
# # ...
1526+
# end
1527+
# end
1528+
#
1529+
# @see #include
1530+
# @see #extend
1531+
def prepend(mod, *filters)
1532+
define_mixed_in_module(mod, filters, @prepend_modules, :prepend) do |group|
1533+
safe_prepend(mod, group)
15351534
end
15361535
end
15371536

@@ -1586,14 +1585,14 @@ def in_project_source_dir_regex
15861585

15871586
# @private
15881587
def configure_mock_framework
1589-
RSpec::Core::ExampleGroup.__send__(:include, mock_framework)
1588+
RSpec::Core::ExampleGroup.include(mock_framework)
15901589
conditionally_disable_mocks_monkey_patching
15911590
end
15921591

15931592
# @private
15941593
def configure_expectation_framework
15951594
expectation_frameworks.each do |framework|
1596-
RSpec::Core::ExampleGroup.__send__(:include, framework)
1595+
RSpec::Core::ExampleGroup.include(framework)
15971596
end
15981597
conditionally_disable_expectations_monkey_patching
15991598
end
@@ -2155,7 +2154,7 @@ def run_suite_hooks(hook_description, hooks)
21552154
end
21562155

21572156
def get_files_to_run(paths)
2158-
files = FlatMap.flat_map(paths_to_check(paths)) do |path|
2157+
files = paths_to_check(paths).flat_map do |path|
21592158
path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
21602159
File.directory?(path) ? gather_directories(path) : extract_location(path)
21612160
end.uniq
@@ -2331,30 +2330,16 @@ def metadata_applies_to_group?(meta, group)
23312330
meta.empty? || MetadataFilter.apply?(:any?, meta, group.metadata)
23322331
end
23332332

2334-
if RSpec::Support::RubyFeatures.module_prepends_supported?
2335-
def safe_prepend(mod, host)
2336-
host.__send__(:prepend, mod) unless host < mod
2337-
end
2333+
def safe_prepend(mod, host)
2334+
host.prepend(mod) unless host < mod
23382335
end
23392336

2340-
if RUBY_VERSION.to_f >= 1.9
2341-
def safe_include(mod, host)
2342-
host.__send__(:include, mod) unless host < mod
2343-
end
2344-
2345-
def safe_extend(mod, host)
2346-
host.extend(mod) unless host.singleton_class < mod
2347-
end
2348-
else # for 1.8.7
2349-
# :nocov:
2350-
def safe_include(mod, host)
2351-
host.__send__(:include, mod) unless host.included_modules.include?(mod)
2352-
end
2337+
def safe_include(mod, host)
2338+
host.include(mod) unless host < mod
2339+
end
23532340

2354-
def safe_extend(mod, host)
2355-
host.extend(mod) unless (class << host; self; end).included_modules.include?(mod)
2356-
end
2357-
# :nocov:
2341+
def safe_extend(mod, host)
2342+
host.extend(mod) unless host.singleton_class < mod
23582343
end
23592344

23602345
def define_mixed_in_module(mod, filters, mod_list, config_method, &block)

lib/rspec/core/configuration_options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def parse_args_ignoring_files_or_dirs_to_run(args, source)
169169
def args_from_options_file(path)
170170
return [] unless path && File.exist?(path)
171171
config_string = options_file_as_erb_string(path)
172-
FlatMap.flat_map(config_string.split(/\n+/), &:shellsplit)
172+
config_string.split(/\n+/).flat_map(&:shellsplit)
173173
end
174174

175175
def options_file_as_erb_string(path)

lib/rspec/core/example.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
RSpec::Support.require_rspec_support 'ruby_features'
2+
13
module RSpec
24
module Core
35
# Wrapper for an instance of a subclass of {ExampleGroup}. An instance of
@@ -294,7 +296,7 @@ def run(example_group_instance, reporter)
294296
RSpec.current_example = nil
295297
end
296298

297-
if RSpec::Support::Ruby.jruby? || RUBY_VERSION.to_f < 1.9
299+
if RSpec::Support::Ruby.jruby?
298300
# :nocov:
299301
# For some reason, rescuing `Support::AllExceptionsExceptOnesWeMustNotRescue`
300302
# in place of `Exception` above can cause the exit status to be the wrong

0 commit comments

Comments
 (0)