Skip to content

Instantly share code, notes, and snippets.

@enthal
Created April 24, 2012 01:50
Show Gist options
  • Save enthal/2475463 to your computer and use it in GitHub Desktop.
Save enthal/2475463 to your computer and use it in GitHub Desktop.
added a failing test for a case when RR.mock breaks objects that use method_missing like Redis::Namespace
commit 56d2a064e942243cd601b3b5ac1ec48004a02664
Author: Jared Grippe and Rex Chung and Tim James <techops+jared+rex+tjames@change.org>
Date: Mon Apr 23 18:35:27 2012 -0700
added a failing test for a case when RR.mock breaks objects that use method_missing like Redis::Namespace
diff --git a/spec/rr/double_injection/double_injection_spec.rb b/spec/rr/double_injection/double_injection_spec.rb
index be2109b..d9ade8c 100644
--- a/spec/rr/double_injection/double_injection_spec.rb
+++ b/spec/rr/double_injection/double_injection_spec.rb
@@ -91,6 +91,28 @@ module RR
subject.methods.should_not include('foobar')
end
end
+
+ end
+
+ context "when the subject is using method missing" do
+ it "properly resets the mocked method" do
+ delegator = Class.new{
+ def initialize other
+ @other = other
+ end
+ def method_missing method, *args, &block
+ @other.send(method, *args, &block)
+ end
+ }
+ array_delegator = delegator.new([1,2,3])
+
+ array_delegator.size.should == 3
+ mock(array_delegator).size{ 12 }
+ array_delegator.size.should == 12
+ RR.reset
+ array_delegator.size.should == 3
+ end
+
end
context "when the subject redefines respond_to?" do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment