summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/matchers/be_false_spec.rb
blob: 31afd24ebcaa5b69c0fa36563ddf17aa5a636073 (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
require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'

describe BeFalseMatcher do
  it "matches when actual is false" do
    BeFalseMatcher.new.matches?(false).should == true
  end

  it "does not match when actual is not false" do
    BeFalseMatcher.new.matches?("").should == false
    BeFalseMatcher.new.matches?(true).should == false
    BeFalseMatcher.new.matches?(nil).should == false
    BeFalseMatcher.new.matches?(0).should == false
  end

  it "provides a useful failure message" do
    matcher = BeFalseMatcher.new
    matcher.matches?("some string")
    matcher.failure_message.should == ["Expected \"some string\"", "to be false"]
  end

  it "provides a useful negative failure message" do
    matcher = BeFalseMatcher.new
    matcher.matches?(false)
    matcher.negative_failure_message.should == ["Expected false", "not to be false"]
  end
end