summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/matchers/be_true_spec.rb
blob: 39ef05a0f853f8e1d4dde4a1bf617064e42aee22 (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 BeTrueMatcher do
  it "matches when actual is true" do
    expect(BeTrueMatcher.new.matches?(true)).to eq(true)
  end

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

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

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