mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Remove Locals sub-module
This allows for seamless helper methods.
This commit is contained in:
parent
718be70edd
commit
9b07f669ed
3 changed files with 36 additions and 47 deletions
|
@ -93,7 +93,7 @@ In no particular order, features that have been implemented and are planned:
|
|||
- [ ] Before and after hooks - `before_each`, `before_all`, `after_each`, `after_all`, `around_each`
|
||||
- [ ] One-liner syntax
|
||||
- [ ] Should syntax
|
||||
- [ ] Helper methods and modules
|
||||
- [X] Helper methods and modules
|
||||
- [ ] Aliasing - custom example group types with preset attributes
|
||||
- [ ] Pending tests - `pending`
|
||||
- [ ] Shared examples - `behaves_like`, `include_examples`
|
||||
|
|
|
@ -24,8 +24,7 @@ module Spectator
|
|||
} %}
|
||||
::Spectator::ContextDefinitions::MAPPING[{{absolute_module_name.stringify}}] = Context.new({{what_arg}}, ::Spectator::ContextDefinitions::MAPPING[{{parent_module.stringify}}])
|
||||
|
||||
module Locals
|
||||
include {{parent_module}}::Locals
|
||||
include {{parent_module}}
|
||||
|
||||
{% if what.is_a?(Path) || what.is_a?(Generic) %}
|
||||
def described_class
|
||||
|
@ -39,7 +38,6 @@ module Spectator
|
|||
described_class.new
|
||||
end
|
||||
{% end %}
|
||||
end
|
||||
|
||||
{{block.body}}
|
||||
end
|
||||
|
@ -54,7 +52,6 @@ module Spectator
|
|||
{% raise "Duplicate given variable name \"#{var_name.id}\"" %}
|
||||
{% end %}
|
||||
|
||||
module Locals
|
||||
@%wrapper : ValueWrapper?
|
||||
|
||||
private def %collection
|
||||
|
@ -73,7 +70,6 @@ module Spectator
|
|||
private def {{setter}}(value)
|
||||
@%wrapper = TypedValueWrapper(typeof(%collection_first)).new(value)
|
||||
end
|
||||
end
|
||||
|
||||
\{% ::Spectator::ContextDefinitions::ALL[@type.id][:given] << {name: "{{var_name}}".id, collection: "{{collection}}".id, setter: "{{setter}}".id} %}
|
||||
|
||||
|
@ -88,7 +84,6 @@ module Spectator
|
|||
macro let(name, &block)
|
||||
let!(%value) {{block}}
|
||||
|
||||
module Locals
|
||||
@%wrapper : ValueWrapper?
|
||||
|
||||
def {{name.id}}
|
||||
|
@ -101,15 +96,12 @@ module Spectator
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
macro let!(name, &block)
|
||||
module Locals
|
||||
def {{name.id}}
|
||||
{{block.body}}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
macro before_all(&block)
|
||||
::Spectator::ContextDefinitions::MAPPING[{{@type.stringify}}].before_all_hooks << -> {{block}}
|
||||
|
@ -143,7 +135,7 @@ module Spectator
|
|||
{% var_names = given_vars.map { |v| v[:name] } %}
|
||||
class Example%example
|
||||
include ExampleDSL
|
||||
include Locals
|
||||
include {{parent_module}}
|
||||
|
||||
def %run({{ var_names.join(", ").id }})
|
||||
{{block.body}}
|
||||
|
@ -151,7 +143,7 @@ module Spectator
|
|||
end
|
||||
|
||||
class {{class_name.id}} < ::Spectator::Example
|
||||
include Locals
|
||||
include {{parent_module}}
|
||||
|
||||
{% if given_vars.empty? %}
|
||||
def initialize(context)
|
||||
|
|
|
@ -10,8 +10,5 @@ module Spectator
|
|||
given: [] of Object
|
||||
} %}
|
||||
::Spectator::ContextDefinitions::MAPPING[{{@type.stringify}}] = ::Spectator::Context::ROOT
|
||||
|
||||
module Locals
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue