Move example filters from === to their own types

This commit is contained in:
Michael Miller 2019-03-25 10:51:50 -06:00
parent b2ab579d8a
commit a3c1892465
11 changed files with 113 additions and 160 deletions

View file

@ -0,0 +1,21 @@
require "./spec_helper"
describe Spectator::LineExampleFilter do
describe "#includes?" do
context "with a matching example" do
it "is true" do
example = PassingExample.create
filter = Spectator::LineExampleFilter.new(example.source.line)
filter.includes?(example).should be_true
end
end
context "with a non-matching example" do
it "is false" do
example = PassingExample.create
filter = Spectator::LineExampleFilter.new(example.source.line + 5)
filter.includes?(example).should be_false
end
end
end
end

View file

@ -0,0 +1,21 @@
require "./spec_helper"
describe Spectator::NameExampleFilter do
describe "#includes?" do
context "with a matching example" do
it "is true" do
example = PassingExample.create
filter = Spectator::NameExampleFilter.new(example.to_s)
filter.includes?(example).should be_true
end
end
context "with a non-matching example" do
it "is false" do
example = PassingExample.create
filter = Spectator::NameExampleFilter.new("BOGUS")
filter.includes?(example).should be_false
end
end
end
end

View file

@ -119,66 +119,4 @@ describe Spectator::PendingExample do
example.to_s.should contain(group.what.to_s)
end
end
describe "#===" do
context "with a matching Regex" do
it "is true" do
example = new_pending_example
regex = Regex.new(Regex.escape(example.what))
(example === regex).should be_true
end
end
context "with a non-matching Regex" do
it "is false" do
example = new_pending_example
regex = /BOGUS/
(example === regex).should be_false
end
end
context "with a String equal to the name" do
it "is true" do
example = new_pending_example
(example === example.to_s).should be_true
end
end
context "with a String different than the name" do
it "is false" do
example = new_pending_example
(example === "BOGUS").should be_false
end
end
context "with a matching source location" do
it "is true" do
example = new_pending_example
(example === example.source).should be_true
end
end
context "with a non-matching source location" do
it "is false" do
example = new_pending_example
source = Spectator::Source.new(__FILE__, __LINE__)
(example === source).should be_false
end
end
context "with a matching source line" do
it "is true" do
example = new_pending_example
(example === example.source.line).should be_true
end
end
context "with a non-matching source line" do
it "is false" do
example = new_pending_example
line = example.source.line + 5
(example === line).should be_false
end
end
end
end

View file

@ -1565,66 +1565,4 @@ describe Spectator::RunnableExample do
end
end
end
describe "#===" do
context "with a matching Regex" do
it "is true" do
example = new_runnable_example
regex = Regex.new(Regex.escape(example.what))
(example === regex).should be_true
end
end
context "with a non-matching Regex" do
it "is false" do
example = new_runnable_example
regex = /BOGUS/
(example === regex).should be_false
end
end
context "with a String equal to the name" do
it "is true" do
example = new_runnable_example
(example === example.to_s).should be_true
end
end
context "with a String different than the name" do
it "is false" do
example = new_runnable_example
(example === "BOGUS").should be_false
end
end
context "with a matching source location" do
it "is true" do
example = new_runnable_example
(example === example.source).should be_true
end
end
context "with a non-matching source location" do
it "is false" do
example = new_runnable_example
source = Spectator::Source.new(__FILE__, __LINE__)
(example === source).should be_false
end
end
context "with a matching source line" do
it "is true" do
example = new_runnable_example
(example === example.source.line).should be_true
end
end
context "with a non-matching source line" do
it "is false" do
example = new_runnable_example
line = example.source.line + 5
(example === line).should be_false
end
end
end
end

View file

@ -0,0 +1,22 @@
require "./spec_helper"
describe Spectator::SourceExampleFilter do
describe "#includes?" do
context "with a matching example" do
it "is true" do
example = PassingExample.create
filter = Spectator::SourceExampleFilter.new(example.source)
filter.includes?(example).should be_true
end
end
context "with a non-matching example" do
it "is false" do
example = PassingExample.create
source = Spectator::Source.new(__FILE__, __LINE__)
filter = Spectator::SourceExampleFilter.new(source)
filter.includes?(example).should be_false
end
end
end
end