mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Secondary initializer for missing label
Label is set to actual/expected stringified value if omitted.
This commit is contained in:
parent
9a77f8b7fd
commit
7f4690b042
5 changed files with 41 additions and 11 deletions
|
@ -10,7 +10,7 @@ describe Spectator::Expectations::ValueExpectationPartial do
|
|||
end
|
||||
|
||||
describe "#label" do
|
||||
context "with a non-empty string" do
|
||||
context "when provided" do
|
||||
it "contains the value passed to the constructor" do
|
||||
actual = 777
|
||||
label = "lucky"
|
||||
|
@ -19,10 +19,10 @@ describe Spectator::Expectations::ValueExpectationPartial do
|
|||
end
|
||||
end
|
||||
|
||||
context "with an empty string" do
|
||||
context "when omitted" do
|
||||
it "contains a stringified version of #actual" do
|
||||
actual = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new("", actual)
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(actual)
|
||||
partial.label.should eq(actual.to_s)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -85,6 +85,16 @@ describe Spectator::Matchers::EqualityMatcher do
|
|||
matcher = Spectator::Matchers::EqualityMatcher.new(label, value)
|
||||
matcher.message(partial).should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1.to_s, value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2)
|
||||
matcher.message(partial).should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
|
@ -100,7 +110,7 @@ describe Spectator::Matchers::EqualityMatcher do
|
|||
label = "everything"
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(label, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value.to_s, value)
|
||||
matcher.message(partial).should contain(label)
|
||||
matcher.negated_message(partial).should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expected label" do
|
||||
|
@ -108,7 +118,17 @@ describe Spectator::Matchers::EqualityMatcher do
|
|||
label = "everything"
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value.to_s, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(label, value)
|
||||
matcher.message(partial).should contain(label)
|
||||
matcher.negated_message(partial).should contain(label)
|
||||
end
|
||||
|
||||
context "when expected label is omitted" do
|
||||
it "contains stringified form of expected value" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1.to_s, value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2)
|
||||
matcher.negated_message(partial).should contain(value2.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue