Permalink
Browse files

Use stub_const to have a user class and show intent

  • Loading branch information...
1 parent 275d585 commit fffa5d55a203e6e8a26e3da269e7f21dc54f1a3d @rentalcustard rentalcustard committed Oct 26, 2012
Showing with 13 additions and 3 deletions.
  1. +13 −3 spec/rspec/matchers/be_instance_of_spec.rb
@@ -27,10 +27,20 @@ module Matchers
end
context "when expected provides an expanded inspect, e.g. AR::Base" do
- before { Fixnum.stub(:inspect) { "foo" } }
+ let(:user_klass) do
+ Class.new do
+ def self.inspect
+ "User(id: integer, name: string)"
+ end
+ end
+ end
+
+ before { stub_const("User", user_klass) }
+
it "provides a description including only the class name" do
- matcher = be_an_instance_of(Fixnum)
- matcher.description.should == "be an instance of Fixnum"
+ matcher = be_an_instance_of(User)
+ #it will be namespaced because I defined it inside this spec file
+ matcher.description.should == "be an instance of User"
end
end
end

0 comments on commit fffa5d5

Please sign in to comment.