mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Remove specs for change matchers (for now)
This commit is contained in:
parent
a56d6762c0
commit
e6599d5fe0
3 changed files with 0 additions and 541 deletions
|
@ -1,191 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::ChangeFromMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
context "with a static expression" do
|
||||
describe "#matched?" do
|
||||
it "is false" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 0 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(i) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with changing expression" do
|
||||
describe "#matched?" do
|
||||
it "is true" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(i) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected before" do
|
||||
it "is the expected value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(0) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"expected before").value.should eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual before" do
|
||||
it "is the initial value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(0) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"actual before").value.should eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "expected after" do
|
||||
it "is the negated initial value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(0) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected after")[:value].should eq(0)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected after")[:to_s].should start_with("Not ")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual after" do
|
||||
it "is the resulting value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(0) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"actual after").value.should eq(5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the action label" do
|
||||
i = 0
|
||||
label = "ACTION"
|
||||
partial = new_block_partial(label) { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(i) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(label, i) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the action label" do
|
||||
i = 0
|
||||
label = "ACTION"
|
||||
partial = new_block_partial(label) { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(i) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(label, i) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with the wrong initial value" do
|
||||
describe "#matched?" do
|
||||
it "is false" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected before" do
|
||||
it "is the expected value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"expected before").value.should eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual before" do
|
||||
it "is the initial value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"actual before").value.should eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "expected after" do
|
||||
it "is the negated initial value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected after")[:value].should eq(2)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected after")[:to_s].should start_with("Not ")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual after" do
|
||||
it "is the resulting value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"actual after").value.should eq(5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(label, 2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeFromMatcher.new(label, 2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,159 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::ChangeMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
context "with a static expression" do
|
||||
describe "#matched?" do
|
||||
it "is false" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 0 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with changing expression" do
|
||||
describe "#matched?" do
|
||||
it "is true" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "before" do
|
||||
it "is the initial value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :before).value.should eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "after" do
|
||||
it "is the resulting value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :after).value.should eq(5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the action label" do
|
||||
i = 0
|
||||
label = "ACTION"
|
||||
partial = new_block_partial(label) { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new(label) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the action label" do
|
||||
i = 0
|
||||
label = "ACTION"
|
||||
partial = new_block_partial(label) { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new(label) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#from" do
|
||||
it "returns a ChangeFromMatcher" do
|
||||
i = 0
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
matcher.from(0).should be_a(Spectator::Matchers::ChangeFromMatcher(Int32, Int32))
|
||||
end
|
||||
|
||||
it "passes along the expected from value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
match_data = matcher.from(0).match(partial)
|
||||
match_data_value_with_key(match_data.values, :"expected before").value.should eq(0)
|
||||
end
|
||||
|
||||
it "passes along the expression" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
matcher.from(0).match(partial)
|
||||
i.should eq(5) # Local scope `i` will be updated if the expression (closure) was passed on.
|
||||
end
|
||||
|
||||
it "passes along the label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new(label) { i }
|
||||
match_data = matcher.from(0).match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#to" do
|
||||
it "returns a ChangeToMatcher" do
|
||||
i = 0
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
matcher.to(0).should be_a(Spectator::Matchers::ChangeToMatcher(Int32, Int32))
|
||||
end
|
||||
|
||||
it "passes along the expected to value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
match_data = matcher.to(5).match(partial)
|
||||
match_data_value_with_key(match_data.values, :"expected after").value.should eq(5)
|
||||
end
|
||||
|
||||
it "passes along the expression" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new { i }
|
||||
matcher.to(5).match(partial)
|
||||
i.should eq(5) # Local scope `i` will be updated if the expression (closure) was passed on.
|
||||
end
|
||||
|
||||
it "passes along the label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeMatcher.new(label) { i }
|
||||
match_data = matcher.to(5).match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,191 +0,0 @@
|
|||
require "../spec_helper"
|
||||
|
||||
describe Spectator::Matchers::ChangeToMatcher do
|
||||
describe "#match" do
|
||||
context "returned MatchData" do
|
||||
context "with a static expression" do
|
||||
describe "#matched?" do
|
||||
it "is false" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 0 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(i) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with changing expression" do
|
||||
describe "#matched?" do
|
||||
it "is true" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(i + 5) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected before" do
|
||||
it "is the negated resulting value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(5) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected before")[:value].should eq(5)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected before")[:to_s].should start_with("Not ")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual before" do
|
||||
it "is the initial value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(5) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"actual before").value.should eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "expected after" do
|
||||
it "is the expected value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(5) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"expected after").value.should eq(5)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual after" do
|
||||
it "is the resulting value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(5) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"actual after").value.should eq(5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the action label" do
|
||||
i = 0
|
||||
label = "ACTION"
|
||||
partial = new_block_partial(label) { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(i + 5) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(label, i + 5) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the action label" do
|
||||
i = 0
|
||||
label = "ACTION"
|
||||
partial = new_block_partial(label) { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(i + 5) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(label, i + 5) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with the wrong final value" do
|
||||
describe "#matched?" do
|
||||
it "is false" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.matched?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#values" do
|
||||
context "expected before" do
|
||||
it "is the negated resulting value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected before")[:value].should eq(2)
|
||||
match_data_value_sans_prefix(match_data.values, :"expected before")[:to_s].should start_with("Not ")
|
||||
end
|
||||
end
|
||||
|
||||
context "actual before" do
|
||||
it "is the initial value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"actual before").value.should eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "expected after" do
|
||||
it "is the expected value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"expected after").value.should eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context "actual after" do
|
||||
it "is the resulting value" do
|
||||
i = 0
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data_value_with_key(match_data.values, :"actual after").value.should eq(5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#message" do
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(label, 2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.message.should contain(label)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#negated_message" do
|
||||
it "contains the expression label" do
|
||||
i = 0
|
||||
label = "EXPRESSION"
|
||||
partial = new_block_partial { i += 5 }
|
||||
matcher = Spectator::Matchers::ChangeToMatcher.new(label, 2) { i }
|
||||
match_data = matcher.match(partial)
|
||||
match_data.negated_message.should contain(label)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue