mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add spec for predicate matcher
This commit is contained in:
parent
6bfd15b7f9
commit
8a09ddac04
1 changed files with 57 additions and 0 deletions
57
spec/matchers/predicate_matcher_spec.cr
Normal file
57
spec/matchers/predicate_matcher_spec.cr
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
require "../spec_helper"
|
||||||
|
|
||||||
|
describe Spectator::Matchers::PredicateMatcher do
|
||||||
|
describe "#match?" do
|
||||||
|
context "with a true predicate" do
|
||||||
|
it "is true" do
|
||||||
|
value = "foobar"
|
||||||
|
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||||
|
matcher = Spectator::Matchers::PredicateMatcher(NamedTuple(ascii_only: Nil)).new
|
||||||
|
matcher.match?(partial).should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with a false predicate" do
|
||||||
|
it "is false" do
|
||||||
|
value = "foobar"
|
||||||
|
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||||
|
matcher = Spectator::Matchers::PredicateMatcher(NamedTuple(empty: Nil)).new
|
||||||
|
matcher.match?(partial).should be_false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#message" do
|
||||||
|
it "contains the actual label" do
|
||||||
|
value = "foobar"
|
||||||
|
label = "blah"
|
||||||
|
partial = Spectator::Expectations::ValueExpectationPartial.new(label, value)
|
||||||
|
matcher = Spectator::Matchers::PredicateMatcher(NamedTuple(ascii_only: Nil)).new
|
||||||
|
matcher.message(partial).should contain(label)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "contains stringified form of predicate" do
|
||||||
|
value = "foobar"
|
||||||
|
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||||
|
matcher = Spectator::Matchers::PredicateMatcher(NamedTuple(ascii_only: Nil)).new
|
||||||
|
matcher.message(partial).should contain("ascii_only")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#negated_message" do
|
||||||
|
it "contains the actual label" do
|
||||||
|
value = "foobar"
|
||||||
|
label = "blah"
|
||||||
|
partial = Spectator::Expectations::ValueExpectationPartial.new(label, value)
|
||||||
|
matcher = Spectator::Matchers::PredicateMatcher(NamedTuple(ascii_only: Nil)).new
|
||||||
|
matcher.negated_message(partial).should contain(label)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "contains stringified form of predicate" do
|
||||||
|
value = "foobar"
|
||||||
|
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||||
|
matcher = Spectator::Matchers::PredicateMatcher(NamedTuple(ascii_only: Nil)).new
|
||||||
|
matcher.negated_message(partial).should contain("ascii_only")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue