mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Initial code to indirectly run example
This issolates the example code from the example class' attributes, such as #description, #run, and others.
This commit is contained in:
parent
700108f52f
commit
625a331745
1 changed files with 10 additions and 2 deletions
|
@ -167,10 +167,18 @@ module Spectator
|
|||
{% class_name = (safe_name.camelcase + "Example").id %}
|
||||
{% given_vars = ::Spectator::ContextDefinitions::ALL[parent_module.id][:given] %}
|
||||
{% var_names = given_vars.map { |v| v[:name] } %}
|
||||
class {{class_name.id}} < ::Spectator::Example
|
||||
class Example%example
|
||||
include ExampleDSL
|
||||
include Locals
|
||||
|
||||
def %run({{ var_names.join(", ").id }})
|
||||
{{block.body}}
|
||||
end
|
||||
end
|
||||
|
||||
class {{class_name.id}} < ::Spectator::Example
|
||||
include Locals
|
||||
|
||||
{% if given_vars.empty? %}
|
||||
def initialize(context)
|
||||
super(context)
|
||||
|
@ -185,7 +193,7 @@ module Spectator
|
|||
{% end %}
|
||||
|
||||
def run
|
||||
{{block.body}}
|
||||
Example%example.new.%run({{ var_names.join(", ").id }})
|
||||
end
|
||||
|
||||
def description
|
||||
|
|
Loading…
Reference in a new issue