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

Adds another selector based on subject. #23

Closed
wants to merge 1 commit into from

Conversation

ZachBeta
Copy link

@ZachBeta ZachBeta commented May 9, 2013

Resolves issue #22

@bcardarella
Copy link
Contributor

Removing the open_email method changes the public API behavior which I don't want to do.

I think instead there needs to be a general search functionality. Something like

search_emails(:to => 'someone', :from => 'someone', :subject => 'string' or /regex/, :body => 'string' or /regex/)

The body search and subject search will always do a search for emails that contain instead of exact match and you can search by any number of criteria. This will always return a collection. Thoughts?

@ZachBeta
Copy link
Author

ZachBeta commented May 9, 2013

I was trying to make it as open ended a matcher as possible, like capybara's click_link

click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click_on('Link Text') # clicks on either links or buttons
click_on('Button Value')

It's a lot nicer to work with on the front end although it does change the existing api, it shouldn't break the currently existing functionality.

@bcardarella
Copy link
Contributor

Well the gem follows semantic versioning so I cannot break public API without doing a major version bump which I don't want to do.

As for the selector, I see where you're going but the selectors are meant only to work on one aspect of a document. We would want to search against multiple criteria in which selectors don't make sense.

@ZachBeta
Copy link
Author

ZachBeta commented May 9, 2013

Understood.

What if we open up the api a bit wider

open_email('[email protected]')
open_email_to('[email protected]') # alias to open_email
open_email_with_subject('Subject Line')

I'm not sure I have the time in the immediate future to properly implement a search_emails({})

And the next big version the api can be reformed updated based on community usage.

@bcardarella
Copy link
Contributor

The gem itself is meant to work only an integration environment. To that end the API reflects how one should work with their own email. The #open_email method is meant to switch the context to the user being imitated in the integration test.

Because integration tests are meant to simulate real-world interactions you wouldn't be expected to be able to just search for all emails the app has sent based upon subject.

After thinking of this, I don't think the correct direction is to change anything in the public API. There are methods to hook into if people want to work around it but I don't want to encourage breaking the personas for integration testing.

@bcardarella bcardarella closed this May 9, 2013
@ZachBeta
Copy link
Author

ZachBeta commented May 9, 2013

In our situation a user receives 2 emails from the application and we're only concerned with the path through one of them.

Since there's already a method emails_sent_to(recipient), we'll be using

emails_sent_to(user.email)
current_email = current_emails.find { |email| email.subject == 'Subject Text 1' }
current_email.click_link('Link text 1')

Hopefully this helps anyone else googling for a solution to a similar problem.

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

Successfully merging this pull request may close these issues.

2 participants