Fix Ruby 2.4 and Aruba 0.14.0 compatibility.

This commit is contained in:
Vít Ondruch 2017-01-31 16:44:22 +01:00
parent 98927e4576
commit 8d95aca46a
2 changed files with 123 additions and 4 deletions

View File

@ -0,0 +1,104 @@
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

View File

@ -3,7 +3,7 @@
%global rpmminorver .%(echo %preminorver | sed -e 's|^\\.\\.*||')
%global fullver %{majorver}%{?preminorver}
%global fedorarel 1
%global fedorarel 2
%global gem_name rspec-core
@ -28,6 +28,9 @@ Source0: http://rubygems.org/gems/%{gem_name}-%{fullver}.gem
# %%{SOURCE2} %%{name} %%{version}
Source1: rubygem-%{gem_name}-%{version}-full.tar.gz
Source2: rspec-related-create-full-tarball.sh
# Fix Ruby 2.4 compatibility.
# https://github.com/rspec/rspec-core/pull/2363
Patch0: rspec-core-3.5.4-Fixes-for-Ruby-2.4.patch
#BuildRequires: ruby(release)
BuildRequires: rubygems-devel
@ -79,6 +82,10 @@ gem unpack %{SOURCE0}
gem specification %{SOURCE0} -l --ruby > %{gem_name}.gemspec
pushd %{gem_name}-%{version}
%patch0 -p1
popd
%build
gem build %{gem_name}.gemspec
%gem_install
@ -121,9 +128,14 @@ for ((i = 0; i < ${#FAILFILE[@]}; i++)) {
${FAILFILE[$i]}
}
# FIXME
# Currently Fedora has aruba 0.6.2, however with aruba 0.14.0
# many tests fail.
# Fix compatibility with Aruba 0.14.0. Not sure if this is upstreamble, since
# it seems Aruba 0.7.0+ might have some Ruby 1.8.7 compatibility issues ...
sed -i 's/in_current_dir/cd(".")/' \
spec/{integration/{failed_line_detection,filtering,persistence_failures}_spec,support/aruba_support}.rb
sed -i 's/clean_current_dir/setup_aruba/' \
spec/integration/{failed_line_detection,filtering,persistence_failures,suite_hooks_errors}_spec.rb
sed -i 's/remove_file/remove/' spec/integration/order_spec.rb
ruby -rubygems -Ilib/ -S exe/rspec || \
ruby -rubygems -Ilib/ -S exe/rspec --tag ~broken
@ -149,6 +161,9 @@ popd
%{gem_docdir}
%changelog
* Tue Jan 31 2017 Vít Ondruch <vondruch@redhat.com> - 3.5.4-2
- Fix Ruby 2.4 and Aruba 0.14.0 compatibility.
* Mon Oct 10 2016 Mamoru TASAKA <mtasaka@fedoraproject.org> - 3.5.4-1
- 3.5.4