Fix Ruby 2.4 compatibility.
This commit is contained in:
parent
db74cf1175
commit
0ed82e40f1
@ -0,0 +1,515 @@
|
|||||||
|
From 2b04f95cf585720f80da56c2785bee65812f15a0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Myron Marston <myron.marston@gmail.com>
|
||||||
|
Date: Mon, 26 Dec 2016 23:03:53 -0800
|
||||||
|
Subject: [PATCH] Address Fixnum changes in Ruby 2.4.
|
||||||
|
|
||||||
|
---
|
||||||
|
README.md | 4 +-
|
||||||
|
features/built_in_matchers/README.md | 2 +-
|
||||||
|
features/built_in_matchers/predicates.feature | 4 +-
|
||||||
|
features/built_in_matchers/types.feature | 68 +++++++++++-----------
|
||||||
|
features/built_in_matchers/yield.feature | 4 +-
|
||||||
|
features/composing_matchers.feature | 4 +-
|
||||||
|
lib/rspec/matchers.rb | 16 ++---
|
||||||
|
spec/rspec/expectations/expectation_target_spec.rb | 8 +--
|
||||||
|
.../rspec/matchers/built_in/be_instance_of_spec.rb | 10 ++--
|
||||||
|
spec/rspec/matchers/built_in/be_kind_of_spec.rb | 4 +-
|
||||||
|
spec/rspec/matchers/built_in/be_spec.rb | 2 +-
|
||||||
|
spec/rspec/matchers/built_in/change_spec.rb | 10 ++--
|
||||||
|
spec/rspec/matchers/built_in/compound_spec.rb | 4 +-
|
||||||
|
spec/rspec/matchers/built_in/yield_spec.rb | 16 ++---
|
||||||
|
spec/rspec/matchers/dsl_spec.rb | 12 ++--
|
||||||
|
15 files changed, 84 insertions(+), 84 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/README.md b/README.md
|
||||||
|
index ed55085..d7c4b34 100644
|
||||||
|
--- a/README.md
|
||||||
|
+++ b/README.md
|
||||||
|
@@ -150,7 +150,7 @@ expect { |b| 5.tap(&b) }.to yield_control # passes regardless of yielded args
|
||||||
|
expect { |b| yield_if_true(true, &b) }.to yield_with_no_args # passes only if no args are yielded
|
||||||
|
|
||||||
|
expect { |b| 5.tap(&b) }.to yield_with_args(5)
|
||||||
|
-expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum)
|
||||||
|
+expect { |b| 5.tap(&b) }.to yield_with_args(Integer)
|
||||||
|
expect { |b| "a string".tap(&b) }.to yield_with_args(/str/)
|
||||||
|
|
||||||
|
expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3)
|
||||||
|
@@ -263,7 +263,7 @@ expect(hash).to match(
|
||||||
|
:a => {
|
||||||
|
:b => a_collection_containing_exactly(
|
||||||
|
a_string_starting_with("f"),
|
||||||
|
- an_instance_of(Fixnum)
|
||||||
|
+ an_instance_of(Integer)
|
||||||
|
),
|
||||||
|
:c => { :d => (a_value < 3) }
|
||||||
|
}
|
||||||
|
diff --git a/features/built_in_matchers/README.md b/features/built_in_matchers/README.md
|
||||||
|
index 29cb8a6..df555a0 100644
|
||||||
|
--- a/features/built_in_matchers/README.md
|
||||||
|
+++ b/features/built_in_matchers/README.md
|
||||||
|
@@ -133,5 +133,5 @@ e.g.
|
||||||
|
expect { |b| User.transaction(&b) }.to yield_with_no_args
|
||||||
|
expect { |b| 5.tap(&b) }.not_to yield_with_no_args # because it yields with `5`
|
||||||
|
expect { |b| 5.tap(&b) }.to yield_with_args(5) # because 5 == 5
|
||||||
|
- expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum) # because Fixnum === 5
|
||||||
|
+ expect { |b| 5.tap(&b) }.to yield_with_args(Integer) # because Integer === 5
|
||||||
|
expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3)
|
||||||
|
diff --git a/features/built_in_matchers/predicates.feature b/features/built_in_matchers/predicates.feature
|
||||||
|
index 64061bd..e417bdf 100644
|
||||||
|
--- a/features/built_in_matchers/predicates.feature
|
||||||
|
+++ b/features/built_in_matchers/predicates.feature
|
||||||
|
@@ -47,7 +47,7 @@ Feature: Predicate matchers
|
||||||
|
|
||||||
|
Any arguments passed to the matcher will be passed on to the predicate method.
|
||||||
|
|
||||||
|
- Scenario: should be_zero (based on Fixnum#zero?)
|
||||||
|
+ Scenario: should be_zero (based on Integer#zero?)
|
||||||
|
Given a file named "should_be_zero_spec.rb" with:
|
||||||
|
"""ruby
|
||||||
|
RSpec.describe 0 do
|
||||||
|
@@ -118,7 +118,7 @@ Feature: Predicate matchers
|
||||||
|
Scenario: matcher arguments are passed on to the predicate method
|
||||||
|
Given a file named "predicate_matcher_argument_spec.rb" with:
|
||||||
|
"""ruby
|
||||||
|
- class Fixnum
|
||||||
|
+ class Integer
|
||||||
|
def multiple_of?(x)
|
||||||
|
(self % x).zero?
|
||||||
|
end
|
||||||
|
diff --git a/features/built_in_matchers/types.feature b/features/built_in_matchers/types.feature
|
||||||
|
index 8a56571..9204609 100644
|
||||||
|
--- a/features/built_in_matchers/types.feature
|
||||||
|
+++ b/features/built_in_matchers/types.feature
|
||||||
|
@@ -22,20 +22,20 @@ Feature: Type matchers
|
||||||
|
"""ruby
|
||||||
|
module MyModule; end
|
||||||
|
|
||||||
|
- class Fixnum
|
||||||
|
+ class Float
|
||||||
|
include MyModule
|
||||||
|
end
|
||||||
|
|
||||||
|
- RSpec.describe 17 do
|
||||||
|
+ RSpec.describe 17.0 do
|
||||||
|
# the actual class
|
||||||
|
- it { is_expected.to be_kind_of(Fixnum) }
|
||||||
|
- it { is_expected.to be_a_kind_of(Fixnum) }
|
||||||
|
- it { is_expected.to be_a(Fixnum) }
|
||||||
|
+ it { is_expected.to be_kind_of(Float) }
|
||||||
|
+ it { is_expected.to be_a_kind_of(Float) }
|
||||||
|
+ it { is_expected.to be_a(Float) }
|
||||||
|
|
||||||
|
# the superclass
|
||||||
|
- it { is_expected.to be_kind_of(Integer) }
|
||||||
|
- it { is_expected.to be_a_kind_of(Integer) }
|
||||||
|
- it { is_expected.to be_an(Integer) }
|
||||||
|
+ it { is_expected.to be_kind_of(Numeric) }
|
||||||
|
+ it { is_expected.to be_a_kind_of(Numeric) }
|
||||||
|
+ it { is_expected.to be_an(Numeric) }
|
||||||
|
|
||||||
|
# an included module
|
||||||
|
it { is_expected.to be_kind_of(MyModule) }
|
||||||
|
@@ -48,12 +48,12 @@ Feature: Type matchers
|
||||||
|
it { is_expected.not_to be_a(String) }
|
||||||
|
|
||||||
|
# deliberate failures
|
||||||
|
- it { is_expected.not_to be_kind_of(Fixnum) }
|
||||||
|
- it { is_expected.not_to be_a_kind_of(Fixnum) }
|
||||||
|
- it { is_expected.not_to be_a(Fixnum) }
|
||||||
|
- it { is_expected.not_to be_kind_of(Integer) }
|
||||||
|
- it { is_expected.not_to be_a_kind_of(Integer) }
|
||||||
|
- it { is_expected.not_to be_an(Integer) }
|
||||||
|
+ it { is_expected.not_to be_kind_of(Float) }
|
||||||
|
+ it { is_expected.not_to be_a_kind_of(Float) }
|
||||||
|
+ it { is_expected.not_to be_a(Float) }
|
||||||
|
+ it { is_expected.not_to be_kind_of(Numeric) }
|
||||||
|
+ it { is_expected.not_to be_a_kind_of(Numeric) }
|
||||||
|
+ it { is_expected.not_to be_an(Numeric) }
|
||||||
|
it { is_expected.not_to be_kind_of(MyModule) }
|
||||||
|
it { is_expected.not_to be_a_kind_of(MyModule) }
|
||||||
|
it { is_expected.not_to be_a(MyModule) }
|
||||||
|
@@ -64,29 +64,29 @@ Feature: Type matchers
|
||||||
|
"""
|
||||||
|
When I run `rspec be_kind_of_matcher_spec.rb`
|
||||||
|
Then the output should contain all of these:
|
||||||
|
- | 24 examples, 12 failures |
|
||||||
|
- | expected 17 not to be a kind of Fixnum |
|
||||||
|
- | expected 17 not to be a kind of Integer |
|
||||||
|
- | expected 17 not to be a kind of MyModule |
|
||||||
|
- | expected 17 to be a kind of String |
|
||||||
|
+ | 24 examples, 12 failures |
|
||||||
|
+ | expected 17.0 not to be a kind of Float |
|
||||||
|
+ | expected 17.0 not to be a kind of Numeric |
|
||||||
|
+ | expected 17.0 not to be a kind of MyModule |
|
||||||
|
+ | expected 17.0 to be a kind of String |
|
||||||
|
|
||||||
|
Scenario: be_(an_)instance_of matcher
|
||||||
|
Given a file named "be_instance_of_matcher_spec.rb" with:
|
||||||
|
"""ruby
|
||||||
|
module MyModule; end
|
||||||
|
|
||||||
|
- class Fixnum
|
||||||
|
+ class Float
|
||||||
|
include MyModule
|
||||||
|
end
|
||||||
|
|
||||||
|
- RSpec.describe 17 do
|
||||||
|
+ RSpec.describe 17.0 do
|
||||||
|
# the actual class
|
||||||
|
- it { is_expected.to be_instance_of(Fixnum) }
|
||||||
|
- it { is_expected.to be_an_instance_of(Fixnum) }
|
||||||
|
+ it { is_expected.to be_instance_of(Float) }
|
||||||
|
+ it { is_expected.to be_an_instance_of(Float) }
|
||||||
|
|
||||||
|
# the superclass
|
||||||
|
- it { is_expected.not_to be_instance_of(Integer) }
|
||||||
|
- it { is_expected.not_to be_an_instance_of(Integer) }
|
||||||
|
+ it { is_expected.not_to be_instance_of(Numeric) }
|
||||||
|
+ it { is_expected.not_to be_an_instance_of(Numeric) }
|
||||||
|
|
||||||
|
# an included module
|
||||||
|
it { is_expected.not_to be_instance_of(MyModule) }
|
||||||
|
@@ -97,10 +97,10 @@ Feature: Type matchers
|
||||||
|
it { is_expected.not_to be_an_instance_of(String) }
|
||||||
|
|
||||||
|
# deliberate failures
|
||||||
|
- it { is_expected.not_to be_instance_of(Fixnum) }
|
||||||
|
- it { is_expected.not_to be_an_instance_of(Fixnum) }
|
||||||
|
- it { is_expected.to be_instance_of(Integer) }
|
||||||
|
- it { is_expected.to be_an_instance_of(Integer) }
|
||||||
|
+ it { is_expected.not_to be_instance_of(Float) }
|
||||||
|
+ it { is_expected.not_to be_an_instance_of(Float) }
|
||||||
|
+ it { is_expected.to be_instance_of(Numeric) }
|
||||||
|
+ it { is_expected.to be_an_instance_of(Numeric) }
|
||||||
|
it { is_expected.to be_instance_of(MyModule) }
|
||||||
|
it { is_expected.to be_an_instance_of(MyModule) }
|
||||||
|
it { is_expected.to be_instance_of(String) }
|
||||||
|
@@ -109,8 +109,8 @@ Feature: Type matchers
|
||||||
|
"""
|
||||||
|
When I run `rspec be_instance_of_matcher_spec.rb`
|
||||||
|
Then the output should contain all of these:
|
||||||
|
- | 16 examples, 8 failures |
|
||||||
|
- | expected 17 not to be an instance of Fixnum |
|
||||||
|
- | expected 17 to be an instance of Integer |
|
||||||
|
- | expected 17 to be an instance of MyModule |
|
||||||
|
- | expected 17 to be an instance of String |
|
||||||
|
+ | 16 examples, 8 failures |
|
||||||
|
+ | expected 17.0 not to be an instance of Float |
|
||||||
|
+ | expected 17.0 to be an instance of Numeric |
|
||||||
|
+ | expected 17.0 to be an instance of MyModule |
|
||||||
|
+ | expected 17.0 to be an instance of String |
|
||||||
|
diff --git a/features/built_in_matchers/yield.feature b/features/built_in_matchers/yield.feature
|
||||||
|
index 1abb8fb..ab2b3e0 100644
|
||||||
|
--- a/features/built_in_matchers/yield.feature
|
||||||
|
+++ b/features/built_in_matchers/yield.feature
|
||||||
|
@@ -139,13 +139,13 @@ Feature: `yield` matchers
|
||||||
|
RSpec.describe "yield_successive_args matcher" do
|
||||||
|
specify { expect { |b| array.each(&b) }.to yield_successive_args(1, 2, 3) }
|
||||||
|
specify { expect { |b| array_of_tuples.each(&b) }.to yield_successive_args([:a, :b], [:c, :d]) }
|
||||||
|
- specify { expect { |b| array.each(&b) }.to yield_successive_args(Fixnum, Fixnum, Fixnum) }
|
||||||
|
+ specify { expect { |b| array.each(&b) }.to yield_successive_args(Integer, Integer, Integer) }
|
||||||
|
specify { expect { |b| array.each(&b) }.not_to yield_successive_args(1, 2) }
|
||||||
|
|
||||||
|
# deliberate failures
|
||||||
|
specify { expect { |b| array.each(&b) }.not_to yield_successive_args(1, 2, 3) }
|
||||||
|
specify { expect { |b| array_of_tuples.each(&b) }.not_to yield_successive_args([:a, :b], [:c, :d]) }
|
||||||
|
- specify { expect { |b| array.each(&b) }.not_to yield_successive_args(Fixnum, Fixnum, Fixnum) }
|
||||||
|
+ specify { expect { |b| array.each(&b) }.not_to yield_successive_args(Integer, Integer, Integer) }
|
||||||
|
specify { expect { |b| array.each(&b) }.to yield_successive_args(1, 2) }
|
||||||
|
end
|
||||||
|
"""
|
||||||
|
diff --git a/features/composing_matchers.feature b/features/composing_matchers.feature
|
||||||
|
index aa32799..a5f96bb 100644
|
||||||
|
--- a/features/composing_matchers.feature
|
||||||
|
+++ b/features/composing_matchers.feature
|
||||||
|
@@ -122,7 +122,7 @@ Feature: Composing Matchers
|
||||||
|
specify "you can match nested data structures against matchers" do
|
||||||
|
hash = {
|
||||||
|
:a => {
|
||||||
|
- :b => ["foo", 5],
|
||||||
|
+ :b => ["foo", 5.0],
|
||||||
|
:c => { :d => 2.05 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -131,7 +131,7 @@ Feature: Composing Matchers
|
||||||
|
:a => {
|
||||||
|
:b => a_collection_containing_exactly(
|
||||||
|
a_string_starting_with("f"),
|
||||||
|
- an_instance_of(Fixnum)
|
||||||
|
+ an_instance_of(Float)
|
||||||
|
),
|
||||||
|
:c => { :d => (a_value < 3) }
|
||||||
|
}
|
||||||
|
diff --git a/lib/rspec/matchers.rb b/lib/rspec/matchers.rb
|
||||||
|
index 27bd40f..b644b6f 100644
|
||||||
|
--- a/lib/rspec/matchers.rb
|
||||||
|
+++ b/lib/rspec/matchers.rb
|
||||||
|
@@ -41,9 +41,9 @@ module RSpec
|
||||||
|
#
|
||||||
|
# expect("a string").to be_an_instance_of(String) # =>"a string".instance_of?(String) # passes
|
||||||
|
#
|
||||||
|
- # expect(3).to be_a_kind_of(Fixnum) # => 3.kind_of?(Numeric) | passes
|
||||||
|
- # expect(3).to be_a_kind_of(Numeric) # => 3.kind_of?(Numeric) | passes
|
||||||
|
- # expect(3).to be_an_instance_of(Fixnum) # => 3.instance_of?(Fixnum) | passes
|
||||||
|
+ # expect(3).to be_a_kind_of(Integer) # => 3.kind_of?(Numeric) | passes
|
||||||
|
+ # expect(3).to be_a_kind_of(Numeric) # => 3.kind_of?(Numeric) | passes
|
||||||
|
+ # expect(3).to be_an_instance_of(Integer) # => 3.instance_of?(Integer) | passes
|
||||||
|
# expect(3).not_to be_an_instance_of(Numeric) # => 3.instance_of?(Numeric) | fails
|
||||||
|
#
|
||||||
|
# RSpec will also create custom matchers for predicates like `has_key?`. To
|
||||||
|
@@ -367,7 +367,7 @@ def be_a(klass)
|
||||||
|
# Passes if actual.instance_of?(expected)
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
- # expect(5).to be_an_instance_of(Fixnum)
|
||||||
|
+ # expect(5).to be_an_instance_of(Integer)
|
||||||
|
# expect(5).not_to be_an_instance_of(Numeric)
|
||||||
|
# expect(5).not_to be_an_instance_of(Float)
|
||||||
|
def be_an_instance_of(expected)
|
||||||
|
@@ -379,7 +379,7 @@ def be_an_instance_of(expected)
|
||||||
|
# Passes if actual.kind_of?(expected)
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
- # expect(5).to be_a_kind_of(Fixnum)
|
||||||
|
+ # expect(5).to be_a_kind_of(Integer)
|
||||||
|
# expect(5).to be_a_kind_of(Numeric)
|
||||||
|
# expect(5).not_to be_a_kind_of(Float)
|
||||||
|
def be_a_kind_of(expected)
|
||||||
|
@@ -585,7 +585,7 @@ def eql(expected)
|
||||||
|
# information about equality in Ruby.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
- # expect(5).to equal(5) # Fixnums are equal
|
||||||
|
+ # expect(5).to equal(5) # Integers are equal
|
||||||
|
# expect("5").not_to equal("5") # Strings that look the same are not the same object
|
||||||
|
def equal(expected)
|
||||||
|
BuiltIn::Equal.new(expected)
|
||||||
|
@@ -688,7 +688,7 @@ def all(expected)
|
||||||
|
# :a => {
|
||||||
|
# :b => a_collection_containing_exactly(
|
||||||
|
# a_string_starting_with("f"),
|
||||||
|
- # an_instance_of(Fixnum)
|
||||||
|
+ # an_instance_of(Integer)
|
||||||
|
# ),
|
||||||
|
# :c => { :d => (a_value < 3) }
|
||||||
|
# }
|
||||||
|
@@ -905,7 +905,7 @@ def yield_with_no_args
|
||||||
|
# @example
|
||||||
|
# expect { |b| 5.tap(&b) }.to yield_with_args # because #tap yields an arg
|
||||||
|
# expect { |b| 5.tap(&b) }.to yield_with_args(5) # because 5 == 5
|
||||||
|
- # expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum) # because Fixnum === 5
|
||||||
|
+ # expect { |b| 5.tap(&b) }.to yield_with_args(Integer) # because Integer === 5
|
||||||
|
# expect { |b| File.open("f.txt", &b) }.to yield_with_args(/txt/) # because /txt/ === "f.txt"
|
||||||
|
#
|
||||||
|
# expect { |b| User.transaction(&b) }.not_to yield_with_args # because it yields no args
|
||||||
|
diff --git a/spec/rspec/expectations/expectation_target_spec.rb b/spec/rspec/expectations/expectation_target_spec.rb
|
||||||
|
index 7d0c7f9..84d5ff1 100644
|
||||||
|
--- a/spec/rspec/expectations/expectation_target_spec.rb
|
||||||
|
+++ b/spec/rspec/expectations/expectation_target_spec.rb
|
||||||
|
@@ -52,16 +52,16 @@ module Expectations
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'fails an invalid negative expectation' do
|
||||||
|
- message = /expected 5 not to be a kind of Fixnum/
|
||||||
|
+ message = /expected 5 not to be a kind of Integer/
|
||||||
|
expect {
|
||||||
|
- expect(5).not_to be_a(Fixnum)
|
||||||
|
+ expect(5).not_to be_an(Integer)
|
||||||
|
}.to fail_with(message)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'fails an invalid negative expectation with a split infinitive' do
|
||||||
|
- message = /expected 5 not to be a kind of Fixnum/
|
||||||
|
+ message = /expected 5 not to be a kind of Integer/
|
||||||
|
expect {
|
||||||
|
- expect(5).to_not be_a(Fixnum)
|
||||||
|
+ expect(5).to_not be_an(Integer)
|
||||||
|
}.to fail_with(message)
|
||||||
|
end
|
||||||
|
|
||||||
|
diff --git a/spec/rspec/matchers/built_in/be_instance_of_spec.rb b/spec/rspec/matchers/built_in/be_instance_of_spec.rb
|
||||||
|
index f198acc..c739bee 100644
|
||||||
|
--- a/spec/rspec/matchers/built_in/be_instance_of_spec.rb
|
||||||
|
+++ b/spec/rspec/matchers/built_in/be_instance_of_spec.rb
|
||||||
|
@@ -2,12 +2,12 @@ module RSpec
|
||||||
|
module Matchers
|
||||||
|
[:be_an_instance_of, :be_instance_of].each do |method|
|
||||||
|
RSpec.describe "expect(actual).to #{method}(expected)" do
|
||||||
|
- it_behaves_like "an RSpec matcher", :valid_value => 5, :invalid_value => "a" do
|
||||||
|
- let(:matcher) { send(method, Fixnum) }
|
||||||
|
+ it_behaves_like "an RSpec matcher", :valid_value => "a", :invalid_value => 5 do
|
||||||
|
+ let(:matcher) { send(method, String) }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "passes if actual is instance of expected class" do
|
||||||
|
- expect(5).to send(method, Fixnum)
|
||||||
|
+ expect("a").to send(method, String)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails if actual is instance of subclass of expected class" do
|
||||||
|
@@ -23,9 +23,9 @@ module Matchers
|
||||||
|
end
|
||||||
|
|
||||||
|
it "provides a description" do
|
||||||
|
- matcher = be_an_instance_of(Fixnum)
|
||||||
|
+ matcher = be_an_instance_of(Integer)
|
||||||
|
matcher.matches?(Numeric)
|
||||||
|
- expect(matcher.description).to eq "be an instance of Fixnum"
|
||||||
|
+ expect(matcher.description).to eq "be an instance of Integer"
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when expected provides an expanded inspect, e.g. AR::Base" do
|
||||||
|
diff --git a/spec/rspec/matchers/built_in/be_kind_of_spec.rb b/spec/rspec/matchers/built_in/be_kind_of_spec.rb
|
||||||
|
index 51bc227..cfd8504 100644
|
||||||
|
--- a/spec/rspec/matchers/built_in/be_kind_of_spec.rb
|
||||||
|
+++ b/spec/rspec/matchers/built_in/be_kind_of_spec.rb
|
||||||
|
@@ -3,11 +3,11 @@ module Matchers
|
||||||
|
[:be_a_kind_of, :be_kind_of].each do |method|
|
||||||
|
RSpec.describe "expect(actual).to #{method}(expected)" do
|
||||||
|
it_behaves_like "an RSpec matcher", :valid_value => 5, :invalid_value => "a" do
|
||||||
|
- let(:matcher) { send(method, Fixnum) }
|
||||||
|
+ let(:matcher) { send(method, Integer) }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "passes if actual is instance of expected class" do
|
||||||
|
- expect(5).to send(method, Fixnum)
|
||||||
|
+ expect("string").to send(method, String)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "passes if actual is instance of subclass of expected class" do
|
||||||
|
diff --git a/spec/rspec/matchers/built_in/be_spec.rb b/spec/rspec/matchers/built_in/be_spec.rb
|
||||||
|
index c1040b9..eaa8bff 100644
|
||||||
|
--- a/spec/rspec/matchers/built_in/be_spec.rb
|
||||||
|
+++ b/spec/rspec/matchers/built_in/be_spec.rb
|
||||||
|
@@ -770,7 +770,7 @@ def large?
|
||||||
|
|
||||||
|
RSpec.describe "be_an_instance_of" do
|
||||||
|
it "passes when direct class matches" do
|
||||||
|
- expect(5).to be_an_instance_of(Fixnum)
|
||||||
|
+ expect("string").to be_an_instance_of(String)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails when class is higher up hierarchy" do
|
||||||
|
diff --git a/spec/rspec/matchers/built_in/change_spec.rb b/spec/rspec/matchers/built_in/change_spec.rb
|
||||||
|
index fc40f5d..e2e873e 100644
|
||||||
|
--- a/spec/rspec/matchers/built_in/change_spec.rb
|
||||||
|
+++ b/spec/rspec/matchers/built_in/change_spec.rb
|
||||||
|
@@ -28,14 +28,14 @@ class SomethingExpected
|
||||||
|
val = nil
|
||||||
|
|
||||||
|
expect {
|
||||||
|
- val = 42
|
||||||
|
- }.to change { val.class }.from(NilClass).to(Fixnum)
|
||||||
|
+ val = "string"
|
||||||
|
+ }.to change { val.class }.from(NilClass).to(String)
|
||||||
|
|
||||||
|
expect {
|
||||||
|
expect {
|
||||||
|
- val = "string"
|
||||||
|
- }.to change { val.class }.from(Fixnum).to(NilClass)
|
||||||
|
- }.to fail_with(/but is now String/)
|
||||||
|
+ val = :symbol
|
||||||
|
+ }.to change { val.class }.from(String).to(NilClass)
|
||||||
|
+ }.to fail_with(/but is now Symbol/)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with boolean values" do
|
||||||
|
diff --git a/spec/rspec/matchers/built_in/compound_spec.rb b/spec/rspec/matchers/built_in/compound_spec.rb
|
||||||
|
index 2254296..aeeb5cf 100644
|
||||||
|
--- a/spec/rspec/matchers/built_in/compound_spec.rb
|
||||||
|
+++ b/spec/rspec/matchers/built_in/compound_spec.rb
|
||||||
|
@@ -416,7 +416,7 @@ def expect_block
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when only second matcher fails" do
|
||||||
|
- subject { include("baz").and be_a(Fixnum) }
|
||||||
|
+ subject { include("baz").and be_an(Integer) }
|
||||||
|
|
||||||
|
it 'fails with a message not containing a diff for first matcher' do
|
||||||
|
expect {
|
||||||
|
@@ -784,7 +784,7 @@ def expect_block
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when both matchers are not diffable" do
|
||||||
|
- subject { be_a(String).or be_a(Fixnum) }
|
||||||
|
+ subject { be_a(String).or be_an(Integer) }
|
||||||
|
|
||||||
|
it "is not diffable" do
|
||||||
|
expect(subject).not_to be_diffable
|
||||||
|
diff --git a/spec/rspec/matchers/built_in/yield_spec.rb b/spec/rspec/matchers/built_in/yield_spec.rb
|
||||||
|
index 793df45..9f809f4 100644
|
||||||
|
--- a/spec/rspec/matchers/built_in/yield_spec.rb
|
||||||
|
+++ b/spec/rspec/matchers/built_in/yield_spec.rb
|
||||||
|
@@ -481,18 +481,18 @@ def each_arg(*args, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
- describe "expect {...}.to yield_with_args(String, Fixnum)" do
|
||||||
|
+ describe "expect {...}.to yield_with_args(String, Integer)" do
|
||||||
|
it "passes if the block yields objects of the given classes" do
|
||||||
|
- expect { |b| _yield_with_args("string", 15, &b) }.to yield_with_args(String, Fixnum)
|
||||||
|
+ expect { |b| _yield_with_args("string", 15, &b) }.to yield_with_args(String, Integer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "passes if the block yields the given classes" do
|
||||||
|
- expect { |b| _yield_with_args(String, Fixnum, &b) }.to yield_with_args(String, Fixnum)
|
||||||
|
+ expect { |b| _yield_with_args(String, Integer, &b) }.to yield_with_args(String, Integer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails if the block yields objects of different classes" do
|
||||||
|
expect {
|
||||||
|
- expect { |b| _yield_with_args(15, "string", &b) }.to yield_with_args(String, Fixnum)
|
||||||
|
+ expect { |b| _yield_with_args(15, "string", &b) }.to yield_with_args(String, Integer)
|
||||||
|
}.to fail_with(/expected given block to yield with arguments, but yielded with unexpected arguments/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@@ -630,18 +630,18 @@ def each_arg(*args, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
- describe "expect {...}.to yield_successive_args(String, Fixnum)" do
|
||||||
|
+ describe "expect {...}.to yield_successive_args(String, Integer)" do
|
||||||
|
it "passes if the block successively yields objects of the given classes" do
|
||||||
|
- expect { |b| ["string", 15].each(&b) }.to yield_successive_args(String, Fixnum)
|
||||||
|
+ expect { |b| ["string", 15].each(&b) }.to yield_successive_args(String, Integer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "passes if the block yields the given classes" do
|
||||||
|
- expect { |b| [String, Fixnum].each(&b) }.to yield_successive_args(String, Fixnum)
|
||||||
|
+ expect { |b| [String, Integer].each(&b) }.to yield_successive_args(String, Integer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails if the block yields objects of different classes" do
|
||||||
|
expect {
|
||||||
|
- expect { |b| [15, "string"].each(&b) }.to yield_successive_args(String, Fixnum)
|
||||||
|
+ expect { |b| [15, "string"].each(&b) }.to yield_successive_args(String, Integer)
|
||||||
|
}.to fail_with(/expected given block to yield successively with arguments/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
diff --git a/spec/rspec/matchers/dsl_spec.rb b/spec/rspec/matchers/dsl_spec.rb
|
||||||
|
index d139887..ce78b39 100644
|
||||||
|
--- a/spec/rspec/matchers/dsl_spec.rb
|
||||||
|
+++ b/spec/rspec/matchers/dsl_spec.rb
|
||||||
|
@@ -590,16 +590,16 @@ def foo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
- expect(Fixnum).to descend_from(Object)
|
||||||
|
- expect(Fixnum).not_to descend_from(Array)
|
||||||
|
+ expect(Integer).to descend_from(Object)
|
||||||
|
+ expect(Integer).not_to descend_from(Array)
|
||||||
|
|
||||||
|
expect {
|
||||||
|
- expect(Fixnum).to descend_from(Array)
|
||||||
|
- }.to fail_with(/expected Fixnum to descend from Array/)
|
||||||
|
+ expect(Integer).to descend_from(Array)
|
||||||
|
+ }.to fail_with(/expected Integer to descend from Array/)
|
||||||
|
|
||||||
|
expect {
|
||||||
|
- expect(Fixnum).not_to descend_from(Object)
|
||||||
|
- }.to fail_with(/expected Fixnum not to descend from Object/)
|
||||||
|
+ expect(Integer).not_to descend_from(Object)
|
||||||
|
+ }.to fail_with(/expected Integer not to descend from Object/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can use the `match` matcher from a `match` block" do
|
@ -1,13 +0,0 @@
|
|||||||
--- 2.14.5/TMP/lib/rspec/matchers.rb.be_truthy 1970-01-01 09:00:00.000000000 +0900
|
|
||||||
+++ 2.14.5/TMP/lib/rspec/matchers.rb 2014-08-13 16:30:56.000000000 +0900
|
|
||||||
@@ -198,6 +198,10 @@
|
|
||||||
BuiltIn::BeNil.new
|
|
||||||
end
|
|
||||||
|
|
||||||
+ alias_method :be_truthy, :be_true
|
|
||||||
+ alias_method :be_falsey, :be_false
|
|
||||||
+ alias_method :be_falsy, :be_falsey
|
|
||||||
+
|
|
||||||
# @example
|
|
||||||
# expect(actual).to be_true
|
|
||||||
# expect(actual).to be_false
|
|
@ -3,13 +3,13 @@
|
|||||||
%global rpmminorver .%(echo %preminorver | sed -e 's|^\\.\\.*||')
|
%global rpmminorver .%(echo %preminorver | sed -e 's|^\\.\\.*||')
|
||||||
%global fullver %{majorver}%{?preminorver}
|
%global fullver %{majorver}%{?preminorver}
|
||||||
|
|
||||||
%global fedorarel 1
|
%global fedorarel 2
|
||||||
|
|
||||||
%global gem_name rspec-expectations
|
%global gem_name rspec-expectations
|
||||||
|
|
||||||
%global need_bootstrap_set 0
|
%global need_bootstrap_set 0
|
||||||
|
|
||||||
Summary: Rspec-2 expectations (should and matchers)
|
Summary: RSpec expectations (should and matchers)
|
||||||
Name: rubygem-%{gem_name}
|
Name: rubygem-%{gem_name}
|
||||||
Version: %{majorver}
|
Version: %{majorver}
|
||||||
Release: %{?preminorver:0.}%{fedorarel}%{?preminorver:%{rpmminorver}}%{?dist}
|
Release: %{?preminorver:0.}%{fedorarel}%{?preminorver:%{rpmminorver}}%{?dist}
|
||||||
@ -21,6 +21,9 @@ Source0: https://rubygems.org/gems/%{gem_name}-%{fullver}.gem
|
|||||||
# %%{SOURCE2} %%{name} %%{version}
|
# %%{SOURCE2} %%{name} %%{version}
|
||||||
Source1: rubygem-%{gem_name}-%{version}-full.tar.gz
|
Source1: rubygem-%{gem_name}-%{version}-full.tar.gz
|
||||||
Source2: rspec-related-create-full-tarball.sh
|
Source2: rspec-related-create-full-tarball.sh
|
||||||
|
# Fix Ruby 2.4 compatibility.
|
||||||
|
# https://github.com/rspec/rspec-expectations/commit/2b04f95cf585720f80da56c2785bee65812f15a0
|
||||||
|
Patch0: rspec-expectations-3.5.0-Address-Fixnum-changes-in-Ruby-2.4.patch
|
||||||
|
|
||||||
#BuildRequires: ruby(release)
|
#BuildRequires: ruby(release)
|
||||||
BuildRequires: rubygems-devel
|
BuildRequires: rubygems-devel
|
||||||
@ -50,6 +53,10 @@ gem unpack %{SOURCE0}
|
|||||||
%setup -q -D -T -n %{gem_name}-%{version} -a 1
|
%setup -q -D -T -n %{gem_name}-%{version} -a 1
|
||||||
gem specification %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
gem specification %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
||||||
|
|
||||||
|
pushd %{gem_name}-%{version}
|
||||||
|
%patch0 -p1
|
||||||
|
popd
|
||||||
|
|
||||||
%build
|
%build
|
||||||
gem build %{gem_name}.gemspec
|
gem build %{gem_name}.gemspec
|
||||||
%gem_install
|
%gem_install
|
||||||
@ -87,6 +94,9 @@ popd
|
|||||||
%{gem_docdir}
|
%{gem_docdir}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jan 18 2017 Vít Ondruch <vondruch@redhat.com> - 3.5.0-2
|
||||||
|
- Fix Ruby 2.4 compatibility.
|
||||||
|
|
||||||
* Sun Jul 24 2016 Mamoru TASAKA <mtasaka@fedoraproject.org> - 3.5.0-1
|
* Sun Jul 24 2016 Mamoru TASAKA <mtasaka@fedoraproject.org> - 3.5.0-1
|
||||||
- Enable tests again
|
- Enable tests again
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user