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

Ruby 2.7 support #2680

Merged
merged 6 commits into from
Dec 27, 2019
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
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 2019-12-18T14:01:38+00:00 from the rspec-dev repo.
# This file was generated on 2019-12-26T17:20:33+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
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2019-12-18T14:01:38+00:00 from the rspec-dev repo.
# This file was generated on 2019-12-26T17:20:33+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.

# In order to install old Rubies, we need to use old Ubuntu distibution.
Expand All @@ -22,9 +22,10 @@ rvm:
- 2.1
- 2.2.10
- 2.3.8
- 2.4.6
- 2.5.5
- 2.6.2
- 2.4.9
- 2.5.7
- 2.6.5
- 2.7.0
- ruby-head
- ree
- rbx-3
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2019-12-18T14:01:38+00:00 from the rspec-dev repo.
# This file was generated on 2019-12-26T17:20:33+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.

version: "{build}"
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/filter_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def file_scoped_include?(ex_metadata, ids, locations)

# @private
class FilterRules
PROC_HEX_NUMBER = /0x[0-9a-f]+@/
PROC_HEX_NUMBER = /0x[0-9a-f]+@?/
PROJECT_DIR = File.expand_path('.')

attr_accessor :opposite
Expand Down
5 changes: 2 additions & 3 deletions lib/rspec/core/option_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ def parse(source=nil)
begin
parser(options).parse!(args)
rescue OptionParser::InvalidOption => e
failure = e.message
failure << " (defined in #{source})" if source
abort "#{failure}\n\nPlease use --help for a listing of valid options"
abort "#{e.message}#{" (defined in #{source})" if source}\n\n" \
"Please use --help for a listing of valid options"
end

options[:files_or_directories_to_run] = args
Expand Down
2 changes: 1 addition & 1 deletion script/clone_all_rspec_repos
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# This file was generated on 2019-12-18T14:01:38+00:00 from the rspec-dev repo.
# This file was generated on 2019-12-26T17:20:33+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.

set -e
Expand Down
2 changes: 1 addition & 1 deletion script/functions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2019-12-18T14:01:38+00:00 from the rspec-dev repo.
# This file was generated on 2019-12-26T17:20:33+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.

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Expand Down
20 changes: 18 additions & 2 deletions script/predicate_functions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2019-12-18T14:01:38+00:00 from the rspec-dev repo.
# This file was generated on 2019-12-26T17:20:33+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.

function is_mri {
Expand Down Expand Up @@ -57,6 +57,18 @@ function is_mri_2plus {
fi
}

function is_mri_27 {
if is_mri; then
if ruby -e "exit(RUBY_VERSION.to_f == 2.7)"; then
return 0
else
return 1
fi
else
return 1
fi
}

function is_ruby_23_plus {
if ruby -e "exit(RUBY_VERSION.to_f >= 2.3)"; then
return 0
Expand Down Expand Up @@ -89,7 +101,11 @@ function additional_specs_available {
function documentation_enforced {
if [ -x ./bin/yard ]; then
if is_mri_2plus; then
return 0
if is_mri_27; then
return 1
else
return 0
fi
else
return 1
fi
Expand Down
2 changes: 1 addition & 1 deletion script/run_build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# This file was generated on 2019-12-18T14:01:38+00:00 from the rspec-dev repo.
# This file was generated on 2019-12-26T17:20:33+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.

set -e
Expand Down
2 changes: 1 addition & 1 deletion script/travis_functions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2019-12-18T14:01:38+00:00 from the rspec-dev repo.
# This file was generated on 2019-12-26T17:20:33+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.

# Taken from:
Expand Down
2 changes: 1 addition & 1 deletion script/update_rubygems_and_install_bundler
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# This file was generated on 2019-12-18T14:01:38+00:00 from the rspec-dev repo.
# This file was generated on 2019-12-26T17:20:33+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.

set -e
Expand Down
10 changes: 6 additions & 4 deletions spec/rspec/core/formatters/html_snippet_extractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ module Formatters
expect(RSpec::Core::Formatters::HtmlSnippetExtractor.new.lines_around("blech", 8)).to eq("# Couldn't get snippet for blech")
end

it "falls back on a default message when it gets a security error" do
message = with_safe_set_to_level_that_triggers_security_errors do
RSpec::Core::Formatters::HtmlSnippetExtractor.new.lines_around("blech".dup.taint, 8)
if RSpec::Support::RubyFeatures.supports_taint?
it "falls back on a default message when it gets a security error" do
message = with_safe_set_to_level_that_triggers_security_errors do
RSpec::Core::Formatters::HtmlSnippetExtractor.new.lines_around("blech".dup.taint, 8)
end
expect(message).to eq("# Couldn't get snippet for blech")
end
expect(message).to eq("# Couldn't get snippet for blech")
end

describe "snippet extraction" do
Expand Down
40 changes: 24 additions & 16 deletions spec/support/helper_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,32 @@ def ignoring_warnings
result
end

def with_safe_set_to_level_that_triggers_security_errors
result = nil
# In Ruby 2.7 taint was removed and has no effect, whilst SAFE warns that it
# has no effect and will become a normal varible in 3.0.
if RUBY_VERSION >= '2.7'
def with_safe_set_to_level_that_triggers_security_errors
yield
end
else
def with_safe_set_to_level_that_triggers_security_errors
result = nil

orig_safe = $SAFE
Thread.new do
ignoring_warnings { $SAFE = SAFE_LEVEL_THAT_TRIGGERS_SECURITY_ERRORS }
result = yield
end.join
orig_safe = $SAFE
Thread.new do
ignoring_warnings { $SAFE = SAFE_LEVEL_THAT_TRIGGERS_SECURITY_ERRORS }
result = yield
end.join

# $SAFE is not supported on Rubinius
# In Ruby 2.6, $SAFE became a global variable; previously it was local to a thread.
unless defined?(Rubinius) || SAFE_IS_GLOBAL_VARIABLE
# $SAFE should not have changed in this thread.
expect($SAFE).to eql orig_safe
end
# $SAFE is not supported on Rubinius
# In Ruby 2.6, $SAFE became a global variable; previously it was local to a thread.
unless defined?(Rubinius) || SAFE_IS_GLOBAL_VARIABLE
# $SAFE should not have changed in this thread.
expect($SAFE).to eql orig_safe
end

result
ensure
$SAFE = orig_safe if orig_safe && SAFE_IS_GLOBAL_VARIABLE
result
ensure
$SAFE = orig_safe if orig_safe && SAFE_IS_GLOBAL_VARIABLE
end
end
end