Change test root to SpectatorTest

This commit is contained in:
Michael Miller 2019-08-31 13:11:59 -06:00
parent 752b7f0ffa
commit 00a2495027
2 changed files with 13 additions and 5 deletions

View file

@ -1,4 +1,5 @@
require "./spectator/includes" require "./spectator/includes"
require "./spectator_test"
# Module that contains all functionality related to Spectator. # Module that contains all functionality related to Spectator.
module Spectator module Spectator
@ -32,15 +33,12 @@ module Spectator
# We don't want the spec code to accidentally pickup types and values from the `Spectator` module. # We don't want the spec code to accidentally pickup types and values from the `Spectator` module.
# Another reason is that we need a root module to put all examples and groups in. # Another reason is that we need a root module to put all examples and groups in.
# And lastly, the spec DSL needs to be given to the block of code somehow. # And lastly, the spec DSL needs to be given to the block of code somehow.
# The DSL is included in the `SpectatorExamples` module. # The DSL is included in the `SpectatorTest` class.
# #
# For more information on how the DSL works, see the `DSL` module. # For more information on how the DSL works, see the `DSL` module.
# Root-level class that contains all examples and example groups. # Root-level class that contains all examples and example groups.
class SpectatorExamples class SpectatorTest
include ::Spectator::DSL::StructureDSL # Include the DSL for creating groups, example, and more.
include ::Spectator::DSL::ExampleDSL # Mix in methods and macros specifically for example DSL.
# Pass off the "what" argument and block to `DSL::StructureDSL.describe`. # Pass off the "what" argument and block to `DSL::StructureDSL.describe`.
# That method will handle creating a new group for this spec. # That method will handle creating a new group for this spec.
describe({{what}}) {{block}} describe({{what}}) {{block}}

10
src/spectator_test.cr Normal file
View file

@ -0,0 +1,10 @@
require "./spectator/dsl/example_dsl"
require "./spectator/dsl/structure_dsl"
# Root-level class that all tests inherit from and are contained in.
# This class is intentionally outside of the scope of Spectator,
# so that the namespace isn't leaked into tests unexpectedly.
class SpectatorTest
include ::Spectator::DSL::StructureDSL # Include the DSL for creating groups, example, and more.
include ::Spectator::DSL::ExampleDSL # Mix in methods and macros specifically for example DSL.
end