mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add test for fix, fix test for range_matcher
This commit is contained in:
parent
ce9bf918c1
commit
83ac420273
2 changed files with 20 additions and 2 deletions
17
spec/rspec/expectations/be_between_matcher_spec.cr
Normal file
17
spec/rspec/expectations/be_between_matcher_spec.cr
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
require "../../spec_helper"
|
||||||
|
|
||||||
|
Spectator.describe "`be_between` matcher" do
|
||||||
|
context "basic usage" do
|
||||||
|
describe 7 do
|
||||||
|
it { is_expected.to be_between(1, 10) }
|
||||||
|
it { is_expected.to be_between(0.2, 27.1) }
|
||||||
|
it { is_expected.not_to be_between(1.5, 4) }
|
||||||
|
it { is_expected.not_to be_between(8, 9) }
|
||||||
|
|
||||||
|
# boundaries check
|
||||||
|
it { is_expected.to be_between(0, 7) }
|
||||||
|
it { is_expected.to be_between(7, 10) }
|
||||||
|
it { is_expected.not_to (be_between(0, 7).exclusive) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -13,13 +13,14 @@ module Spectator::Matchers
|
||||||
|
|
||||||
# Returns a new matcher, with the same bounds, but uses an inclusive range.
|
# Returns a new matcher, with the same bounds, but uses an inclusive range.
|
||||||
def inclusive
|
def inclusive
|
||||||
new_range = Range.new(range.begin, range.end, exclusive: false)
|
label = expected.label
|
||||||
expected = TestValue.new(new_range, label)
|
new_range = Range.new(range.begin, label)
|
||||||
RangeMatcher.new(expected)
|
RangeMatcher.new(expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a new matcher, with the same bounds, but uses an exclusive range.
|
# Returns a new matcher, with the same bounds, but uses an exclusive range.
|
||||||
def exclusive
|
def exclusive
|
||||||
|
label = expected.label
|
||||||
new_range = Range.new(range.begin, range.end, exclusive: true)
|
new_range = Range.new(range.begin, range.end, exclusive: true)
|
||||||
expected = TestValue.new(new_range, label)
|
expected = TestValue.new(new_range, label)
|
||||||
RangeMatcher.new(expected)
|
RangeMatcher.new(expected)
|
||||||
|
|
Loading…
Reference in a new issue