blob: ca7bf83fdd05fb831cd8d3aa0f435f490ccfcfe6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
describe EqualMatcher do
it "matches when actual is equal? to expected" do
EqualMatcher.new(1).matches?(1).should == true
EqualMatcher.new(:blue).matches?(:blue).should == true
EqualMatcher.new(Object).matches?(Object).should == true
o = Object.new
EqualMatcher.new(o).matches?(o).should == true
end
it "does not match when actual is not a equal? to expected" do
EqualMatcher.new(1).matches?(1.0).should == false
EqualMatcher.new("blue").matches?("blue").should == false
EqualMatcher.new(Hash).matches?(Object).should == false
end
it "provides a useful failure message" do
matcher = EqualMatcher.new("red")
matcher.matches?("red")
matcher.failure_message.should == ["Expected \"red\"\n", "to be identical to \"red\"\n"]
end
it "provides a useful negative failure message" do
matcher = EqualMatcher.new(1)
matcher.matches?(1)
matcher.negative_failure_message.should == ["Expected 1\n", "not to be identical to 1\n"]
end
end
|