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