mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Remove specs for matchers
Will replace with Spectator-based tests later.
This commit is contained in:
parent
85b7412436
commit
251e3b8774
29 changed files with 0 additions and 7149 deletions
|
@ -1,405 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::ArrayMatcher do
|
||||
describe "#in_any_order" do
|
||||
it "returns an unordered matcher" do
|
||||
array = %i[x y z]
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array)
|
||||
matcher.in_any_order.should be_a(Spectator::Matchers::UnorderedArrayMatcher(Symbol))
|
||||
end
|
||||
|
||||
it "maintains the expected array" do
|
||||
array = %i[x y z]
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array)
|
||||
unordered_matcher = matcher.in_any_order
|
||||
unordered_matcher.expected.should eq(array)
|
||||
end
|
||||
|
||||
it "maintains the expected label" do
|
||||
array = %i[x y z]
|
||||
label = "some_array"
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array, label)
|
||||
unordered_matcher = matcher.in_any_order
|
||||
unordered_matcher.label.should eq(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
context "with identical arrays" do
|
||||
describe "#matched?" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected array" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual array" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = [1, 2, 3]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = [1, 2, 3]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with arrays differing in size" do
|
||||
describe "#matched?" do
|
||||
it "is false" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected array" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(array2)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual array" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array1)
|
||||
end
|
||||
end
|
||||
|
||||
context "expected size" do
|
||||
it "is the expected size" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected size")[:value].should eq(array2.size)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual size" do
|
||||
it "is the actual size" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"actual size")[:value].should eq(array1.size)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions size" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("size")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with arrays differing in content" do
|
||||
describe "#matched?" do
|
||||
it "is false" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(array2)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array1)
|
||||
end
|
||||
end
|
||||
|
||||
context "expected element" do
|
||||
it "is the first mismatch" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected element")[:value].should eq(array2.first)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual element" do
|
||||
it "is the first mismatch" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"actual element")[:value].should eq(array1.first)
|
||||
end
|
||||
end
|
||||
|
||||
context "index" do
|
||||
it "is the mismatched index" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :index)[:value].should eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions content" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("content")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,358 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::AttributesMatcher do
|
||||
describe "#match" do
|
||||
it "uses ===" do
|
||||
array = %i[a b c]
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new({first: spy})
|
||||
matcher.match(partial)
|
||||
spy.case_eq_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "one argument" do
|
||||
context "against an equal value" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
attributes = {first: :a}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different value" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
attributes = {first: :z}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching type" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
attributes = {first: Symbol}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching type" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
attributes = {first: Int32}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching regex" do
|
||||
it "is true" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
attributes = {first: /foo/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching regex" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
attributes = {first: /qux/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "multiple attributes" do
|
||||
context "against equal values" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
attributes = {first: :a, last: :c}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "matching type" do
|
||||
context "matching regex" do
|
||||
it "is true" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Symbol, last: /foo/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "non-matching regex" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Symbol, last: /bar/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "non-matching type" do
|
||||
context "matching regex" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Float32, last: /foo/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "non-matching regex" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Float32, last: /bar/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against one equal value" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
attributes = {first: :a, last: :d}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no equal values" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
attributes = {first: :d, last: :e}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against matching types" do
|
||||
it "is true" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Symbol, last: String}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against one matching type" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Symbol, last: Float32}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no matching types" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Float32, last: Bytes}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against matching regexes" do
|
||||
it "is true" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
attributes = {first: /foo/i, last: /baz/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against one matching regex" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
attributes = {first: /foo/i, last: /qux/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no matching regexes" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR]
|
||||
attributes = {first: /baz/i, last: /qux/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against equal and matching type and regex" do
|
||||
it "is true" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Symbol, last: /foo/i, size: 3}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
it "contains a key for each expected attribute" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Symbol, last: /foo/i, size: 3}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_has_key?(match_data.values, :"expected first").should be_true
|
||||
match_data_has_key?(match_data.values, :"expected last").should be_true
|
||||
match_data_has_key?(match_data.values, :"expected size").should be_true
|
||||
end
|
||||
|
||||
it "contains a key for each actual value" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Symbol, last: /foo/i, size: 3}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_has_key?(match_data.values, :"actual first").should be_true
|
||||
match_data_has_key?(match_data.values, :"actual last").should be_true
|
||||
match_data_has_key?(match_data.values, :"actual size").should be_true
|
||||
end
|
||||
|
||||
it "has the expected values" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Symbol, last: /foo/i, size: 3}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected first")[:value].should eq(attributes[:first])
|
||||
match_data_value_sans_prefix(match_data.values, :"expected last")[:value].should eq(attributes[:last])
|
||||
match_data_value_sans_prefix(match_data.values, :"expected size")[:value].should eq(attributes[:size])
|
||||
end
|
||||
|
||||
it "has the actual values" do
|
||||
array = [:a, 42, "FOO"]
|
||||
attributes = {first: Symbol, last: /foo/i, size: 3}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"actual first")[:value].should eq(array.first)
|
||||
match_data_value_sans_prefix(match_data.values, :"actual last")[:value].should eq(array.last)
|
||||
match_data_value_sans_prefix(match_data.values, :"actual size")[:value].should eq(array.size)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
attributes = {size: 6}
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
attributes = {size: 6}
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
attributes = {size: 6}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(attributes.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
attributes = {size: 6}
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
attributes = {size: 6}
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
attributes = {size: 6}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::AttributesMatcher.new(attributes)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(attributes.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,203 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::CaseMatcher do
|
||||
describe "#match" do
|
||||
it "compares using #===" do
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(42)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(spy)
|
||||
matcher.match(partial)
|
||||
spy.case_eq_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with identical values" do
|
||||
it "is true" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with different values" do
|
||||
it "is false" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with the same instance" do
|
||||
it "is true" do
|
||||
# Box is used because it is a reference type and doesn't override the == method.
|
||||
ref = Box.new([] of Int32)
|
||||
partial = new_partial(ref)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(ref)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with different instances" do
|
||||
context "with same contents" do
|
||||
it "is true" do
|
||||
array1 = [1, 2, 3]
|
||||
array2 = [1, 2, 3]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with different contents" do
|
||||
it "is false" do
|
||||
array1 = [1, 2, 3]
|
||||
array2 = [4, 5, 6]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with the same type" do
|
||||
it "is true" do
|
||||
value1 = "foobar"
|
||||
value2 = String
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a different type" do
|
||||
it "is false" do
|
||||
value1 = "foobar"
|
||||
value2 = Array
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with a matching regex" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
pattern = /foo/
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(pattern)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a non-matching regex" do
|
||||
it "is false" do
|
||||
value = "foo"
|
||||
pattern = /bar/
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(pattern)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
actual = "foobar"
|
||||
expected = /foo/
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(expected)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
actual = "foobar"
|
||||
expected = /foo/
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::CaseMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,391 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::CollectionMatcher do
|
||||
describe "#match" do
|
||||
it "compares using #includes?" do
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(5)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(spy)
|
||||
matcher.match(partial)
|
||||
spy.includes_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "given a Range" do
|
||||
context "inclusive" do
|
||||
it "is true for lower-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for lower-bound minus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower - 1
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is true for mid-range" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = 5
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is true for upper-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for upper-bound plus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper + 1
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "exclusive" do
|
||||
it "is true for lower-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for lower-bound minus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower - 1
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is true for mid-range" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = 5
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for upper-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is false for upper-bound plus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper + 1
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "given an Enumerable" do
|
||||
it "is true for an existing item" do
|
||||
array = %i[a b c]
|
||||
value = :b
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for a non-existing item" do
|
||||
array = %i[a b c]
|
||||
value = :z
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "given a Range" do
|
||||
context "collection" do
|
||||
it "is the expected value" do
|
||||
value = 5
|
||||
range = Range.new(3, 9)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :collection)[:value].should eq(range)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
value = 5
|
||||
range = Range.new(3, 9)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "given an Enumerable" do
|
||||
context "collection" do
|
||||
it "is the expected value" do
|
||||
array = %i[a b c]
|
||||
value = :z
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :collection)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
array = %i[a b c]
|
||||
value = :z
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(range.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(range.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#of" do
|
||||
it "is true for lower-bound" do
|
||||
center = 5
|
||||
diff = 4
|
||||
lower = center - diff
|
||||
value = lower
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for lower-bound minus 1" do
|
||||
center = 5
|
||||
diff = 4
|
||||
lower = center - diff
|
||||
value = lower - 1
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is true for mid-range" do
|
||||
center = 5
|
||||
diff = 4
|
||||
value = center
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is true for upper-bound" do
|
||||
center = 5
|
||||
diff = 4
|
||||
upper = center + diff
|
||||
value = upper
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for upper-bound plus 1" do
|
||||
center = 5
|
||||
diff = 4
|
||||
upper = center + diff
|
||||
value = upper + 1
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the original label" do
|
||||
center = 5
|
||||
diff = 4
|
||||
value = 3
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff, label).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the center" do
|
||||
center = 5
|
||||
diff = 4
|
||||
value = 3
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(center.to_s)
|
||||
end
|
||||
|
||||
it "contains the diff" do
|
||||
center = 5
|
||||
diff = 4
|
||||
value = 3
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(diff.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the original label" do
|
||||
center = 5
|
||||
diff = 4
|
||||
value = 3
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff, label).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the center" do
|
||||
center = 5
|
||||
diff = 4
|
||||
value = 3
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(center.to_s)
|
||||
end
|
||||
|
||||
it "contains the diff" do
|
||||
center = 5
|
||||
diff = 4
|
||||
value = 3
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::CollectionMatcher.new(diff).of(center)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(diff.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,386 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::ContainMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a String" do
|
||||
context "one argument" do
|
||||
context "against a matching string" do
|
||||
it "is true" do
|
||||
value = "foobarbaz"
|
||||
search = "bar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "at the beginning" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = "foo"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "at the end" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = "bar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different string" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching character" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = 'o'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "at the beginning" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = 'f'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "at the end" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = 'r'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different character" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
search = 'z'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "multiple arguments" do
|
||||
context "against matching strings" do
|
||||
it "is true" do
|
||||
value = "foobarbaz"
|
||||
search = {"foo", "bar", "baz"}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against one matching string" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {"foo", "qux"}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no matching strings" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
search = {"baz", "qux"}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against matching characters" do
|
||||
it "is true" do
|
||||
value = "foobarbaz"
|
||||
search = {'f', 'b', 'z'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against one matching character" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {'f', 'c', 'd'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no matching characters" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {'c', 'd', 'e'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching string and character" do
|
||||
it "is true" do
|
||||
value = "foobarbaz"
|
||||
search = {"foo", 'z'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching string and non-matching character" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {"foo", 'c'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching string and matching character" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {"qux", 'f'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching string and character" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {"qux", 'c'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Enumberable" do
|
||||
context "one argument" do
|
||||
context "against an equal value" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
search = :b
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "at the beginning" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
search = :a
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "at the end" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
search = :c
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different value" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
search = :z
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "multiple arguments" do
|
||||
context "against equal values" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
search = {:a, :b}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against one equal value" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
search = {:a, :d}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no equal values" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
search = {:d, :e}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
describe "subset" do
|
||||
it "is the expected set" do
|
||||
array = %i[a b c]
|
||||
search = {:d, :e}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :subset)[:value].should eq(search)
|
||||
end
|
||||
end
|
||||
|
||||
describe "superset" do
|
||||
it "is the actual set" do
|
||||
array = %i[a b c]
|
||||
search = {:d, :e}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :superset)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search}, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(search)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search}, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ContainMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(search)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,73 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::EmptyMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with an empty set" do
|
||||
it "is true" do
|
||||
array = [] of Symbol
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EmptyMatcher.new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a filled set" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EmptyMatcher.new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is an empty set" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EmptyMatcher.new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should eq("[]")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual set" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EmptyMatcher.new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::EmptyMatcher.new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::EmptyMatcher.new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,393 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::EndWithMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a String" do
|
||||
context "against a matching string" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
last = "bar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at end" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
last = "foo"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different string" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
last = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching character" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
last = 'r'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at end" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
last = 'b'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different character" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
last = 'z'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching regex" do
|
||||
it "is true" do
|
||||
value = "FOOBAR"
|
||||
last = /bar/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at end" do
|
||||
it "is false" do
|
||||
value = "FOOBAR"
|
||||
last = /foo/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching regex" do
|
||||
it "is false" do
|
||||
value = "FOOBAR"
|
||||
last = /baz/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Enumberable" do
|
||||
context "against an equal value" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
last = :c
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at end" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
last = :b
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different value" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
last = :z
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against matching element type" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(Symbol)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at end" do
|
||||
it "is false" do
|
||||
array = [1, 2, 3, :a, :b, :c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(Int32)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against different element type" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(Int32)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching regex" do
|
||||
it "is true" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
last = /baz/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at end" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
last = /bar/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching regex" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
last = /qux/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "with a String" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
value = "FOOBAR"
|
||||
last = /baz/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(last)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
value = "FOOBAR"
|
||||
last = /baz/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Indexable" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
last = /qux/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(last)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the last element" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
last = /qux/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "list" do
|
||||
it "is the full actual list" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
last = /qux/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :list)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
context "with a String" do
|
||||
it "mentions #ends_with?" do
|
||||
value = "foobar"
|
||||
last = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("#ends_with?")
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Indexable" do
|
||||
it "mentions ===" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(array.last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("===")
|
||||
end
|
||||
|
||||
it "mentions last" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(array.last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("last")
|
||||
end
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
last = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
last = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
last = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(last)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
context "with a String" do
|
||||
it "mentions #starts_with?" do
|
||||
value = "foobar"
|
||||
last = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("#ends_with?")
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Indexable" do
|
||||
it "mentions ===" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(array.last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("===")
|
||||
end
|
||||
|
||||
it "mentions last" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(array.last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("last")
|
||||
end
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
last = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
last = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
last = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EndWithMatcher.new(last)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(last)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,173 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::EqualityMatcher do
|
||||
describe "#match" do
|
||||
it "compares using #==" do
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(spy)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(42)
|
||||
matcher.match(partial)
|
||||
spy.eq_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with identical values" do
|
||||
it "is true" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with different values" do
|
||||
it "is false" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with the same instance" do
|
||||
it "is true" do
|
||||
# Box is used because it is a reference type and doesn't override the == method.
|
||||
ref = Box.new([] of Int32)
|
||||
partial = new_partial(ref)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(ref)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with different instances" do
|
||||
context "with same contents" do
|
||||
it "is true" do
|
||||
array1 = [1, 2, 3]
|
||||
array2 = [1, 2, 3]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with different contents" do
|
||||
it "is false" do
|
||||
array1 = [1, 2, 3]
|
||||
array2 = [4, 5, 6]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
expected, actual = 42, 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(expected)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
expected, actual = 42, 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions ==" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("==")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions ==" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("==")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,205 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::ExceptionMatcher do
|
||||
describe "#match" do
|
||||
it "compares the message using #===" do
|
||||
spy = SpySUT.new
|
||||
partial = new_block_partial { raise "foobar" }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(Exception, SpySUT).new(spy, "foo")
|
||||
matcher.match(partial)
|
||||
spy.case_eq_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with no exception" do
|
||||
it "is false" do
|
||||
partial = new_block_partial { 42 }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(Exception, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with an exception" do
|
||||
context "of the same type" do
|
||||
it "is true" do
|
||||
partial = new_block_partial { raise ArgumentError.new }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(ArgumentError, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "of a different type" do
|
||||
it "is false" do
|
||||
partial = new_block_partial { raise ArgumentError.new }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(KeyError, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "of a sub-type" do
|
||||
it "is true" do
|
||||
partial = new_block_partial { raise ArgumentError.new }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(Exception, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "and an equal message" do
|
||||
it "is true" do
|
||||
message = "foobar"
|
||||
partial = new_block_partial { raise ArgumentError.new(message) }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(ArgumentError, String).new(message, "label")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "and a different message" do
|
||||
it "is false" do
|
||||
partial = new_block_partial { raise ArgumentError.new("foobar") }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(ArgumentError, String).new("different", "label")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "and a matching regex" do
|
||||
it "is true" do
|
||||
partial = new_block_partial { raise ArgumentError.new("foobar") }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(ArgumentError, Regex).new(/foo/, "label")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "and a non-matching regex" do
|
||||
it "is false" do
|
||||
partial = new_block_partial { raise ArgumentError.new("foobar") }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(ArgumentError, Regex).new(/baz/, "label")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
describe "expected type" do
|
||||
it "is the exception type" do
|
||||
partial = new_block_partial { raise ArgumentError.new }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(KeyError, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected type")[:value].should eq(KeyError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "actual type" do
|
||||
it "is the raised type" do
|
||||
partial = new_block_partial { raise ArgumentError.new }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(KeyError, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"actual type")[:value].should eq(ArgumentError)
|
||||
end
|
||||
|
||||
context "when nothing is raised" do
|
||||
it "is Nil" do
|
||||
partial = new_block_partial { 42 }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(KeyError, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"actual type")[:value].should eq(Nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "expected message" do
|
||||
it "is the expected value" do
|
||||
regex = /baz/
|
||||
partial = new_block_partial { raise ArgumentError.new("foobar") }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(KeyError, Regex).new(regex, "label")
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected message")[:value].should eq(regex)
|
||||
end
|
||||
end
|
||||
|
||||
describe "actual message" do
|
||||
it "is the raised exception's message" do
|
||||
message = "foobar"
|
||||
partial = new_block_partial { raise ArgumentError.new(message) }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(KeyError, Regex).new(/baz/, "label")
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"actual message")[:value].should eq(message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions raise" do
|
||||
partial = new_block_partial { raise "foobar" }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(Exception, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("raise")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
label = "everything"
|
||||
partial = new_block_partial(label) { raise "foobar" }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(Exception, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
label = "everything"
|
||||
partial = new_block_partial { raise "foobar" }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(Exception, Regex).new(/foobar/, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the exception type" do
|
||||
partial = new_block_partial { raise "foobar" }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(ArgumentError, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("ArgumentError")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions raise" do
|
||||
partial = new_block_partial { raise "foobar" }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(Exception, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("raise")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
label = "everything"
|
||||
partial = new_block_partial(label) { raise "foobar" }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(Exception, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
label = "everything"
|
||||
partial = new_block_partial { raise "foobar" }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(Exception, Regex).new(/foobar/, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the exception type" do
|
||||
partial = new_block_partial { raise "foobar" }
|
||||
matcher = Spectator::Matchers::ExceptionMatcher(ArgumentError, Nil).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("ArgumentError")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,160 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::GreaterThanEqualMatcher do
|
||||
describe "#match" do
|
||||
it "compares using #>=" do
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(spy)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(42)
|
||||
matcher.match(partial)
|
||||
spy.ge_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a larger value" do
|
||||
it "is false" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with a smaller value" do
|
||||
it "is true" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with an equal value" do
|
||||
it "is true" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(expected)
|
||||
end
|
||||
|
||||
it "is prefixed with >=" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should start_with(">=")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions >=" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(">=")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions >=" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(">=")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::GreaterThanEqualMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,160 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::GreaterThanMatcher do
|
||||
describe "#match" do
|
||||
it "compares using #>" do
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(spy)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(42)
|
||||
matcher.match(partial)
|
||||
spy.gt_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a larger value" do
|
||||
it "is false" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with a smaller value" do
|
||||
it "is true" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with an equal value" do
|
||||
it "is false" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(expected)
|
||||
end
|
||||
|
||||
it "is prefixed with >" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should start_with(">")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions >" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(">")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions >" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(">")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::GreaterThanMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,166 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
private struct FakeKeySet
|
||||
def has_key?(key)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
describe Spectator::Matchers::HaveKeyMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "against a Hash" do
|
||||
context "with an existing key" do
|
||||
it "is true" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
key = "foo"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a non-existent key" do
|
||||
it "is false" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
key = "baz"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a NamedTuple" do
|
||||
context "with an existing key" do
|
||||
it "is true" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :foo
|
||||
partial = new_partial(tuple)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a non-existent key" do
|
||||
it "is false" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :baz
|
||||
partial = new_partial(tuple)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "key" do
|
||||
it "is the expected key" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :baz
|
||||
partial = new_partial(tuple)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :key)[:value].should eq(key)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
context "when #keys is available" do
|
||||
it "is the list of keys" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :baz
|
||||
partial = new_partial(tuple)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(tuple.keys)
|
||||
end
|
||||
end
|
||||
|
||||
context "when #keys isn't available" do
|
||||
it "is the actual value" do
|
||||
actual = FakeKeySet.new
|
||||
key = :baz
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :foo
|
||||
label = "blah"
|
||||
partial = new_partial(tuple, label)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :foo
|
||||
label = "blah"
|
||||
partial = new_partial(tuple)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when the expected label is omitted" do
|
||||
it "contains the stringified key" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :foo
|
||||
partial = new_partial(tuple)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(key.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :foo
|
||||
label = "blah"
|
||||
partial = new_partial(tuple, label)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :foo
|
||||
label = "blah"
|
||||
partial = new_partial(tuple)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when the expected label is omitted" do
|
||||
it "contains the stringified key" do
|
||||
tuple = {foo: "bar"}
|
||||
key = :foo
|
||||
partial = new_partial(tuple)
|
||||
matcher = Spectator::Matchers::HaveKeyMatcher.new(key)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(key.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,604 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::HaveMatcher do
|
||||
describe "#match" do
|
||||
it "uses ===" do
|
||||
array = %i[a b c]
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({spy})
|
||||
matcher.match(partial)
|
||||
spy.case_eq_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a String" do
|
||||
context "one argument" do
|
||||
context "against a matching string" do
|
||||
it "is true" do
|
||||
value = "foobarbaz"
|
||||
search = "bar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "at the beginning" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = "foo"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "at the end" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = "bar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different string" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching character" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = 'o'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "at the beginning" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = 'f'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "at the end" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
search = 'r'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different character" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
search = 'z'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "multiple arguments" do
|
||||
context "against matching strings" do
|
||||
it "is true" do
|
||||
value = "foobarbaz"
|
||||
search = {"foo", "bar", "baz"}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against one matching string" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {"foo", "qux"}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no matching strings" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
search = {"baz", "qux"}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against matching characters" do
|
||||
it "is true" do
|
||||
value = "foobarbaz"
|
||||
search = {'f', 'b', 'z'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against one matching character" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {'f', 'c', 'd'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no matching characters" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {'c', 'd', 'e'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching string and character" do
|
||||
it "is true" do
|
||||
value = "foobarbaz"
|
||||
search = {"foo", 'z'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching string and non-matching character" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {"foo", 'c'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching string and matching character" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {"qux", 'f'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching string and character" do
|
||||
it "is false" do
|
||||
value = "foobarbaz"
|
||||
search = {"qux", 'c'}
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Enumberable" do
|
||||
context "one argument" do
|
||||
context "against an equal value" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
search = :b
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "at the beginning" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
search = :a
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "at the end" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
search = :c
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different value" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
search = :z
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching type" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({Symbol})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "at the beginning" do
|
||||
it "is true" do
|
||||
array = [:a, 1, 2]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({Symbol})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "at the end" do
|
||||
it "is true" do
|
||||
array = [0, 1, :c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({Symbol})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching type" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({Int32})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching regex" do
|
||||
it "is true" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
search = /bar/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "at the beginning" do
|
||||
it "is true" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
search = /foo/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "at the end" do
|
||||
it "is true" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
search = /baz/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching regex" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
search = /qux/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "multiple arguments" do
|
||||
context "against equal values" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
search = {:a, :b}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "matching type" do
|
||||
context "matching regex" do
|
||||
it "is true" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {:a, Int32, /foo/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "non-matching regex" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {:a, Int32, /bar/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "non-matching type" do
|
||||
context "matching regex" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {:a, Float32, /foo/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "non-matching regex" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {:a, Float32, /bar/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against one equal value" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
search = {:a, :d}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no equal values" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
search = {:d, :e}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against matching types" do
|
||||
it "is true" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {Symbol, String}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against one matching type" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {Symbol, Float32}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no matching types" do
|
||||
it "is false" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {Float32, Bytes}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against matching regexes" do
|
||||
it "is true" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
search = {/foo/i, /bar/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against one matching regex" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
search = {/foo/i, /qux/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against no matching regexes" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR]
|
||||
search = {/baz/i, /qux/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against equal and matching type and regex" do
|
||||
it "is true" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {:a, Int32, /foo/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "subset" do
|
||||
it "has the expected value" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {:a, Int32, /foo/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :subset)[:value].should eq(search)
|
||||
end
|
||||
end
|
||||
|
||||
context "superset" do
|
||||
it "has the actual value" do
|
||||
array = [:a, 42, "FOO"]
|
||||
search = {:a, Int32, /foo/i}
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new(search)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :superset)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search}, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(search)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search}, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
search = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HaveMatcher.new({search})
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(search)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,87 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::HavePredicateMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#match?" do
|
||||
context "with a true predicate" do
|
||||
it "is true" do
|
||||
value = "foo\\bar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HavePredicateMatcher.new({back_references: Tuple.new}, "back_references")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a false predicate" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HavePredicateMatcher.new({back_references: Tuple.new}, "back_references")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
it "contains a key for each expected attribute" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HavePredicateMatcher.new({back_references: Tuple.new}, "back_references")
|
||||
match_data = matcher.match(partial)
|
||||
match_data_has_key?(match_data.values, :back_references).should be_true
|
||||
end
|
||||
|
||||
it "has the actual values" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HavePredicateMatcher.new({back_references: Tuple.new}, "back_references")
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :back_references)[:value].should eq(value.has_back_references?)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
label = "blah"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::HavePredicateMatcher.new({back_references: Tuple.new}, "back_references")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
label = "blah"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HavePredicateMatcher.new({back_references: Tuple.new}, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
label = "blah"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::HavePredicateMatcher.new({back_references: Tuple.new}, "back_references")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
label = "blah"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::HavePredicateMatcher.new({back_references: Tuple.new}, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,140 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
private struct FakeValueSet
|
||||
def has_value?(value)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
describe Spectator::Matchers::HaveValueMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with an existing value" do
|
||||
it "is true" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
value = "bar"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a non-existent value" do
|
||||
it "is false" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
value = "baz"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "value" do
|
||||
it "is the expected value" do
|
||||
hash = {"foo" => "bar"}
|
||||
value = "baz"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :value)[:value].should eq(value)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
context "when #values is available" do
|
||||
it "is the list of values" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
value = "baz"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(hash.values)
|
||||
end
|
||||
end
|
||||
|
||||
context "when #values isn't available" do
|
||||
it "is the actual value" do
|
||||
actual = FakeValueSet.new
|
||||
value = "baz"
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
value = "bar"
|
||||
label = "blah"
|
||||
partial = new_partial(hash, label)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
value = "bar"
|
||||
label = "blah"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when the expected label is omitted" do
|
||||
it "contains the stringified key" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
value = "bar"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(value.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
value = "bar"
|
||||
label = "blah"
|
||||
partial = new_partial(hash, label)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
value = "bar"
|
||||
label = "blah"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when the expected label is omitted" do
|
||||
it "contains the stringified key" do
|
||||
hash = Hash{"foo" => "bar"}
|
||||
value = "bar"
|
||||
partial = new_partial(hash)
|
||||
matcher = Spectator::Matchers::HaveValueMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(value.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,181 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::InequalityMatcher do
|
||||
describe "#match" do
|
||||
it "compares using #!=" do
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(spy)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(42)
|
||||
matcher.match(partial)
|
||||
spy.ne_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with identical values" do
|
||||
it "is false" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with different values" do
|
||||
it "is true" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with the same instance" do
|
||||
it "is false" do
|
||||
# Box is used because it is a reference type and doesn't override the == method.
|
||||
ref = Box.new([] of Int32)
|
||||
partial = new_partial(ref)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(ref)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with different instances" do
|
||||
context "with same contents" do
|
||||
it "is false" do
|
||||
array1 = [1, 2, 3]
|
||||
array2 = [1, 2, 3]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with different contents" do
|
||||
it "is true" do
|
||||
array1 = [1, 2, 3]
|
||||
array2 = [4, 5, 6]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
expected, actual = 42, 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(expected)
|
||||
end
|
||||
|
||||
it "is prefixed with 'Not'" do
|
||||
expected, actual = 42, 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should start_with("Not")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
expected, actual = 42, 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions !=" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("!=")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions !=" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("!=")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::InequalityMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,160 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::LessThanEqualMatcher do
|
||||
describe "#match" do
|
||||
it "compares using #<=" do
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(spy)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(42)
|
||||
matcher.match(partial)
|
||||
spy.le_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a larger value" do
|
||||
it "is true" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a smaller value" do
|
||||
it "is false" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with an equal value" do
|
||||
it "is true" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(expected)
|
||||
end
|
||||
|
||||
it "is prefixed with <=" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should start_with("<=")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions <=" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("<=")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions <=" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("<=")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::LessThanEqualMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,160 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::LessThanMatcher do
|
||||
describe "#match" do
|
||||
it "compares using #<" do
|
||||
spy = SpySUT.new
|
||||
partial = new_partial(spy)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(42)
|
||||
matcher.match(partial)
|
||||
spy.lt_call_count.should be > 0
|
||||
end
|
||||
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a larger value" do
|
||||
it "is true" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a smaller value" do
|
||||
it "is false" do
|
||||
actual = 777
|
||||
expected = 42
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with an equal value" do
|
||||
it "is false" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(expected)
|
||||
end
|
||||
|
||||
it "is prefixed with <" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should start_with("<")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
actual = 42
|
||||
expected = 777
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions <" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("<")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions <" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("<")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = new_partial(value1)
|
||||
matcher = Spectator::Matchers::LessThanMatcher.new(value2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,86 +0,0 @@
|
|||
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
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is nil" do
|
||||
partial = new_partial(42)
|
||||
matcher = Spectator::Matchers::NilMatcher.new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::NilMatcher.new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(value)
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,89 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::PredicateMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#match?" do
|
||||
context "with a true predicate" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::PredicateMatcher.new({ascii_only: Tuple.new}, "ascii_only")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a false predicate" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::PredicateMatcher.new({empty: Tuple.new}, "empty")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
it "contains a key for each expected attribute" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::PredicateMatcher.new({empty: Tuple.new, ascii_only: Tuple.new}, "empty, ascii_only")
|
||||
match_data = matcher.match(partial)
|
||||
match_data_has_key?(match_data.values, :empty).should be_true
|
||||
match_data_has_key?(match_data.values, :ascii_only).should be_true
|
||||
end
|
||||
|
||||
it "has the actual values" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::PredicateMatcher.new({empty: Tuple.new, ascii_only: Tuple.new}, "empty, ascii_only")
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :empty)[:value].should eq(value.empty?)
|
||||
match_data_value_sans_prefix(match_data.values, :ascii_only)[:value].should eq(value.ascii_only?)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
label = "blah"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::PredicateMatcher.new({ascii_only: Tuple.new}, "ascii_only")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
label = "blah"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::PredicateMatcher.new({ascii_only: Tuple.new}, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
label = "blah"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::PredicateMatcher.new({ascii_only: Tuple.new}, "ascii_only")
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
label = "blah"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::PredicateMatcher.new({ascii_only: Tuple.new}, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,686 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::RangeMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "inclusive" do
|
||||
it "is true for lower-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for lower-bound minus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower - 1
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is true for mid-range" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = 5
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is true for upper-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for upper-bound plus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper + 1
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "exclusive" do
|
||||
it "is true for lower-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for lower-bound minus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower - 1
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is true for mid-range" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = 5
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for upper-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is false for upper-bound plus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper + 1
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "lower" do
|
||||
it "is #begin from the expected range" do
|
||||
range = Range.new(3, 9)
|
||||
partial = new_partial(5)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :lower)[:value].should eq(range.begin)
|
||||
end
|
||||
|
||||
it "is prefixed with >=" do
|
||||
range = Range.new(3, 9)
|
||||
partial = new_partial(5)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :lower)[:to_s].should start_with(">=")
|
||||
end
|
||||
end
|
||||
|
||||
context "upper" do
|
||||
it "is #end from the expected range" do
|
||||
range = Range.new(3, 9)
|
||||
partial = new_partial(5)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :upper)[:value].should eq(range.end)
|
||||
end
|
||||
|
||||
context "when inclusive" do
|
||||
it "is prefixed with <=" do
|
||||
range = Range.new(3, 9, exclusive: false)
|
||||
partial = new_partial(5)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :upper)[:to_s].should start_with("<=")
|
||||
end
|
||||
end
|
||||
|
||||
context "when exclusive" do
|
||||
it "is prefixed with <" do
|
||||
range = Range.new(3, 9, exclusive: false)
|
||||
partial = new_partial(5)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :upper)[:to_s].should start_with("<")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
value = 5
|
||||
range = Range.new(3, 9)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(range.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(range.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#inclusive" do
|
||||
context "initially exclusive" do
|
||||
it "is true for lower-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for lower-bound minus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower - 1
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is true for mid-range" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = 5
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is true for upper-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for upper-bound plus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper + 1
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions inclusive" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("inclusive")
|
||||
end
|
||||
|
||||
it "does not mention exclusive" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should_not contain("exclusive")
|
||||
end
|
||||
|
||||
it "contains the original label" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions inclusive" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("inclusive")
|
||||
end
|
||||
|
||||
it "does not mention exclusive" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should_not contain("exclusive")
|
||||
end
|
||||
|
||||
it "contains the original label" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "initially inclusive" do
|
||||
it "is true for lower-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for lower-bound minus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower - 1
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is true for mid-range" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = 5
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is true for upper-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for upper-bound plus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper + 1
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions inclusive" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("inclusive")
|
||||
end
|
||||
|
||||
it "contains the original label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions inclusive" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("inclusive")
|
||||
end
|
||||
|
||||
it "contains the original label" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label).inclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#exclusive" do
|
||||
context "initially inclusive" do
|
||||
it "is true for lower-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for lower-bound minus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower - 1
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is true for mid-range" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = 5
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for upper-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is false for upper-bound plus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper + 1
|
||||
range = Range.new(lower, upper, exclusive: false)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions exclusive" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("exclusive")
|
||||
end
|
||||
|
||||
it "does not mention inclusive" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should_not contain("inclusive")
|
||||
end
|
||||
|
||||
it "contains the original label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions exclusive" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("exclusive")
|
||||
end
|
||||
|
||||
it "does not mention inclusive" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should_not contain("inclusive")
|
||||
end
|
||||
|
||||
it "contains the original label" do
|
||||
range = 1..10
|
||||
value = 5
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "initially exclusive" do
|
||||
it "is true for lower-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for lower-bound minus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = lower - 1
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is true for mid-range" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = 5
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
it "is false for upper-bound" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
it "is false for upper-bound plus 1" do
|
||||
lower = 3
|
||||
upper = 9
|
||||
value = upper + 1
|
||||
range = Range.new(lower, upper, exclusive: true)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "mentions exclusive" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("exclusive")
|
||||
end
|
||||
|
||||
it "contains the original label" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions exclusive" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("exclusive")
|
||||
end
|
||||
|
||||
it "contains the original label" do
|
||||
range = 1...10
|
||||
value = 5
|
||||
label = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RangeMatcher.new(range, label).exclusive
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,152 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::ReferenceMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with the same instance" do
|
||||
it "is true" do
|
||||
# Box is used because it is a reference type and doesn't override the == method.
|
||||
ref = Box.new([] of Int32)
|
||||
partial = new_partial(ref)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(ref)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with different instances" do
|
||||
context "with same contents" do
|
||||
it "is false" do
|
||||
array1 = [1, 2, 3]
|
||||
array2 = [1, 2, 3]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with a duplicated instance" do
|
||||
it "is false" do
|
||||
array1 = [1, 2, 3]
|
||||
array2 = array1.dup
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with the same type" do
|
||||
it "is false" do
|
||||
obj1 = "foo"
|
||||
obj2 = "bar"
|
||||
partial = new_partial(obj1)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(obj2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with a different type" do
|
||||
it "is false" do
|
||||
obj1 = "foobar"
|
||||
obj2 = [1, 2, 3]
|
||||
partial = new_partial(obj1)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(obj2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
actual = "foobar"
|
||||
expected = /foo/
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(expected)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
actual = "foobar"
|
||||
expected = /foo/
|
||||
partial = new_partial(actual)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(expected)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
obj1 = "foo"
|
||||
obj2 = "bar"
|
||||
partial = new_partial(obj1)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(obj2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(obj2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(value)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(value, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
obj1 = "foo"
|
||||
obj2 = "bar"
|
||||
partial = new_partial(obj1)
|
||||
matcher = Spectator::Matchers::ReferenceMatcher.new(obj2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(obj2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,123 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::RespondMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "one method" do
|
||||
context "with a responding method" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(size: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-responding method" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(downcase: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "multiple methods" do
|
||||
context "with one responding method" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(size: Nil, downcase: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with all responding methods" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(size: Nil, to_a: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with no responding methods" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(downcase: Nil, upcase: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
it "contains a key for each expected method" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(size: Nil, downcase: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_has_key?(match_data.values, :"responds to #size").should be_true
|
||||
match_data_has_key?(match_data.values, :"responds to #downcase").should be_true
|
||||
end
|
||||
|
||||
it "has the actual values" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(size: Nil, downcase: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"responds to #size")[:value].should be_true
|
||||
match_data_value_sans_prefix(match_data.values, :"responds to #downcase")[:value].should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(size: Nil, downcase: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the method names" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(size: Nil, downcase: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("#size")
|
||||
match_data.message.should contain("#downcase")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(size: Nil, downcase: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the method names" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::RespondMatcher(NamedTuple(size: Nil, downcase: Nil)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("#size")
|
||||
match_data.negated_message.should contain("#downcase")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,121 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::SizeMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a matching number of items" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
size = array.size
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a different number of items" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
size = array.size + 1
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the size given" do
|
||||
array = %i[a b c]
|
||||
size = array.size + 1
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(size)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the size of the set" do
|
||||
array = %i[a b c]
|
||||
size = array.size + 1
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :actual).value.should eq(array.size)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
size = array.size + 1
|
||||
label = "foobar"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array = %i[a b c]
|
||||
size = array.size + 1
|
||||
label = "foobar"
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
array = %i[a b c]
|
||||
size = array.size + 1
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(size.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
size = array.size + 1
|
||||
label = "foobar"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array = %i[a b c]
|
||||
size = array.size + 1
|
||||
label = "foobar"
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
array = %i[a b c]
|
||||
size = array.size + 1
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeMatcher.new(size)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(size.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,121 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::SizeOfMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a matching number of items" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a different number of items" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3, 4]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the size given" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3, 4]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(other.size)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the size of the set" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3, 4]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :actual).value.should eq(array.size)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3, 4]
|
||||
label = "foobar"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3, 4]
|
||||
label = "foobar"
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3, 4]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(other.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3, 4]
|
||||
label = "foobar"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3, 4]
|
||||
label = "foobar"
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
array = %i[a b c]
|
||||
other = [1, 2, 3, 4]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::SizeOfMatcher.new(other)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(other.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,393 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::StartWithMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with a String" do
|
||||
context "against a matching string" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
start = "foo"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at start" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
start = "bar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different string" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
start = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching character" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
start = 'f'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at start" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
start = 'b'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different character" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
start = 'z'
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching regex" do
|
||||
it "is true" do
|
||||
value = "FOOBAR"
|
||||
start = /foo/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at start" do
|
||||
it "is false" do
|
||||
value = "FOOBAR"
|
||||
start = /bar/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching regex" do
|
||||
it "is false" do
|
||||
value = "FOOBAR"
|
||||
start = /baz/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Enumberable" do
|
||||
context "against an equal value" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
start = :a
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at start" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
start = :b
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a different value" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
start = :z
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against matching element type" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(Symbol)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at start" do
|
||||
it "is false" do
|
||||
array = [1, 2, 3, :a, :b, :c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(Symbol)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against different element type" do
|
||||
it "is false" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(Int32)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "against a matching regex" do
|
||||
it "is true" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
start = /foo/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
|
||||
context "not at start" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
start = /bar/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "against a non-matching regex" do
|
||||
it "is false" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
start = /qux/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "with a String" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
value = "FOOBAR"
|
||||
first = /baz/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(first)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(first)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
value = "FOOBAR"
|
||||
first = /baz/i
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(first)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Indexable" do
|
||||
context "expected" do
|
||||
it "is the expected value" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
first = /qux/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(first)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(first)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the first element" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
first = /qux/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(first)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array.first)
|
||||
end
|
||||
end
|
||||
|
||||
context "list" do
|
||||
it "is the full actual list" do
|
||||
array = %w[FOO BAR BAZ]
|
||||
first = /qux/i
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(first)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :list)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
context "with a String" do
|
||||
it "mentions #starts_with?" do
|
||||
value = "foobar"
|
||||
start = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("#starts_with?")
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Enumerable" do
|
||||
it "mentions ===" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(array.first)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("===")
|
||||
end
|
||||
|
||||
it "mentions first" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(array.first)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("first")
|
||||
end
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
start = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
start = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
start = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(start)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
context "with a String" do
|
||||
it "mentions #starts_with?" do
|
||||
value = "foobar"
|
||||
start = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("#starts_with?")
|
||||
end
|
||||
end
|
||||
|
||||
context "with an Enumerable" do
|
||||
it "mentions ===" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(array.first)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("===")
|
||||
end
|
||||
|
||||
it "mentions first" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(array.first)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("first")
|
||||
end
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
value = "foobar"
|
||||
start = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
value = "foobar"
|
||||
start = "baz"
|
||||
label = "everything"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value = "foobar"
|
||||
start = "baz"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::StartWithMatcher.new(start)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(start)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,374 +0,0 @@
|
|||
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::TruthyMatcher.new(true)
|
||||
end
|
||||
|
||||
describe Spectator::Matchers::TruthyMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
context "truthy" do
|
||||
describe "#matched?" do
|
||||
context "with a truthy value" do
|
||||
it "is true" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with false" do
|
||||
it "is false" do
|
||||
value = false
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with nil" do
|
||||
it "is false" do
|
||||
value = nil
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "contains the definition of falsey" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should match(/false or nil/i)
|
||||
end
|
||||
|
||||
it "is prefixed with \"Not\"" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should start_with(/not/i)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(value)
|
||||
end
|
||||
end
|
||||
|
||||
context "truthy" do
|
||||
context "when the actual value is truthy" do
|
||||
it "is true" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :truthy)[:value].should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "when the actual value is false" do
|
||||
it "is false" do
|
||||
value = false
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :truthy)[:value].should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "when the actual value is nil" do
|
||||
it "is false" do
|
||||
value = nil
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :truthy)[:value].should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the \"truthy\"" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("truthy")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the \"truthy\"" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(true)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("truthy")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "falsey" do
|
||||
describe "#matched?" do
|
||||
context "with a truthy value" do
|
||||
it "is false" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with false" do
|
||||
it "is true" do
|
||||
value = false
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with nil" do
|
||||
it "is true" do
|
||||
value = nil
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "contains the definition of falsey" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should match(/false or nil/i)
|
||||
end
|
||||
|
||||
it "is not prefixed with \"Not\"" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:to_s].should_not start_with(/not/i)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual value" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(value)
|
||||
end
|
||||
end
|
||||
|
||||
context "truthy" do
|
||||
context "when the actual value is truthy" do
|
||||
it "is true" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :truthy)[:value].should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "when the actual value is false" do
|
||||
it "is false" do
|
||||
value = false
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :truthy)[:value].should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "when the actual value is nil" do
|
||||
it "is false" do
|
||||
value = nil
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :truthy)[:value].should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the \"falsey\"" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("falsey")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the \"falsey\"" do
|
||||
value = 42
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TruthyMatcher.new(false)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("falsey")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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
|
|
@ -1,125 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::TypeMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
describe "#matched?" do
|
||||
context "with the same type" do
|
||||
it "is true" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TypeMatcher(String).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a different type" do
|
||||
it "is false" do
|
||||
value = "foobar"
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TypeMatcher(Int32).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with a parent type" do
|
||||
it "is true" do
|
||||
value = IO::Memory.new
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TypeMatcher(IO).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "with a child type" do
|
||||
it "is false" do
|
||||
value = Exception.new("foobar")
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TypeMatcher(ArgumentError).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "with a mix-in" do
|
||||
it "is true" do
|
||||
value = %i[a b c]
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TypeMatcher(Enumerable(Symbol)).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected type name" do
|
||||
value = %i[a b c]
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TypeMatcher(String).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(String)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual type name" do
|
||||
value = %i[a b c]
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TypeMatcher(String).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(typeof(value))
|
||||
end
|
||||
|
||||
it "is the runtime type name" do
|
||||
value = 42.as(Int32?)
|
||||
partial = new_partial(value)
|
||||
matcher = Spectator::Matchers::TypeMatcher(String).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(value.class)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::TypeMatcher(String).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected type" do
|
||||
partial = new_partial(42)
|
||||
matcher = Spectator::Matchers::TypeMatcher(String).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain("String")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
value = 42
|
||||
label = "everything"
|
||||
partial = new_partial(value, label)
|
||||
matcher = Spectator::Matchers::TypeMatcher(String).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected type" do
|
||||
partial = new_partial(42)
|
||||
matcher = Spectator::Matchers::TypeMatcher(String).new
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("String")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,474 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::UnorderedArrayMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
context "with identical arrays" do
|
||||
describe "#matched?" do
|
||||
it "is true" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected array" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual array" do
|
||||
array = %i[a b c]
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = [1, 2, 3]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array, label)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array = %i[a b c]
|
||||
label = "everything"
|
||||
partial = new_partial(array)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = [1, 2, 3]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with identical unordered arrays" do
|
||||
describe "#matched?" do
|
||||
it "is true" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[c a b]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[c a b]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(array2)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[c a b]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[c a b]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[c a b]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[c a b]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[c a b]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[c a b]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[c a b]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with arrays differing in size" do
|
||||
describe "#matched?" do
|
||||
it "is false" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected array" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(array2)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual array" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array1)
|
||||
end
|
||||
end
|
||||
|
||||
context "missing" do
|
||||
it "is the missing items" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
missing = match_data_value_sans_prefix(match_data.values, :missing)[:value].as(typeof(array2))
|
||||
missing.should contain(:f)
|
||||
end
|
||||
end
|
||||
|
||||
context "extra" do
|
||||
it "is the extra items" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
extra = match_data_value_sans_prefix(match_data.values, :extra)[:value].as(typeof(array1))
|
||||
extra.should contain(:b)
|
||||
extra.should contain(:d)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c d e]
|
||||
array2 = %i[a c e f]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with arrays differing in content" do
|
||||
describe "#matched?" do
|
||||
it "is false" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected" do
|
||||
it "is the expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :expected)[:value].should eq(array2)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual" do
|
||||
it "is the actual array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :actual)[:value].should eq(array1)
|
||||
end
|
||||
end
|
||||
|
||||
context "missing" do
|
||||
it "is the missing items" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
missing = match_data_value_sans_prefix(match_data.values, :missing)[:value].as(typeof(array2))
|
||||
missing.should contain(:x)
|
||||
missing.should contain(:y)
|
||||
missing.should contain(:z)
|
||||
end
|
||||
end
|
||||
|
||||
context "extra" do
|
||||
it "is the extra items" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
extra = match_data_value_sans_prefix(match_data.values, :extra)[:value].as(typeof(array1))
|
||||
extra.should contain(:a)
|
||||
extra.should contain(:b)
|
||||
extra.should contain(:c)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "mentions content" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain("content")
|
||||
end
|
||||
|
||||
it "contains the actual label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1, label)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
label = "everything"
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2, label)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected array" do
|
||||
array1 = %i[a b c]
|
||||
array2 = %i[x y z]
|
||||
partial = new_partial(array1)
|
||||
matcher = Spectator::Matchers::UnorderedArrayMatcher.new(array2)
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(array2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue