shard-spectator/src/spectator/dsl/top.cr

33 lines
1.1 KiB
Crystal
Raw Normal View History

2020-10-18 04:57:27 +00:00
require "./groups"
module Spectator::DSL
module Top
{% for method in %i[example_group describe context] %}
# Top-level describe method.
# All specs in a file must be wrapped in this call.
# This takes an argument and a block.
# The argument is what your spec is describing.
# It can be any Crystal expression,
# but is typically a class name or feature string.
# The block should contain all of the examples for what is being described.
2021-08-18 21:57:22 +00:00
#
2020-10-18 04:57:27 +00:00
# Example:
# ```
# Spectator.describe Foo do
# # Your examples for `Foo` go here.
# end
# ```
2021-08-18 21:57:22 +00:00
#
# Tags can be specified by adding symbols (keywords) after the first argument.
# Key-value pairs can also be specified.
#
2021-01-09 20:17:42 +00:00
# NOTE: Inside the block, the `Spectator` prefix _should not_ be used.
2021-08-18 21:57:22 +00:00
macro {{method.id}}(description, *tags, **metadata, &block)
2020-10-18 04:57:27 +00:00
class ::SpectatorTestContext
2021-08-18 21:57:22 +00:00
{{method.id}}(\{{description}}, \{{tags.splat(", ")}} \{{metadata.double_splat}}) \{{block}}
2020-10-18 04:57:27 +00:00
end
end
{% end %}
end
end