From e6599d5fe062fc4b6927c39ce0d2c9c685aff034 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sat, 10 Aug 2019 11:40:33 -0600 Subject: [PATCH] Remove specs for change matchers (for now) --- spec/matchers/change_from_matcher_spec.cr | 191 ---------------------- spec/matchers/change_matcher_spec.cr | 159 ------------------ spec/matchers/change_to_matcher_spec.cr | 191 ---------------------- 3 files changed, 541 deletions(-) delete mode 100644 spec/matchers/change_from_matcher_spec.cr delete mode 100644 spec/matchers/change_matcher_spec.cr delete mode 100644 spec/matchers/change_to_matcher_spec.cr diff --git a/spec/matchers/change_from_matcher_spec.cr b/spec/matchers/change_from_matcher_spec.cr deleted file mode 100644 index 521c117..0000000 --- a/spec/matchers/change_from_matcher_spec.cr +++ /dev/null @@ -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 diff --git a/spec/matchers/change_matcher_spec.cr b/spec/matchers/change_matcher_spec.cr deleted file mode 100644 index d153b61..0000000 --- a/spec/matchers/change_matcher_spec.cr +++ /dev/null @@ -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 diff --git a/spec/matchers/change_to_matcher_spec.cr b/spec/matchers/change_to_matcher_spec.cr deleted file mode 100644 index 34ab71f..0000000 --- a/spec/matchers/change_to_matcher_spec.cr +++ /dev/null @@ -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