summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/matchers/equal.rb
blob: 5dc77d27ea76525e678104d0202e2ad6cad30602 (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
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

module MSpecMatchers
  private def equal(expected)
    EqualMatcher.new(expected)
  end
end