aboutsummaryrefslogtreecommitdiffstats
path: root/spec/mspec/lib/mspec/matchers/eql.rb
blob: a855789550c6f62742286bef5aeb324ba0e2e1b6 (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 EqlMatcher
  def initialize(expected)
    @expected = expected
  end

  def matches?(actual)
    @actual = actual
    @actual.eql?(@expected)
  end

  def failure_message
    ["Expected #{@actual.pretty_inspect}",
     "to have same value and type as #{@expected.pretty_inspect}"]
  end

  def negative_failure_message
    ["Expected #{@actual.pretty_inspect}",
     "not to have same value or type as #{@expected.pretty_inspect}"]
  end
end

module MSpecMatchers
  private def eql(expected)
    EqlMatcher.new(expected)
  end
end