Blame SOURCES/rubygem-mocha-1.1.0-As-of-Ruby-v2.2-nil-is-frozen-so-these-tests-are-irrelevant.patch

c2b424
From a65ea1ed3dce43cbc2cc16b3660afd2cce3db33e Mon Sep 17 00:00:00 2001
c2b424
From: James Mead <james@floehopper.org>
c2b424
Date: Mon, 2 Mar 2015 19:37:21 +0000
c2b424
Subject: [PATCH] As of Ruby v2.2, nil is frozen so these tests are irrelevant.
c2b424
c2b424
In all these scenarios in the latest versions of Ruby, a `Mocha::StubbingError`
c2b424
will be raised with the message: "can't stub method on frozen object: nil".
c2b424
c2b424
This behaviour is already tested in the more generic `StubbingFrozenObjectTest`
c2b424
and so it's safe to ignore these tests for the relevant versions of Ruby.
c2b424
---
c2b424
 test/acceptance/stubbing_nil_test.rb | 68 +++++++++++++++++++-----------------
c2b424
 1 file changed, 35 insertions(+), 33 deletions(-)
c2b424
c2b424
diff --git a/test/acceptance/stubbing_nil_test.rb b/test/acceptance/stubbing_nil_test.rb
c2b424
index ac163e7..f8c55cd 100644
c2b424
--- a/test/acceptance/stubbing_nil_test.rb
c2b424
+++ b/test/acceptance/stubbing_nil_test.rb
c2b424
@@ -13,47 +13,49 @@ def teardown
c2b424
     teardown_acceptance_test
c2b424
   end
c2b424
 
c2b424
-  def test_should_allow_stubbing_method_on_nil
c2b424
-    Mocha::Configuration.allow(:stubbing_method_on_nil)
c2b424
-    test_result = run_as_test do
c2b424
-      nil.stubs(:stubbed_method)
c2b424
+  if RUBY_VERSION < '2.2.0'
c2b424
+    def test_should_allow_stubbing_method_on_nil
c2b424
+      Mocha::Configuration.allow(:stubbing_method_on_nil)
c2b424
+      test_result = run_as_test do
c2b424
+        nil.stubs(:stubbed_method)
c2b424
+      end
c2b424
+      assert_passed(test_result)
c2b424
+      assert !@logger.warnings.include?("stubbing method on nil: nil.stubbed_method")
c2b424
     end
c2b424
-    assert_passed(test_result)
c2b424
-    assert !@logger.warnings.include?("stubbing method on nil: nil.stubbed_method")
c2b424
-  end
c2b424
 
c2b424
-  def test_should_warn_on_stubbing_method_on_nil
c2b424
-    Mocha::Configuration.warn_when(:stubbing_method_on_nil)
c2b424
-    test_result = run_as_test do
c2b424
-      nil.stubs(:stubbed_method)
c2b424
+    def test_should_warn_on_stubbing_method_on_nil
c2b424
+      Mocha::Configuration.warn_when(:stubbing_method_on_nil)
c2b424
+      test_result = run_as_test do
c2b424
+        nil.stubs(:stubbed_method)
c2b424
+      end
c2b424
+      assert_passed(test_result)
c2b424
+      assert @logger.warnings.include?("stubbing method on nil: nil.stubbed_method")
c2b424
     end
c2b424
-    assert_passed(test_result)
c2b424
-    assert @logger.warnings.include?("stubbing method on nil: nil.stubbed_method")
c2b424
-  end
c2b424
 
c2b424
-  def test_should_prevent_stubbing_method_on_nil
c2b424
-    Mocha::Configuration.prevent(:stubbing_method_on_nil)
c2b424
-    test_result = run_as_test do
c2b424
-      nil.stubs(:stubbed_method)
c2b424
+    def test_should_prevent_stubbing_method_on_nil
c2b424
+      Mocha::Configuration.prevent(:stubbing_method_on_nil)
c2b424
+      test_result = run_as_test do
c2b424
+        nil.stubs(:stubbed_method)
c2b424
+      end
c2b424
+      assert_failed(test_result)
c2b424
+      assert test_result.error_messages.include?("Mocha::StubbingError: stubbing method on nil: nil.stubbed_method")
c2b424
     end
c2b424
-    assert_failed(test_result)
c2b424
-    assert test_result.error_messages.include?("Mocha::StubbingError: stubbing method on nil: nil.stubbed_method")
c2b424
-  end
c2b424
 
c2b424
-  def test_should_default_to_prevent_stubbing_method_on_non_mock_object
c2b424
-    test_result = run_as_test do
c2b424
-      nil.stubs(:stubbed_method)
c2b424
+    def test_should_default_to_prevent_stubbing_method_on_non_mock_object
c2b424
+      test_result = run_as_test do
c2b424
+        nil.stubs(:stubbed_method)
c2b424
+      end
c2b424
+      assert_failed(test_result)
c2b424
+      assert test_result.error_messages.include?("Mocha::StubbingError: stubbing method on nil: nil.stubbed_method")
c2b424
     end
c2b424
-    assert_failed(test_result)
c2b424
-    assert test_result.error_messages.include?("Mocha::StubbingError: stubbing method on nil: nil.stubbed_method")
c2b424
-  end
c2b424
 
c2b424
-  def test_should_allow_stubbing_method_on_non_nil_object
c2b424
-    Mocha::Configuration.prevent(:stubbing_method_on_nil)
c2b424
-    object = Object.new
c2b424
-    test_result = run_as_test do
c2b424
-      object.stubs(:stubbed_method)
c2b424
+    def test_should_allow_stubbing_method_on_non_nil_object
c2b424
+      Mocha::Configuration.prevent(:stubbing_method_on_nil)
c2b424
+      object = Object.new
c2b424
+      test_result = run_as_test do
c2b424
+        object.stubs(:stubbed_method)
c2b424
+      end
c2b424
+      assert_passed(test_result)
c2b424
     end
c2b424
-    assert_passed(test_result)
c2b424
   end
c2b424
 end