Blob Blame History Raw
From 1f7f4175e4f185d1a989dca0e8cd8bc6e6d4555f Mon Sep 17 00:00:00 2001
From: Myron Marston <myron.marston@gmail.com>
Date: Mon, 26 Dec 2016 23:26:58 -0800
Subject: [PATCH] Address Ruby 2.4 Fixnum changes.

---
 .../setting_constraints/matching_arguments.feature |  2 +-
 spec/rspec/mocks/argument_matchers_spec.rb         | 28 +++++++++++-----------
 spec/rspec/mocks/matchers/receive_spec.rb          | 14 +++++------
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/features/setting_constraints/matching_arguments.feature b/features/setting_constraints/matching_arguments.feature
index abc67b2..219302f 100644
--- a/features/setting_constraints/matching_arguments.feature
+++ b/features/setting_constraints/matching_arguments.feature
@@ -17,7 +17,7 @@ Feature: Matching arguments
   | A subset of a hash                                  | `with(hash_including(:a => 1))` | `foo(:a => 1, :b => 2)`               |
   | An excluded subset of a hash                        | `with(hash_excluding(:a => 1))` | `foo(:b => 2)`                        |
   | A subset of an array                                | `with(array_including(:a, :b))` | `foo([:a, :b, :c])`                   |
-  | An instance of a specific class                     | `with(instance_of(Fixnum))`     | `foo(3)`                              |
+  | An instance of a specific class                     | `with(instance_of(Integer))`    | `foo(3)`                              |
   | An object with a given module in its ancestors list | `with(kind_of(Numeric))`        | `foo(3)`                              |
   | Any RSpec matcher                                   | `with(<matcher>)`               | `foo(<object that matches>)`          |
 
diff --git a/spec/rspec/mocks/argument_matchers_spec.rb b/spec/rspec/mocks/argument_matchers_spec.rb
index 3d4c154..3df9172 100644
--- a/spec/rspec/mocks/argument_matchers_spec.rb
+++ b/spec/rspec/mocks/argument_matchers_spec.rb
@@ -59,19 +59,19 @@ module Mocks
       end
 
       describe "instance_of" do
-        it "accepts fixnum as instance_of(Fixnum)" do
-          expect(a_double).to receive(:random_call).with(instance_of(Fixnum))
-          a_double.random_call(1)
+        it "accepts float as instance_of(Float)" do
+          expect(a_double).to receive(:random_call).with(instance_of(Float))
+          a_double.random_call(1.1)
         end
 
-        it "does NOT accept fixnum as instance_of(Numeric)" do
+        it "does NOT accept float as instance_of(Numeric)" do
           expect(a_double).not_to receive(:random_call).with(instance_of(Numeric))
-          a_double.random_call(1)
+          a_double.random_call(1.1)
         end
 
-        it "does NOT accept float as instance_of(Numeric)" do
+        it "does NOT accept integer as instance_of(Numeric)" do
           expect(a_double).not_to receive(:random_call).with(instance_of(Numeric))
-          a_double.random_call(1.5)
+          a_double.random_call(1)
         end
 
         it "rejects non numeric", :reset => true do
@@ -408,23 +408,23 @@ def ==(other)
         end
 
         it "matches a class against itself" do
-          expect(a_double).to receive(:foo).with(Fixnum)
-          a_double.foo(Fixnum)
+          expect(a_double).to receive(:foo).with(Float)
+          a_double.foo(Float)
         end
 
         it "fails a class against an unrelated class", :reset => true do
-          expect(a_double).to receive(:foo).with(Fixnum)
+          expect(a_double).to receive(:foo).with(Float)
           expect { a_double.foo(Hash) }.to fail
         end
 
         it "matches a class against an instance of itself" do
-          expect(a_double).to receive(:foo).with(Fixnum)
-          a_double.foo(3)
+          expect(a_double).to receive(:foo).with(Float)
+          a_double.foo(3.3)
         end
 
         it "fails a class against an object of a different type", :reset => true do
-          expect(a_double).to receive(:foo).with(Fixnum)
-          expect { a_double.foo(3.2) }.to fail
+          expect(a_double).to receive(:foo).with(Float)
+          expect { a_double.foo(3) }.to fail
         end
 
         it "fails with zero arguments", :reset => true do
diff --git a/spec/rspec/mocks/matchers/receive_spec.rb b/spec/rspec/mocks/matchers/receive_spec.rb
index 4285ceb..7937e66 100644
--- a/spec/rspec/mocks/matchers/receive_spec.rb
+++ b/spec/rspec/mocks/matchers/receive_spec.rb
@@ -47,11 +47,11 @@ module Mocks
         end
 
         it 'allows the caller to constrain the received arguments by matcher' do
-          wrapped.to receive(:foo).with an_instance_of Fixnum
+          wrapped.to receive(:foo).with an_instance_of Float
           expect {
-            receiver.foo(1.1)
-          }.to raise_error(/expected.*\(an instance of Fixnum\)/)
-          receiver.foo(1)
+            receiver.foo(1)
+          }.to raise_error(/expected.*\(an instance of Float\)/)
+          receiver.foo(1.1)
         end
 
         it 'allows a `do...end` block implementation to be provided' do
@@ -352,9 +352,9 @@ def receiver.method_missing(*); end # a poor man's stub...
 
           context "when a message is not received" do
             it 'sets up a message expectation that formats argument matchers correctly' do
-              wrapped.to receive(:foo).with an_instance_of Fixnum
+              wrapped.to receive(:foo).with an_instance_of Float
               expect { verify_all }.to(
-                raise_error(/expected: 1 time with arguments: \(an instance of Fixnum\)\n\s+received: 0 times$/)
+                raise_error(/expected: 1 time with arguments: \(an instance of Float\)\n\s+received: 0 times$/)
               )
             end
           end
@@ -467,7 +467,7 @@ def receiver.method_missing(*); end # a poor man's stub...
           let(:receiver) { klass.new }
 
           it 'sets up a message expectation that formats argument matchers correctly' do
-            wrapped.to receive(:foo).with an_instance_of Fixnum
+            wrapped.to receive(:foo).with an_instance_of Float
             expect { verify_all }.to raise_error(/should have received the following message\(s\) but didn't/)
           end
         end