Value first, then label

This commit is contained in:
Michael Miller 2019-08-01 15:48:39 -06:00
parent 7e3b3cd999
commit f004912fc1
3 changed files with 5 additions and 5 deletions

View file

@ -19,7 +19,7 @@ module Spectator::DSL
# Where the actual value is returned by the system-under-test,
# and the expected value is what the actual value should be to satisfy the condition.
macro expect(actual, _source_file = __FILE__, _source_line = __LINE__)
test_value = ::Spectator::TestValue.new({{actual.stringify}}, {{actual}})
test_value = ::Spectator::TestValue.new({{actual}}, {{actual.stringify}})
source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
::Spectator::Expectations::ExpectationPartial.new(value_actual, source)
end
@ -70,11 +70,11 @@ module Spectator::DSL
# The raw block can't be used because it's not clear to the user.
{% method_name = block.body.id.split('.')[1..-1].join('.') %}
%partial = %proc.partial(subject)
test_block = ::Spectator::TestBlock.new({{"#" + method_name}}, %partial)
test_block = ::Spectator::TestBlock.new(%partial, {{"#" + method_name}})
{% else %}
# In this case, it looks like the short-hand method syntax wasn't used.
# Just drop in the proc as-is.
test_block = ::Spectator::TestBlock.new({{"`" + block.body.stringify + "`"}}, %proc)
test_block = ::Spectator::TestBlock.new(%proc, {{"`" + block.body.stringify + "`"}})
{% end %}
source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})

View file

@ -10,7 +10,7 @@ module Spectator
# Creates the block expression with a custom label.
# Typically the label is the code in the block/proc.
def initialize(label : String, @proc : -> ReturnType)
def initialize(@proc : -> ReturnType, label : String)
super(label)
end

View file

@ -7,7 +7,7 @@ module Spectator
getter value : T
# Creates the expression value with a custom label.
def initialize(label : String, @value)
def initialize(@value, label : String)
super(label)
end