mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix specs to work with new Expectation type
This commit is contained in:
parent
35b59854ec
commit
f0204a32ea
9 changed files with 379 additions and 395 deletions
|
@ -1,120 +1,27 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Expectations::ValueExpectation do
|
||||
describe "#eval" do
|
||||
context "with a successful match" do
|
||||
it "returns a successful result" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.eval.successful?.should be_true
|
||||
end
|
||||
|
||||
it "reports a successful actual message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.eval.actual_message.should eq(expectation.message)
|
||||
end
|
||||
end
|
||||
|
||||
context "with an unsuccessful match" do
|
||||
it "returns an unsuccessful result" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.eval.successful?.should be_false
|
||||
end
|
||||
|
||||
it "reports an unsuccessful actual message" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.eval.actual_message.should eq(expectation.negated_message)
|
||||
end
|
||||
end
|
||||
|
||||
it "reports a non-negated expected message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
expectation.eval.expected_message.should eq(expectation.message)
|
||||
end
|
||||
|
||||
context "negated" do
|
||||
context "with a successful match" do
|
||||
it "returns an unsuccessful result" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.eval(true).successful?.should be_false
|
||||
end
|
||||
|
||||
it "reports an unsuccessful actual message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.eval(true).actual_message.should eq(expectation.negated_message)
|
||||
end
|
||||
end
|
||||
|
||||
context "with an unsuccessful match" do
|
||||
it "returns a successful result" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.eval(true).successful?.should be_true
|
||||
end
|
||||
|
||||
it "reports a successful actual message" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.eval(true).actual_message.should eq(expectation.message)
|
||||
end
|
||||
end
|
||||
|
||||
it "reports a negated expected message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
expectation.eval(true).expected_message.should eq(expectation.negated_message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#satisifed?" do
|
||||
context "with a successful match" do
|
||||
it "is true" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value.to_s, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value.to_s, value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(true, false, partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.satisfied?.should be_true
|
||||
end
|
||||
|
||||
context "when negated" do
|
||||
it "is false" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value.to_s, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value.to_s, value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(true, true, partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.satisfied?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an unsuccessful match" do
|
||||
|
@ -123,30 +30,118 @@ describe Spectator::Expectations::ValueExpectation do
|
|||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1.to_s, value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2.to_s, value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(false, false, partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.satisfied?.should be_false
|
||||
end
|
||||
|
||||
context "when negated" do
|
||||
it "is true" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1.to_s, value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2.to_s, value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(false, true, partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.satisfied?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "equals the matcher's #message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value.to_s, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value.to_s, value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
expectation.message.should eq(matcher.message(partial))
|
||||
describe "#actual_message" do
|
||||
context "with a successful match" do
|
||||
it "equals the matcher's #message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value.to_s, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value.to_s, value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(true, false, partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.actual_message.should eq(matcher.message(partial))
|
||||
end
|
||||
|
||||
context "when negated" do
|
||||
it "equals the matcher's #negated_message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value.to_s, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value.to_s, value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(true, true, partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.actual_message.should eq(matcher.negated_message(partial))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an unsuccessful match" do
|
||||
it "equals the matcher's #negated_message" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1.to_s, value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2.to_s, value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(false, false, partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.actual_message.should eq(matcher.negated_message(partial))
|
||||
end
|
||||
|
||||
context "when negated" do
|
||||
it "equals the matcher's #message" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1.to_s, value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2.to_s, value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(false, true, partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.actual_message.should eq(matcher.message(partial))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "equals the matcher's #negated_message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value.to_s, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value.to_s, value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(partial, matcher)
|
||||
expectation.negated_message.should eq(matcher.negated_message(partial))
|
||||
describe "#expected_message" do
|
||||
context "with a successful match" do
|
||||
it "equals the matcher's #message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value.to_s, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value.to_s, value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(true, false, partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.expected_message.should eq(matcher.message(partial))
|
||||
end
|
||||
|
||||
context "when negated" do
|
||||
it "equals the matcher's #negated_message" do
|
||||
value = 42
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value.to_s, value)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value.to_s, value)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(true, true, partial, matcher)
|
||||
matcher.match?(partial).should be_true # Sanity check.
|
||||
expectation.expected_message.should eq(matcher.negated_message(partial))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with an unsuccessful match" do
|
||||
it "equals the matcher's #message" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1.to_s, value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2.to_s, value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(false, false, partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.expected_message.should eq(matcher.message(partial))
|
||||
end
|
||||
|
||||
context "when negated" do
|
||||
it "equals the matcher's #negated_message" do
|
||||
value1 = 42
|
||||
value2 = 777
|
||||
partial = Spectator::Expectations::ValueExpectationPartial.new(value1.to_s, value1)
|
||||
matcher = Spectator::Matchers::EqualityMatcher.new(value2.to_s, value2)
|
||||
expectation = Spectator::Expectations::ValueExpectation.new(false, true, partial, matcher)
|
||||
matcher.match?(partial).should be_false # Sanity check.
|
||||
expectation.expected_message.should eq(matcher.negated_message(partial))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue