mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Some initial double code
This commit is contained in:
parent
70e01364ce
commit
3462bdea1a
3 changed files with 26 additions and 0 deletions
9
src/spectator/double.cr
Normal file
9
src/spectator/double.cr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
module Spectator
|
||||||
|
module Double
|
||||||
|
macro stub(definition)
|
||||||
|
def {{definition.name.id}}
|
||||||
|
{{definition.block.body}}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1437,6 +1437,22 @@ module Spectator::DSL
|
||||||
{% debug %}
|
{% debug %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
macro double(name, &block)
|
||||||
|
{% if block.is_a?(Nop) %}
|
||||||
|
# Create an instance of the double.
|
||||||
|
Double{{name.id}}.new
|
||||||
|
{% else %}
|
||||||
|
# Define a double.
|
||||||
|
struct Double{{name.id}} # TODO: Use fresh variable %double
|
||||||
|
include ::Spectator::Double
|
||||||
|
|
||||||
|
{{block.body}}
|
||||||
|
end
|
||||||
|
# TODO: Register double in current context.
|
||||||
|
{% end %}
|
||||||
|
{% debug %}
|
||||||
|
end
|
||||||
|
|
||||||
# Creates an example, or a test case.
|
# Creates an example, or a test case.
|
||||||
# The *what* argument describes "what" is being tested or asserted.
|
# The *what* argument describes "what" is being tested or asserted.
|
||||||
# The block contains the code to run the test.
|
# The block contains the code to run the test.
|
||||||
|
|
|
@ -31,6 +31,7 @@ require "./nested_example_group"
|
||||||
require "./root_example_group"
|
require "./root_example_group"
|
||||||
|
|
||||||
require "./mock"
|
require "./mock"
|
||||||
|
require "./double"
|
||||||
|
|
||||||
require "./config"
|
require "./config"
|
||||||
require "./config_builder"
|
require "./config_builder"
|
||||||
|
|
Loading…
Reference in a new issue