Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Red test replicating Issue #85

  • Loading branch information...
commit 1eee5eeaf0ac0b10949de0da1a997599b9af26d6 1 parent f0f9d4a
@kaiwren kaiwren authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 spec/rspec/mocks/any_instance_spec.rb
View
14 spec/rspec/mocks/any_instance_spec.rb
@@ -10,6 +10,8 @@ class CustomErrorForAnyInstanceSpec < StandardError;end
def existing_method; :existing_method_return_value; end
def existing_method_with_arguments(arg_one, arg_two = nil); :existing_method_with_arguments_return_value; end
def another_existing_method; end
+ private
+ def private_method; :private_method_return_value; end
end
end
let(:existing_method_return_value){ :existing_method_return_value }
@@ -194,7 +196,7 @@ def another_existing_method; end
klass.new.foo.should eq(klass.new.foo)
end
end
-
+
context "core ruby objects" do
it "works uniformly across *everything*" do
Object.any_instance.stub(:foo).and_return(1)
@@ -672,6 +674,16 @@ class RSpec::SampleRspecTestClass;end
klass.method_defined?(:__existing_method_without_any_instance__).should be_false
klass.new.existing_method.should eq(existing_method_return_value)
end
+
+ context "private methods" do
+ it "restores a stubbed private method after the spec is run (issue #85)" do
+ klass.any_instance.stub(:private_method).and_return(:something)
+
+ space.verify_all
+
+ klass.new.send(:private_method).should eq(:private_method_return_value)
+ end
+ end
end
context "with expectations" do
Please sign in to comment.
Something went wrong with that request. Please try again.