capybara-email
capybara-email copied to clipboard
Add ability to search for an email by subject
Have multiple emails reaching one user. Need to find based on subject.
Investigating.
That's interesting. You could do this with the current API but you have to jump through a hoop or two:
all_emails.find { |e| e.subject ~= /keyword/ }
all_emails.collect { |e| e.subject ~= /keyword/ }
The first will return a single email, the second will return a collection of emails matching
Should make things a little cleaner in our specs by pushing this logic into the gem.
I also noticed the dissonance between first_email_sent_to
and the fact that it grabs the last email. But I figured that might break some other specs, so I left that alone.
I believe it is grabbing the last because the email is pushed onto a queue. I could be wrong, I'll have to double check.
If that's the case, then I was just being too picky about code formatting :-P
@bcardarella is this still an open issue?
@bcardarella can be closed?
checking at the source code (https://github.com/dockyard/capybara-email/blob/master/lib/capybara/email/dsl.rb#L42), I found current_emails
method, which is returning array of emails. So, I fixed this issue by:
current_emails.first.click_link 'Confirm my account'
AND
current_emails.last.click_link 'Change my password'
# current_email is already a last email so we can directly write:
current_email.click_link "Change my password"
So, I guess, you can reference your emails by array index like:
current_emails[0]
current_emails[1]
and so on ....
Hope this is helpful. And yes, I agree, if gem will implement some way to directly fetch emails with their subject.
Thanks