Some initial double code

This commit is contained in:
Michael Miller 2019-08-26 21:49:47 -06:00
parent 70e01364ce
commit 3462bdea1a
3 changed files with 26 additions and 0 deletions

9
src/spectator/double.cr Normal file
View file

@ -0,0 +1,9 @@
module Spectator
module Double
macro stub(definition)
def {{definition.name.id}}
{{definition.block.body}}
end
end
end
end

View file

@ -1437,6 +1437,22 @@ module Spectator::DSL
{% debug %}
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.
# The *what* argument describes "what" is being tested or asserted.
# The block contains the code to run the test.

View file

@ -31,6 +31,7 @@ require "./nested_example_group"
require "./root_example_group"
require "./mock"
require "./double"
require "./config"
require "./config_builder"