Fix DSL usage of BlockExpectationPartial

This commit is contained in:
Michael Miller 2019-03-14 15:04:38 -06:00
parent d0da584f5e
commit e552cbffd2
2 changed files with 4 additions and 3 deletions

View file

@ -69,7 +69,8 @@ module Spectator::DSL
{% else %}
# In this case, it looks like the short-hand method syntax wasn't used.
# Just drop in the block as-is.
::Spectator::Expectations::ValueExpectationPartial.new({{block.body}}, {{block.body.stringify}}, {{_source_file}}, {{_source_line}})
%proc = ->({{block.args.splat}}) {{block}}
::Spectator::Expectations::BlockExpectationPartial.new(%proc, {{block.body.stringify}}, {{_source_file}}, {{_source_line}})
{% end %}
end

View file

@ -11,14 +11,14 @@ module Spectator::Expectations
# Creates the expectation partial.
# The label should be a string representation of the block.
# The block is stored for later use.
protected def initialize(@block : -> ReturnType, label, source_file, source_line)
protected def initialize(@block : Proc(ReturnType), label, source_file, source_line)
super(label, source_file, source_line)
end
# Creates the expectation partial.
# The label is generated by calling to_s on the block.
# The block is stored for later use.
protected def initialize(@block : -> ReturnType, source_file, source_line)
protected def initialize(@block : Proc(ReturnType), source_file, source_line)
super(@block.to_s, source_file, source_line)
end
end