mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Move DSL-based code to subclass of SpectatorContext
This resolves a circular dependency.
This commit is contained in:
parent
67ac06e4d6
commit
6752c7c254
3 changed files with 25 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
||||||
require "./spectator/includes"
|
require "./spectator/includes"
|
||||||
require "./spectator_context"
|
require "./spectator_test_context"
|
||||||
|
|
||||||
# Module that contains all functionality related to Spectator.
|
# Module that contains all functionality related to Spectator.
|
||||||
module Spectator
|
module Spectator
|
||||||
|
@ -38,7 +38,7 @@ module Spectator
|
||||||
# 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 SpectatorContext
|
class ::SpectatorTestContext
|
||||||
# Pass off the description argument and block to `DSL::StructureDSL.describe`.
|
# Pass off the description 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({{description}}) {{block}}
|
describe({{description}}) {{block}}
|
||||||
|
|
|
@ -4,17 +4,4 @@
|
||||||
# This type is intentionally outside the `Spectator` module.
|
# This type is intentionally outside the `Spectator` module.
|
||||||
# The reason for this is to prevent name collision when using the DSL to define a spec.
|
# The reason for this is to prevent name collision when using the DSL to define a spec.
|
||||||
abstract class SpectatorContext
|
abstract class SpectatorContext
|
||||||
# Initial implicit subject for tests.
|
|
||||||
# This method should be overridden by example groups when an object is described.
|
|
||||||
private def _spectator_implicit_subject
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# Initial subject for tests.
|
|
||||||
# Returns the implicit subject.
|
|
||||||
# This method should be overridden when an explicit subject is defined by the DSL.
|
|
||||||
# TODO: Subject needs to be cached.
|
|
||||||
private def subject
|
|
||||||
_spectator_implicit_subject
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
23
src/spectator_test_context.cr
Normal file
23
src/spectator_test_context.cr
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
require "./spectator_context"
|
||||||
|
require "./spectator/dsl"
|
||||||
|
|
||||||
|
class SpectatorTestContext < SpectatorContext
|
||||||
|
include ::Spectator::DSL::Groups
|
||||||
|
|
||||||
|
# Initial implicit subject for tests.
|
||||||
|
# This method should be overridden by example groups when an object is described.
|
||||||
|
private def _spectator_implicit_subject
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# Initial subject for tests.
|
||||||
|
# Returns the implicit subject.
|
||||||
|
# This method should be overridden when an explicit subject is defined by the DSL.
|
||||||
|
# TODO: Subject needs to be cached.
|
||||||
|
private def subject
|
||||||
|
_spectator_implicit_subject
|
||||||
|
end
|
||||||
|
|
||||||
|
# def initialize(@spectator_test_values : ::Spectator::TestValues)
|
||||||
|
# end
|
||||||
|
end
|
Loading…
Reference in a new issue