Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fails with a class hierarchy

  • Loading branch information...
commit 0f9dd05847853a41214b881fa1341c1a40539320 1 parent 991950d
Étienne Barrié etiennebarrie authored
Showing with 26 additions and 0 deletions.
  1. +26 −0 spec/api/any_instance_of/any_instance_of_spec.rb
26 spec/api/any_instance_of/any_instance_of_spec.rb
View
@@ -43,5 +43,31 @@
subject.to_s.should_not == "Subject is stubbed"
subject.should_not respond_to(:baz)
end
+
+ context "with a class hierarchy" do
+
+ before :each do
+ class ParentClass; end
+ class SubjectClass < ParentClass; end
+ any_instance_of(ParentClass, :to_s => "Subject is stubbed")
+ any_instance_of(ParentClass, :foobar => lambda {:baz})
+ end
+
+ it "stubs methods" do
+ any_instance_of(SubjectClass, :to_s => "Subject is stubbed")
+
+ subject = SubjectClass.new
+ subject.should_not respond_to(:baz)
+
+ ParentClass.new.to_s.should == "Subject is stubbed"
+ subject.to_s.should == "Subject is stubbed"
+ subject.foobar.should == :baz
+
+ RR.reset
+
+ subject.to_s.should_not == "Subject is stubbed"
+ subject.should_not respond_to(:baz)
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.