summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/matchers/be_nil.rb
blob: c107ae109c8f55431f8402419c29b123a54f6842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class BeNilMatcher
  def matches?(actual)
    @actual = actual
    @actual.nil?
  end

  def failure_message
    ["Expected #{@actual.inspect}", "to be nil"]
  end

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

class Object
  def be_nil
    BeNilMatcher.new
  end
end