Add support for receiving and interacting with emails
Closed this issue · 11 comments
Waiting for API proposals.
user.recives_email?(text)
user.clicks_email_link(text)
user.emails.last.has?(text)
user.emails.last.click_link(text)
Quote from capybara list:
A while ago I made two tiny gems inspired on the email_spec gem for
testing email content, clicking links in emails etc in Capybara
https://github.com/suhrawardi/capybara_email
https://github.com/suhrawardi/cache_mailer
Didn't really have the need and the time to expand these further. But
you might check whether it suits your need.
Questions etc are welcome!
jarra the.voyage.and.the.messenger@gmail.com
start a rack server with mini app that will mimic webmail interface and allow to navigate it using the browser ?
user.visit_mailbox
user.see!("email subject")
user.click_subject("email subject")
user.see!("email body")
mini mail app is neat although it looks like overengineered solution
API proposal:
user.recive_email!(subject) do |body|
body.has! "Dear Mr."
body.click link
end
I like it for few reasons:
a) I can see the @ in the browser (in test or development mode) and it reflects the way normal user cooperates with emails
b) You can (video) record your test
c) You can still use capybara api for matchers to test against mail content.
However, feel free to write @ support in a different way :-)
It is a nice api but does not allow me to check for recipients or "Replay-To" headers etc. In one of my projects it is important to check for such things.
user.recive_email!(subject) { |body, header| ... }
?
You just convinced me to a tiny rack app. Maybe https://github.com/37signals/mail_view will help here.
Nice. I did not know about it. Fuckin' 37signals implement my every idea :-) I thought that the application could look like http://railsapi.com/doc/rails-v3.0.8rc1/ . Left panel for email topics and sender data. Right panel for the content of clicked email. Search text field (last feature) that would let me search like in gmail: "from:pawel". That's how I would like to test for senders / recipients. This last feature is least important for me. Something like "display all headers" (or displaying them by default) and checking it like @user.find("#from").has!("Pawel")
is also ok for me.
Could you make the mail view optional? It just seems like so much overhead considering most mail clients don't use javascript.
I just use
ActionMailer::Base.deliveries.select { |m| m.to.include?(this.email) }
with some nokogiri parsing action.
Closing since this won't be core feature and minimal support is currently developed in https://github.com/drugpl/mail_inbox