Comments (1)
Hi @daniely, great question! When I was first building ActionMailerMatchers with the folks here at Contently, I took a look at email-spec
and felt like the gem was a little heavy for our specific needs.
If you look in the user_mailer_spec.rb
example in the repo, it looks like the matchers are being used to unit test the mailer objects specifically. That's great, but the purpose of the have_received_email
matcher is to be used in controllers and other services to make sure that emails are being sent when actions are performed. You can see more clearly how action_mailer_matchers
could be used by rewriting email-spec's welcome controller test example.
describe "POST /signup (#signup)" do
it "should deliver the signup email" do
expect {
post :signup, "Email" => "[email protected]", "Name" => "Jimmy Bean"
}.to change(ActionMailer::Base.deliveries, :size).by(1)
last_delivery = ActionMailer::Base.deliveries.last
expect(last_delivery.to).to include "[email protected]"
#message is now multipart, make sure both parts include Jimmy Bean
expect(last_delivery.parts[0].body.to_s).to include "Jimmy Bean"
expect(last_delivery.parts[1].body.to_s).to include "Jimmy Bean"
end
end
With ActionMailerMatchers
describe "POST /signup (#signup)" do
it "should deliver the signup email" do
post :signup, "Email" => "[email protected]", "Name" => "Jimmy Bean"
expect("[email protected]").to have_received_email(body: "Jimmy Bean")
end
end
If you think an idea from email-spec
would be a good addition to this gem, we're happy to hear suggestions or accept pull requests!
from action_mailer_matchers.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from action_mailer_matchers.