Use block instead of yield to insert block

The "yield" method produces `begin...end`.
The "block" method produces `do...end`, which is needed for this syntax.
This commit is contained in:
Michael Miller 2019-03-26 21:45:31 -06:00
parent 2da1f9dbbf
commit e87314be58

View file

@ -502,8 +502,8 @@ module Spectator::DSL
# hash = {"foo" => "bar"} # hash = {"foo" => "bar"}
# expect_raises(KeyError) { hash["baz"] }.to raise_error(KeyError) # expect_raises(KeyError) { hash["baz"] }.to raise_error(KeyError)
# ``` # ```
macro expect_raises(type) macro expect_raises(type, &block)
expect {{yield}}.to raise_error({{type}}) expect {{block}}.to raise_error({{type}})
end end
# Indicates that some block should raise an error with a given message and type. # Indicates that some block should raise an error with a given message and type.
@ -517,8 +517,8 @@ module Spectator::DSL
# expect_raises(KeyError, /baz/) { hash["baz"] } # expect_raises(KeyError, /baz/) { hash["baz"] }
# expect_raises(ArgumentError, "foobar") { raise ArgumentError.new("foobar") } # expect_raises(ArgumentError, "foobar") { raise ArgumentError.new("foobar") }
# ``` # ```
macro expect_raises(type, message) macro expect_raises(type, message, &block)
expect {{yield}}.to raise_error({{type}}, {{message}}) expect {{block}}.to raise_error({{type}}, {{message}})
end end
# Used to create predicate matchers. # Used to create predicate matchers.