mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add getter for wrapped instance
This commit is contained in:
parent
b53e1b60d8
commit
abf7c8831c
3 changed files with 12 additions and 1 deletions
|
@ -1002,6 +1002,9 @@ module Spectator::DSL
|
|||
@instance = {{wrapper_class_name.id}}.new(sample_values)
|
||||
end
|
||||
|
||||
# Retrieves the underlying, wrapped instance.
|
||||
getter instance
|
||||
|
||||
# Add the block's content if one was provided.
|
||||
{% if block.is_a?(Block) %}
|
||||
{{block.body}}
|
||||
|
|
|
@ -14,6 +14,11 @@ module Spectator
|
|||
"DUMMY"
|
||||
end
|
||||
|
||||
# Dummy instance.
|
||||
def instance
|
||||
nil
|
||||
end
|
||||
|
||||
# Dummy run that does nothing.
|
||||
def run_instance
|
||||
raise "You shouldn't be running this."
|
||||
|
|
|
@ -2,7 +2,7 @@ require "./example_component"
|
|||
|
||||
module Spectator
|
||||
# Base class for all types of examples.
|
||||
# Concrete types must implement the `#run_inner` and `#what` methods.
|
||||
# Concrete types must implement the `#run_inner`, `#what`, and `#instance` methods.
|
||||
abstract class Example < ExampleComponent
|
||||
# Indicates whether the example has already been run.
|
||||
getter? finished = false
|
||||
|
@ -10,6 +10,9 @@ module Spectator
|
|||
# Group that the example belongs to.
|
||||
getter group : ExampleGroup
|
||||
|
||||
# Retrieves the internal wrapped instance.
|
||||
abstract def instance
|
||||
|
||||
# Runs the example code.
|
||||
# A result is returned, which represents the outcome of the test.
|
||||
# An example can be run only once.
|
||||
|
|
Loading…
Reference in a new issue