Rename "context" to "locals"

Remove possible confusion around variables (let and subject) and context
keyword.
This commit is contained in:
Michael Miller 2018-09-04 16:17:33 -06:00
parent de55e31407
commit 7ff91b4fc6
2 changed files with 9 additions and 9 deletions

View file

@ -9,14 +9,14 @@ module Spectator
macro context(what, source_file = __FILE__, source_line = __LINE__, type = "Context", &block)
{% safe_name = what.id.stringify.gsub(/\W+/, "_") %}
{% module_name = (type.id + safe_name.camelcase).id %}
{% parent_context_name = PARENT_CONTEXT_NAME %}
{% parent_locals_module = PARENT_LOCALS_MODULE %}
module {{module_name.id}}
include ::Spectator::DSL
PARENT_CONTEXT_NAME = {{parent_context_name.id}}::{{module_name.id}}
PARENT_LOCALS_MODULE = {{parent_locals_module.id}}::{{module_name.id}}
module Context
include {{parent_context_name.id}}::Context
module Locals
include {{parent_locals_module.id}}::Locals
end
{{block.body}}
@ -27,7 +27,7 @@ module Spectator
{% safe_name = description.id.stringify.gsub(/\W+/, "_") %}
{% class_name = (safe_name.camelcase + "Example").id %}
class {{class_name.id}} < ::Spectator::Example
include Context
include Locals
def source
Source.new({{source_file}}, {{source_line}})
@ -52,7 +52,7 @@ module Spectator
macro let(name, &block)
let!({{name}}!) {{block}}
module Context
module Locals
@_%wrapper : ValueWrapper?
def {{name.id}}
@ -68,7 +68,7 @@ module Spectator
end
macro let!(name, &block)
module Context
module Locals
def {{name.id}}
{{block.body}}
end

View file

@ -4,9 +4,9 @@ module Spectator
module Examples
include ::Spectator::DSL
PARENT_CONTEXT_NAME = ::Spectator::Examples
PARENT_LOCALS_MODULE = ::Spectator::Examples
module Context
module Locals
end
end
end