Can't support multiple arguments (expected values)

The macro would only "attach" `.to` to the last partial.
This commit is contained in:
Michael Miller 2019-01-23 16:43:59 -07:00
parent 17c66dd732
commit 78698d2de9

View file

@ -17,12 +17,6 @@ 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.
# #
# Multiple values can be checked, for instance:
# ```
# expect(actual1, actual2).to eq(expected)
# ```
# This will verify that both `actual1` and `actual2` equal `expected`.
#
# The short, one argument syntax used for passing methods to blocks can be used. # The short, one argument syntax used for passing methods to blocks can be used.
# So instead of doing this: # So instead of doing this:
# ``` # ```
@ -33,11 +27,8 @@ module Spectator::DSL
# expect(&.size).to eq(5) # expect(&.size).to eq(5)
# ``` # ```
# The method passed will always be evaluated on `#subject`. # The method passed will always be evaluated on `#subject`.
macro expect(*actual) macro expect(actual)
# Loop over every "actual" to check - this is typically just one item. ::Spectator::Expectations::ValueExpectationPartial.new({{actual.stringify}}, {{actual}})
{% for item in actual %}
::Spectator::Expectations::ValueExpectationPartial.new({{item.stringify}}, {{item}})
{% end %}
end end
# Starts an expectation on a block of code. # Starts an expectation on a block of code.