mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add spec for BeComparison
This commit is contained in:
parent
f09aaf59e6
commit
2758ba7643
1 changed files with 102 additions and 0 deletions
102
spec/matchers/be_comparison_spec.cr
Normal file
102
spec/matchers/be_comparison_spec.cr
Normal file
|
@ -0,0 +1,102 @@
|
|||
require "../spec_helper"
|
||||
|
||||
# This is a terrible hack,
|
||||
# but I don't want to expose `ValueMatcher#expected` publicly
|
||||
# just for this spec.
|
||||
module Spectator::Matchers
|
||||
struct ValueMatcher(ExpectedType)
|
||||
def expected_value
|
||||
expected
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def be_comparison
|
||||
Spectator::Matchers::BeComparison.new
|
||||
end
|
||||
|
||||
describe Spectator::Matchers::BeComparison do
|
||||
describe "#<" do
|
||||
it "returns a LessThanMatcher" do
|
||||
value = 0
|
||||
matcher = be_comparison < value
|
||||
matcher.should be_a(Spectator::Matchers::LessThanMatcher(typeof(value)))
|
||||
end
|
||||
|
||||
it "passes along the expected value" do
|
||||
value = 42
|
||||
matcher = be_comparison < value
|
||||
matcher.expected_value.should eq(value)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#<=" do
|
||||
it "returns a LessThanEqualMatcher" do
|
||||
value = 0
|
||||
matcher = be_comparison <= value
|
||||
matcher.should be_a(Spectator::Matchers::LessThanEqualMatcher(typeof(value)))
|
||||
end
|
||||
|
||||
it "passes along the expected value" do
|
||||
value = 42
|
||||
matcher = be_comparison <= value
|
||||
matcher.expected_value.should eq(value)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#>" do
|
||||
it "returns a GreaterThanMatcher" do
|
||||
value = 0
|
||||
matcher = be_comparison > value
|
||||
matcher.should be_a(Spectator::Matchers::GreaterThanMatcher(typeof(value)))
|
||||
end
|
||||
|
||||
it "passes along the expected value" do
|
||||
value = 42
|
||||
matcher = be_comparison > value
|
||||
matcher.expected_value.should eq(value)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#>=" do
|
||||
it "returns a GreaterThanEqualMatcher" do
|
||||
value = 0
|
||||
matcher = be_comparison >= value
|
||||
matcher.should be_a(Spectator::Matchers::GreaterThanEqualMatcher(typeof(value)))
|
||||
end
|
||||
|
||||
it "passes along the expected value" do
|
||||
value = 42
|
||||
matcher = be_comparison >= value
|
||||
matcher.expected_value.should eq(value)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#==" do
|
||||
it "returns an EqualityMatcher" do
|
||||
value = 0
|
||||
matcher = be_comparison == value
|
||||
matcher.should be_a(Spectator::Matchers::EqualityMatcher(typeof(value)))
|
||||
end
|
||||
|
||||
it "passes along the expected value" do
|
||||
value = 42
|
||||
matcher = be_comparison == value
|
||||
matcher.expected_value.should eq(value)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#!=" do
|
||||
it "returns an InequalityMatcher" do
|
||||
value = 0
|
||||
matcher = be_comparison != value
|
||||
matcher.should be_a(Spectator::Matchers::InequalityMatcher(typeof(value)))
|
||||
end
|
||||
|
||||
it "passes along the expected value" do
|
||||
value = 42
|
||||
matcher = be_comparison != value
|
||||
matcher.expected_value.should eq(value)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue