This really was a snap.
A nice and simple testing recipe (#68) demonstrates how to read in an email from a fixture in just a few lines and pass them to your processing method (MailReceiver.receive in this case).
def read_fixture(action)
IO.readlines(“#{FIXTURES_PATH}/mail_receiver/#{action}”)
end
def test_something
email = read_fixture(“junk_mail”).join
MailReceiver.receive(email)
# assertions
end
And then a few lines on how to feed it “for real”. and we’re up and running!
The only catch… there was some anger over the parens:
mailman: "|/path/to/app/script/runner Mailman.receive(STDIN.read)"
We ended up escaping them, but according to those directions I just linked to – you can also just quote the call to receive.
Advertisement