Fix generating source from brace-less examples.

Addresses https://github.com/icy-arctic-fox/spectator/issues/20
This commit is contained in:
Michael Miller 2021-02-03 10:06:00 -07:00
parent eee5d3888d
commit 8d48e441b2
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD

View file

@ -18,7 +18,11 @@ module Spectator
end
{% end %}
%source = ::Spectator::Source.new({{block.filename}}, {{block.line_number}})
{% if block.is_a?(Nop) %}
%source = ::Spectator::Source.new({{description.filename}}, {{description.line_number}})
{% else %}
%source = ::Spectator::Source.new({{block.filename}}, {{block.line_number}})
{% end %}
::Spectator::SpecBuilder.add_example(
{{description.is_a?(StringLiteral) || description.is_a?(StringInterpolation) || description.is_a?(NilLiteral) ? description : description.stringify}},
%source,
@ -45,7 +49,11 @@ module Spectator
end
{% end %}
%source = ::Spectator::Source.new({{block.filename}}, {{block.line_number}})
{% if block.is_a?(Nop) %}
%source = ::Spectator::Source.new({{description.filename}}, {{description.line_number}})
{% else %}
%source = ::Spectator::Source.new({{block.filename}}, {{block.line_number}})
{% end %}
::Spectator::SpecBuilder.add_pending_example(
{{description.is_a?(StringLiteral) || description.is_a?(StringInterpolation) || description.is_a?(NilLiteral) ? description : description.stringify}},
%source,