Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix generated docstring when Class#inspect changed

  • Loading branch information...
commit a5eb0474cfb640812c0b383576d281c79697788a 1 parent e2ef482
@rentalcustard rentalcustard authored
View
4 lib/rspec/matchers/built_in/be_instance_of.rb
@@ -5,6 +5,10 @@ class BeAnInstanceOf < BaseMatcher
def match(expected, actual)
actual.instance_of? expected
end
+
+ def description
+ "be an instance of #{expected}"
+ end
end
end
end
View
20 spec/rspec/matchers/be_instance_of_spec.rb
@@ -25,10 +25,26 @@ module Matchers
matcher.matches?(Numeric)
matcher.description.should == "be an instance of Fixnum"
end
+
+ context "when expected provides an expanded inspect, e.g. AR::Base" do
+ class User
+ def self.inspect
+ "User(id: integer, name: string)"
+ end
+ end
+ let(:expected) { User }
+
+ it "provides a description including only the class name" do
+ matcher = be_an_instance_of(expected)
+ matcher.matches?(Numeric)
+ #it will be namespaced because I defined it inside this spec file
+ matcher.description.should == "be an instance of RSpec::Matchers::User"
+ end
+ end
end
-
+
describe "actual.should_not #{method}(expected)" do
-
+
it "fails with failure message for should_not if actual is instance of expected class" do
lambda { "foo".should_not send(method, String) }.should fail_with(%Q{expected "foo" not to be an instance of String})
end
Please sign in to comment.
Something went wrong with that request. Please try again.