When you write with the following syntax:
assert_raises(ArgumentError) { excerpt }
What you are actually passing to assert_raises
is a block. This means that the code (excerpt
) is not evaluated until the method itself decides it wants to evaluate it.
With this syntax, though:
assert_failure(excerpt)
excerpt
is evaluated before assert_failure
starts.
If you want to duplicate the above behavior, you need to pass assert_failure
a block:
def assert_failure(&block)
assert_raises(ArgumentError, &block)
end
describe 'author' do
let(:author) {nil}
it('fails') { assert_failure { excerpt } }
end