I just ran into this today as well. Instance variables created in the
setup block of a context are not available to the have_sent_email
matcher. An example:
context "Ticket Notifications" do
setup { @ticket = Factory(:ticket) }
should
have_sent_email.to(@ticket.contact.email)
end
This raises an undefined method 'contact' for nil:NilClass error. This
is on 2.11.3 using Test::Unit.
Any ideas?