2018-10-18 23:54:43 +00:00
|
|
|
require "../spec_helper"
|
|
|
|
|
2019-01-31 20:30:09 +00:00
|
|
|
describe Spectator::Expectations::Expectation do
|
2018-11-14 09:15:55 +00:00
|
|
|
describe "#satisifed?" do
|
2018-10-18 23:54:43 +00:00
|
|
|
context "with a successful match" do
|
2018-11-14 09:15:55 +00:00
|
|
|
it "is true" do
|
2018-10-18 23:54:43 +00:00
|
|
|
value = 42
|
2019-08-09 21:32:22 +00:00
|
|
|
matcher = new_matcher(value)
|
|
|
|
partial = new_partial(value)
|
|
|
|
match_data = matcher.match(partial.actual)
|
2019-02-28 22:17:12 +00:00
|
|
|
match_data.matched?.should be_true # Sanity check.
|
2019-08-09 21:32:22 +00:00
|
|
|
expectation = Spectator::Expectations::Expectation.new(match_data, partial.source)
|
2018-11-14 09:15:55 +00:00
|
|
|
expectation.satisfied?.should be_true
|
2018-10-18 23:54:43 +00:00
|
|
|
end
|
|
|
|
|
2018-11-14 09:15:55 +00:00
|
|
|
context "when negated" do
|
|
|
|
it "is false" do
|
|
|
|
value = 42
|
2019-08-09 21:32:22 +00:00
|
|
|
matcher = new_matcher(value)
|
|
|
|
partial = new_partial(value)
|
|
|
|
match_data = matcher.negated_match(partial.actual)
|
|
|
|
match_data.matched?.should be_false # Sanity check.
|
|
|
|
expectation = Spectator::Expectations::Expectation.new(match_data, partial.source)
|
2018-11-14 09:15:55 +00:00
|
|
|
expectation.satisfied?.should be_false
|
|
|
|
end
|
2018-10-18 23:54:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with an unsuccessful match" do
|
2018-11-14 09:15:55 +00:00
|
|
|
it "is false" do
|
2019-08-09 21:32:22 +00:00
|
|
|
matcher = new_matcher(42)
|
|
|
|
partial = new_partial(777)
|
|
|
|
match_data = matcher.match(partial.actual)
|
2019-02-28 22:17:12 +00:00
|
|
|
match_data.matched?.should be_false # Sanity check.
|
2019-08-09 21:32:22 +00:00
|
|
|
expectation = Spectator::Expectations::Expectation.new(match_data, partial.source)
|
2018-11-14 09:15:55 +00:00
|
|
|
expectation.satisfied?.should be_false
|
2018-10-18 23:54:43 +00:00
|
|
|
end
|
|
|
|
|
2018-11-14 09:15:55 +00:00
|
|
|
context "when negated" do
|
|
|
|
it "is true" do
|
2019-08-09 21:32:22 +00:00
|
|
|
matcher = new_matcher(42)
|
|
|
|
partial = new_partial(777)
|
|
|
|
match_data = matcher.negated_match(partial.actual)
|
2019-02-28 22:17:12 +00:00
|
|
|
match_data.matched?.should be_true # Sanity check.
|
2019-08-09 21:32:22 +00:00
|
|
|
expectation = Spectator::Expectations::Expectation.new(match_data, partial.source)
|
|
|
|
expectation.satisfied?.should be_true
|
2018-11-14 09:15:55 +00:00
|
|
|
end
|
|
|
|
end
|
2018-10-18 23:54:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|