summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/matchers/be_nan.rb
blob: aa19391211dc2ae8fbd37175470735020b83843c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class BeNaNMatcher
  def matches?(actual)
    @actual = actual
    @actual.kind_of?(Float) && @actual.nan?
  end

  def failure_message
    ["Expected #{@actual}", "to be NaN"]
  end

  def negative_failure_message
    ["Expected #{@actual}", "not to be NaN"]
  end
end

class Object
  def be_nan
    BeNaNMatcher.new
  end
end