Store "what" string in context

This commit is contained in:
Michael Miller 2018-09-11 15:54:00 -06:00
parent 284e10482a
commit d8621fc43e
3 changed files with 4 additions and 3 deletions

View file

@ -4,7 +4,7 @@ require "./spectator/*"
module Spectator
VERSION = "0.1.0"
ROOT_CONTEXT = Context.new
ROOT_CONTEXT = Context.new("ROOT")
macro describe(what, source_file = __FILE__, source_line = __LINE__, &block)
module Spectator

View file

@ -2,6 +2,7 @@ require "./example"
module Spectator
class Context
getter what : String
getter parent : Context?
getter examples = [] of Example
getter contexts = [] of Context
@ -14,7 +15,7 @@ module Spectator
@before_all_hooks_run = false
@after_all_hooks_run = false
def initialize(@parent = nil)
def initialize(@what, @parent = nil)
if (parent = @parent)
parent.contexts << self
end

View file

@ -49,7 +49,7 @@ module Spectator
include ::Spectator::DSL
PARENT_CONTEXT = {{context_module.id}}::CURRENT_CONTEXT
CURRENT_CONTEXT = ::Spectator::Context.new(PARENT_CONTEXT)
CURRENT_CONTEXT = ::Spectator::Context.new({{what.stringify}}, PARENT_CONTEXT)
CONTEXT_MODULE = {{context_module.id}}::{{module_name.id}}
GIVEN_VARIABLES = [