rubygem-rspec-core/rspec-core-3.5.4-Fixes-for-Ruby-2.4.patch
2017-01-31 16:45:10 +01:00

105 lines
4.9 KiB
Diff

From c6b11177fcd951380fa1d267944681bf08044aac Mon Sep 17 00:00:00 2001
From: Myron Marston <myron.marston@gmail.com>
Date: Mon, 26 Dec 2016 10:19:31 -0800
Subject: [PATCH 1/2] Change example of invalid option to `--foo_bar`.
`--default_path` seems to be interpretted as `--default-path`
on Ruby 2.4, which is valid.
---
spec/rspec/core/configuration_options_spec.rb | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/spec/rspec/core/configuration_options_spec.rb b/spec/rspec/core/configuration_options_spec.rb
index f170192..7004bed 100644
--- a/spec/rspec/core/configuration_options_spec.rb
+++ b/spec/rspec/core/configuration_options_spec.rb
@@ -395,7 +395,7 @@ def expect_parsing_to_fail_mentioning_source(source, options=[])
expect {
parse_options(*options)
}.to raise_error(SystemExit).and output(a_string_including(
- "invalid option: --default_path (defined in #{source})",
+ "invalid option: --foo_bar (defined in #{source})",
"Please use --help for a listing of valid options"
)).to_stderr
end
@@ -404,7 +404,7 @@ def expect_parsing_to_fail_mentioning_source(source, options=[])
context "defined in #{file_name}" do
it "mentions the file name in the error so users know where to look for it" do
file_name = File.expand_path(file_name) if file_name.start_with?("~")
- File.open(File.expand_path(file_name), "w") { |f| f << "--default_path" }
+ File.open(File.expand_path(file_name), "w") { |f| f << "--foo_bar" }
expect_parsing_to_fail_mentioning_source(file_name)
end
end
@@ -412,7 +412,7 @@ def expect_parsing_to_fail_mentioning_source(source, options=[])
context "defined in SPEC_OPTS" do
it "mentions ENV['SPEC_OPTS'] as the source in the error so users know where to look for it" do
- with_env_vars 'SPEC_OPTS' => "--default_path" do
+ with_env_vars 'SPEC_OPTS' => "--foo_bar" do
expect_parsing_to_fail_mentioning_source("ENV['SPEC_OPTS']")
end
end
@@ -420,7 +420,7 @@ def expect_parsing_to_fail_mentioning_source(source, options=[])
context "defined in a custom file" do
it "mentions the custom file as the source of the error so users know where to look for it" do
- File.open("./custom.opts", "w") {|f| f << "--default_path"}
+ File.open("./custom.opts", "w") {|f| f << "--foo_bar"}
expect_parsing_to_fail_mentioning_source("./custom.opts", %w[-O ./custom.opts])
end
@@ -428,9 +428,9 @@ def expect_parsing_to_fail_mentioning_source(source, options=[])
context "passed at the command line" do
it "does not mention the source since it is obvious where it came from" do
expect {
- parse_options("--default_path")
+ parse_options("--foo_bar")
}.to raise_error(SystemExit).and output(a_string_including(
- "invalid option: --default_path\n",
+ "invalid option: --foo_bar\n",
"Please use --help for a listing of valid options"
)).to_stderr
end
From dba6b95888f79ce5a24bf986bfb5d31385f71bb9 Mon Sep 17 00:00:00 2001
From: Myron Marston <myron.marston@gmail.com>
Date: Mon, 26 Dec 2016 10:24:06 -0800
Subject: [PATCH 2/2] Exclude spec on Ruby 2.4 that fails and is not needed.
---
lib/rspec/core/configuration_options.rb | 2 ++
spec/rspec/core/configuration_options_spec.rb | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/rspec/core/configuration_options.rb b/lib/rspec/core/configuration_options.rb
index f46df2f..1b93e8c 100644
--- a/lib/rspec/core/configuration_options.rb
+++ b/lib/rspec/core/configuration_options.rb
@@ -186,8 +186,10 @@ def local_options_file
def global_options_file
File.join(File.expand_path("~"), ".rspec")
rescue ArgumentError
+ # :nocov:
RSpec.warning "Unable to find ~/.rspec because the HOME environment variable is not set"
nil
+ # :nocov:
end
end
end
diff --git a/spec/rspec/core/configuration_options_spec.rb b/spec/rspec/core/configuration_options_spec.rb
index 7004bed..af3f6d4 100644
--- a/spec/rspec/core/configuration_options_spec.rb
+++ b/spec/rspec/core/configuration_options_spec.rb
@@ -4,7 +4,9 @@
RSpec.describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolated_home => true do
include ConfigOptionsHelper
- it "warns when HOME env var is not set", :unless => (RUBY_PLATFORM == 'java' || RSpec::Support::OS.windows?) do
+ # On Ruby 2.4, `File.expand("~")` works even if `ENV['HOME']` is not set.
+ # But on earlier versions, it fails.
+ it "warns when HOME env var is not set", :unless => (RUBY_PLATFORM == 'java' || RSpec::Support::OS.windows? || RUBY_VERSION >= '2.4') do
without_env_vars 'HOME' do
expect_warning_with_call_site(__FILE__, __LINE__ + 1)
RSpec::Core::ConfigurationOptions.new([]).options