From ffdc0c40acbf9b493b5132ea4dfac71a79082077 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 1 Nov 2018 20:25:38 -0600 Subject: [PATCH] Add spec for ExampleFactory --- spec/dsl/example_factory_spec.cr | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 spec/dsl/example_factory_spec.cr diff --git a/spec/dsl/example_factory_spec.cr b/spec/dsl/example_factory_spec.cr new file mode 100644 index 0000000..1088ec4 --- /dev/null +++ b/spec/dsl/example_factory_spec.cr @@ -0,0 +1,27 @@ +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) + group = Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty) + 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) + group = Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty) + 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) + group = Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty) + 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