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

View file

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

View file

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