mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Replace large DSL files with smaller, logical groups
This commit is contained in:
parent
3f7c16c888
commit
c94b284ab3
5 changed files with 58 additions and 1385 deletions
29
src/spectator/dsl/examples.cr
Normal file
29
src/spectator/dsl/examples.cr
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
require "../source"
|
||||||
|
require "../spec_builder"
|
||||||
|
|
||||||
|
module Spectator
|
||||||
|
module DSL
|
||||||
|
macro it(what, _source_file = __FILE__, _source_line = __LINE__, &block)
|
||||||
|
{% if block.is_a?(Nop) %}
|
||||||
|
{% if what.is_a?(Call) %}
|
||||||
|
def %run
|
||||||
|
{{what}}
|
||||||
|
end
|
||||||
|
{% else %}
|
||||||
|
{% raise "Unrecognized syntax: `it #{what}` at #{_source_file}:#{_source_line}" %}
|
||||||
|
{% end %}
|
||||||
|
{% else %}
|
||||||
|
def %run
|
||||||
|
{{block.body}}
|
||||||
|
end
|
||||||
|
{% end %}
|
||||||
|
|
||||||
|
%source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||||
|
::Spectator::SpecBuilder.add_example(
|
||||||
|
{{what.stringify}},
|
||||||
|
%source,
|
||||||
|
{{@type.name}}
|
||||||
|
) { |test| test.as({{@type.name}}).%run }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
29
src/spectator/dsl/groups.cr
Normal file
29
src/spectator/dsl/groups.cr
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
require "../spec_builder"
|
||||||
|
|
||||||
|
module Spectator
|
||||||
|
module DSL
|
||||||
|
macro context(what, &block)
|
||||||
|
class Context%context < {{@type.id}}
|
||||||
|
::Spectator::SpecBuilder.start_group(
|
||||||
|
{% if what.is_a?(StringLiteral) %}
|
||||||
|
{% if what.starts_with?("#") || what.starts_with?(".") %}
|
||||||
|
{{what.id.symbolize}}
|
||||||
|
{% else %}
|
||||||
|
{{what}}
|
||||||
|
{% end %}
|
||||||
|
{% else %}
|
||||||
|
{{what.symbolize}}
|
||||||
|
{% end %}
|
||||||
|
)
|
||||||
|
|
||||||
|
{{block.body}}
|
||||||
|
|
||||||
|
::Spectator::SpecBuilder.end_group
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
macro describe(what, &block)
|
||||||
|
context({{what}}) {{block}}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue