2018-11-02 02:25:38 +00:00
|
|
|
require "../spec_helper"
|
|
|
|
|
|
|
|
describe Spectator::DSL::ExampleFactory do
|
|
|
|
describe "#build" do
|
|
|
|
it "creates an example of the correct type" do
|
|
|
|
factory = Spectator::DSL::ExampleFactory.new(SpyExample)
|
2019-01-11 17:09:40 +00:00
|
|
|
group = Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty, Spectator::ExampleConditions.empty)
|
2018-11-02 02:25:38 +00:00
|
|
|
example = factory.build(group, Spectator::Internals::SampleValues.empty)
|
|
|
|
example.should be_a(SpyExample)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "passes along the group" do
|
|
|
|
factory = Spectator::DSL::ExampleFactory.new(SpyExample)
|
2019-01-11 17:09:40 +00:00
|
|
|
group = Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty, Spectator::ExampleConditions.empty)
|
2018-11-02 02:25:38 +00:00
|
|
|
example = factory.build(group, Spectator::Internals::SampleValues.empty)
|
|
|
|
example.group.should eq(group)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "passes along the sample values" do
|
|
|
|
factory = Spectator::DSL::ExampleFactory.new(SpyExample)
|
2019-01-11 17:09:40 +00:00
|
|
|
group = Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty, Spectator::ExampleConditions.empty)
|
2018-11-02 02:25:38 +00:00
|
|
|
values = Spectator::Internals::SampleValues.empty.add(:foo, "foo", 12345)
|
|
|
|
example = factory.build(group, values)
|
|
|
|
example.as(SpyExample).sample_values.should eq(values)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|