summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/matchers/be_an_instance_of.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/lib/mspec/matchers/be_an_instance_of.rb')
-rw-r--r--spec/mspec/lib/mspec/matchers/be_an_instance_of.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/mspec/lib/mspec/matchers/be_an_instance_of.rb b/spec/mspec/lib/mspec/matchers/be_an_instance_of.rb
new file mode 100644
index 0000000000..6e31afcddd
--- /dev/null
+++ b/spec/mspec/lib/mspec/matchers/be_an_instance_of.rb
@@ -0,0 +1,26 @@
+class BeAnInstanceOfMatcher
+ def initialize(expected)
+ @expected = expected
+ end
+
+ def matches?(actual)
+ @actual = actual
+ @actual.instance_of?(@expected)
+ end
+
+ def failure_message
+ ["Expected #{@actual.inspect} (#{@actual.class})",
+ "to be an instance of #{@expected}"]
+ end
+
+ def negative_failure_message
+ ["Expected #{@actual.inspect} (#{@actual.class})",
+ "not to be an instance of #{@expected}"]
+ end
+end
+
+class Object
+ def be_an_instance_of(expected)
+ BeAnInstanceOfMatcher.new(expected)
+ end
+end