mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add symbolic attribute to example components
This is used to determine whether a type or method is referenced.
This commit is contained in:
parent
968775a5c3
commit
8339784492
6 changed files with 36 additions and 3 deletions
|
@ -16,7 +16,8 @@ module Spectator::DSL
|
||||||
# ```
|
# ```
|
||||||
# The value would be "String" for the describe block
|
# The value would be "String" for the describe block
|
||||||
# and "with an empty string" for the context block.
|
# and "with an empty string" for the context block.
|
||||||
def initialize(@what : String)
|
# Use a `Symbol` when referencing a type name.
|
||||||
|
def initialize(@what : Symbol | String)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds the example group.
|
# Builds the example group.
|
||||||
|
|
|
@ -271,7 +271,15 @@ module Spectator::DSL
|
||||||
|
|
||||||
# Start a new group.
|
# Start a new group.
|
||||||
::Spectator::DSL::Builder.start_group(
|
::Spectator::DSL::Builder.start_group(
|
||||||
{{what.is_a?(StringLiteral) ? what : what.stringify}}
|
{% if what.is_a?(StringLiteral) %}
|
||||||
|
{% if what.starts_with?("#") || what.starts_with?(".") %}
|
||||||
|
{{what.id.symbolize}}
|
||||||
|
{% else %}
|
||||||
|
{{what}}
|
||||||
|
{% end %}
|
||||||
|
{% else %}
|
||||||
|
{{what.symbolize}}
|
||||||
|
{% end %}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Nest the block's content in the module.
|
# Nest the block's content in the module.
|
||||||
|
@ -1487,6 +1495,11 @@ module Spectator::DSL
|
||||||
# Retrieves the underlying, wrapped test code.
|
# Retrieves the underlying, wrapped test code.
|
||||||
getter instance
|
getter instance
|
||||||
|
|
||||||
|
# Indicates whether the example references a method.
|
||||||
|
def symbolic?
|
||||||
|
{{what.starts_with?('#') ? true : false}}
|
||||||
|
end
|
||||||
|
|
||||||
# Add the block's content if one was provided.
|
# Add the block's content if one was provided.
|
||||||
{% if block.is_a?(Block) %}
|
{% if block.is_a?(Block) %}
|
||||||
{{block.body}}
|
{{block.body}}
|
||||||
|
|
|
@ -14,6 +14,11 @@ module Spectator
|
||||||
"DUMMY"
|
"DUMMY"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Dummy symbolic flag.
|
||||||
|
def symbolic?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
# Dummy source.
|
# Dummy source.
|
||||||
def source
|
def source
|
||||||
Source.new(__FILE__, __LINE__)
|
Source.new(__FILE__, __LINE__)
|
||||||
|
|
|
@ -13,5 +13,8 @@ module Spectator
|
||||||
|
|
||||||
# Lookup the example with the specified index.
|
# Lookup the example with the specified index.
|
||||||
abstract def [](index : Int) : Example
|
abstract def [](index : Int) : Example
|
||||||
|
|
||||||
|
# Indicates that the component references a type or method.
|
||||||
|
abstract def symbolic? : Bool
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,8 @@ module Spectator
|
||||||
# This group can be nested under other groups.
|
# This group can be nested under other groups.
|
||||||
class NestedExampleGroup < ExampleGroup
|
class NestedExampleGroup < ExampleGroup
|
||||||
# Description from the user of the group's contents.
|
# Description from the user of the group's contents.
|
||||||
getter what : String
|
# This is a symbol when referencing a type.
|
||||||
|
getter what : Symbol | String
|
||||||
|
|
||||||
# Group that this is nested in.
|
# Group that this is nested in.
|
||||||
getter parent : ExampleGroup
|
getter parent : ExampleGroup
|
||||||
|
@ -21,6 +22,11 @@ module Spectator
|
||||||
super(hooks, conditions)
|
super(hooks, conditions)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Indicates wheter the group references a type.
|
||||||
|
def symbolic?
|
||||||
|
@what.is_a?(Symbol)
|
||||||
|
end
|
||||||
|
|
||||||
# Runs all of the `before_all` hooks.
|
# Runs all of the `before_all` hooks.
|
||||||
# This should run prior to any examples in the group.
|
# This should run prior to any examples in the group.
|
||||||
# The hooks will be run only once.
|
# The hooks will be run only once.
|
||||||
|
|
|
@ -9,6 +9,11 @@ module Spectator
|
||||||
"ROOT"
|
"ROOT"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Indicates that the group is symbolic.
|
||||||
|
def symbolic?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
# Does nothing.
|
# Does nothing.
|
||||||
# This prevents the root group
|
# This prevents the root group
|
||||||
# from showing up in output.
|
# from showing up in output.
|
||||||
|
|
Loading…
Reference in a new issue