Hi,
I’ve done some work for email-spec that allows you to quickly test
incoming
e-mail handling.
Does any body else receive e-mail? If so, I would love your
input/feedback,
as I’m hoping this will eventually get merged into master so that
everyone
can use.
The branch i’m working in is
herehttp://github.com/mischa/email-spec/tree/incoming.
It provides an IncomingEmail class which you can use to generate emails
with
attachments, multipart emails, etc. Your app can then process this email
as
if it is a normal one.
The rationale behind this is that while Rails Recipies and others
advocate
testing e-mail with actual e-mail fixtures, this felt too brittle for
what I
wanted to do.
So, email-spec will now hopefully help with testing things like:
- Emailing attachments / notes to a backpack-like page
- Replying to messages via email. E.g. how some websites allow you to
‘reply above this line’ to messages / comments via email. - A messaging system that hides users from each other (e.g. a dating
site).
Ben also suggested that this could be used to testing things like how
your
app handles bounced e-mail, etc.
I have included a sample list of steps below. If you are confused about
how
receiving e-mail might work, please checkout my example app (not using
e-mail spec)
herehttp://github.com/mischa/receive_mail_example_app/tree/master.
It uses the fetcher plugin.
Anyway, here are the features:
Feature: EmailSpec Example – Quickly generate incoming e-mail
In order to keep track of my information
As a customer I want to send e-mail to an e-mail spec app
to keep the e-mail in the app so that it can be with other relavent info
Scenario: An incoming email is delivered to a page
Given an incoming email to "[email protected]"
And the email is from "[email protected]"
And a "User" with the email "[email protected]"
When the email is delivered
And I go to the email page
Then I should see the email
Scenario: An incoming email with a header
Given an incoming email to "[email protected]"
And the email is from "[email protected]"
And a "User" with the email "[email protected]"
And the "agent" header is "007"
When the email is delivered
And I go to the email page
Then I should see the email
Scenario: An incoming email with an attachment is delivered to a
page
Given an incoming email
And the email is to “[email protected]”
And a “User” with the email “[email protected]”
And the email has the “image/png” file at
“features/support/rails.png” attached
When the email is delivered
And I go to the email page
Then I should see the email
And I should see the attachment
Scenario: An incoming multipart email's text part goes to a page
Given an incoming email to "[email protected]"
And the email is from "[email protected]"
And the email has both an html part and a text part
And a "User" with the email "[email protected]"
When the email is delivered
And I go to the email page
Then I should see only the text part of the email
Scenario: An incoming html only email goes to a page
Given an incoming email to "[email protected]"
And the email has only html
And the email is from "[email protected]"
And a "User" with the email "[email protected]"
When the email is delivered
And I go to the email page
Then I should see the html
Thanks,
Mischa F.
http://www.themomorohoax.com