Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to search for an email by subject #22

Open
ZachBeta opened this issue May 9, 2013 · 7 comments
Open

Add ability to search for an email by subject #22

ZachBeta opened this issue May 9, 2013 · 7 comments

Comments

@ZachBeta
Copy link

ZachBeta commented May 9, 2013

Have multiple emails reaching one user.
Need to find based on subject.

Investigating.

@bcardarella
Copy link
Contributor

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

@ZachBeta
Copy link
Author

ZachBeta commented May 9, 2013

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.

@bcardarella
Copy link
Contributor

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.

@ZachBeta
Copy link
Author

ZachBeta commented May 9, 2013

If that's the case, then I was just being too picky about code formatting :-P

@maabernethy
Copy link
Contributor

@bcardarella is this still an open issue?

@rsocci
Copy link

rsocci commented Apr 4, 2014

@bcardarella can be closed?

@przbadu
Copy link

przbadu commented Dec 9, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants