Replace large DSL files with smaller, logical groups

This commit is contained in:
Michael Miller 2019-09-15 09:15:33 -06:00
parent 3f7c16c888
commit c94b284ab3
5 changed files with 58 additions and 1385 deletions

View 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

View 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