2019-02-13 05:33:48 +00:00
|
|
|
require "./spec_helper"
|
|
|
|
|
|
|
|
describe Spectator::TestSuite do
|
|
|
|
describe "#each" do
|
|
|
|
it "yields each example" do
|
|
|
|
group = Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty, Spectator::ExampleConditions.empty)
|
2019-04-06 23:20:12 +00:00
|
|
|
group.children = Array.new(5) do
|
2019-02-13 05:33:48 +00:00
|
|
|
PassingExample.new(group, Spectator::Internals::SampleValues.empty).as(Spectator::ExampleComponent)
|
|
|
|
end
|
2019-03-25 17:35:39 +00:00
|
|
|
test_suite = Spectator::TestSuite.new(group, Spectator::NullExampleFilter.new)
|
2019-02-13 05:33:48 +00:00
|
|
|
examples = [] of Spectator::Example
|
|
|
|
test_suite.each do |example|
|
|
|
|
examples << example
|
|
|
|
end
|
|
|
|
examples.should eq(group.children)
|
|
|
|
end
|
2019-03-25 17:35:39 +00:00
|
|
|
|
|
|
|
it "skips examples not in the filter" do
|
|
|
|
group = Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty, Spectator::ExampleConditions.empty)
|
2019-04-06 23:20:12 +00:00
|
|
|
group.children = Array.new(5) do
|
2019-03-25 17:35:39 +00:00
|
|
|
PassingExample.new(group, Spectator::Internals::SampleValues.empty).as(Spectator::ExampleComponent)
|
|
|
|
end
|
|
|
|
test_suite = Spectator::TestSuite.new(group, Spectator::CompositeExampleFilter.new([] of Spectator::ExampleFilter))
|
|
|
|
examples = [] of Spectator::Example
|
|
|
|
test_suite.each do |example|
|
|
|
|
examples << example
|
|
|
|
end
|
|
|
|
examples.should be_empty
|
|
|
|
end
|
2019-02-13 05:33:48 +00:00
|
|
|
end
|
|
|
|
end
|