shard-spectator/spec/matchers/nil_matcher_spec.cr

66 lines
1.9 KiB
Crystal
Raw Normal View History

2019-01-26 23:41:21 +00:00
require "../spec_helper"
describe Spectator::Matchers::NilMatcher do
describe "#match" do
context "returned MatchData" do
describe "#matched?" do
context "with nil" do
it "is true" do
value = nil.as(Bool?)
partial = new_partial(value)
matcher = Spectator::Matchers::NilMatcher.new
match_data = matcher.match(partial)
match_data.matched?.should be_true
end
end
2019-01-26 23:41:21 +00:00
context "with not nil" do
it "is false" do
value = true.as(Bool?)
partial = new_partial(value)
matcher = Spectator::Matchers::NilMatcher.new
match_data = matcher.match(partial)
match_data.matched?.should be_false
end
end
2019-01-26 23:41:21 +00:00
end
describe "#message" do
it "mentions nil" do
partial = new_partial(42)
matcher = Spectator::Matchers::NilMatcher.new
match_data = matcher.match(partial)
match_data.message.should contain("nil")
end
2019-01-26 23:41:21 +00:00
it "contains the actual label" do
value = 42
label = "everything"
partial = new_partial(value, label)
matcher = Spectator::Matchers::NilMatcher.new
match_data = matcher.match(partial)
match_data.message.should contain(label)
end
end
2019-01-26 23:41:21 +00:00
describe "#negated_message" do
it "mentions nil" do
partial = new_partial(42)
matcher = Spectator::Matchers::NilMatcher.new
match_data = matcher.match(partial)
match_data.negated_message.should contain("nil")
end
2019-01-26 23:41:21 +00:00
it "contains the actual label" do
value = 42
label = "everything"
partial = new_partial(value, label)
matcher = Spectator::Matchers::NilMatcher.new
match_data = matcher.match(partial)
match_data.negated_message.should contain(label)
end
end
2019-01-26 23:41:21 +00:00
end
end
end