diff --git a/src/spectator/dsl/builder.cr b/src/spectator/dsl/builder.cr index fd3e42a..638b39d 100644 --- a/src/spectator/dsl/builder.cr +++ b/src/spectator/dsl/builder.cr @@ -1,4 +1,5 @@ -require "../spec/builder" +require "../spec" +require "../spec_builder" module Spectator::DSL # Incrementally builds up a test spec from the DSL. @@ -7,7 +8,7 @@ module Spectator::DSL extend self # Underlying spec builder. - @@builder = Spec::Builder.new + @@builder = SpecBuilder.new # Defines a new example group and pushes it onto the group stack. # Examples and groups defined after calling this method will be nested under the new group. diff --git a/src/spectator/spec/builder.cr b/src/spectator/spec_builder.cr similarity index 95% rename from src/spectator/spec/builder.cr rename to src/spectator/spec_builder.cr index 9071b85..fad4f22 100644 --- a/src/spectator/spec/builder.cr +++ b/src/spectator/spec_builder.cr @@ -1,13 +1,13 @@ -require "../example" -require "../example_context_method" -require "../example_group" +require "./example" +require "./example_context_method" +require "./example_group" module Spectator # Progressively builds a test spec. # # A stack is used to track the current example group. # Adding an example or group will nest it under the group at the top of the stack. - class Spec::Builder + class SpecBuilder # Stack tracking the current group. # The bottom of the stack (first element) is the root group. # The root group should never be removed. @@ -86,7 +86,9 @@ module Spectator # Raises an error if there were not symmetrical calls to `#start_group` and `#end_group`. # This would indicate a logical error somewhere in Spectator or an extension of it. def build : Spec - raise NotImplementedError.new("#build") + raise "Mismatched start and end groups" unless root? + + Spec.new(root_group) end # Checks if the current group is the root group.