summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/matchers/be_false_spec.rb
blob: 46d7253220495e8eec419673ee5b57f939ce6b1d (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'

RSpec.describe BeFalseMatcher do
  it "matches when actual is false" do
    expect(BeFalseMatcher.new.matches?(false)).to eq(true)
  end

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

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

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