This repository was archived by the owner on Jul 12, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 198
Support configuring from return type #73
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| shared_examples_for 'configurable email address' do |address| | ||
| describe '#{address} = :hash' do | ||
| it 'returns a hash for email.#{address}' do | ||
| email = new_email_with_config(address => :hash) | ||
|
|
||
| returned_address = email.send(address) | ||
| if address == :to | ||
| returned_address = returned_address.first | ||
| end | ||
|
|
||
| returned_address.should eq expected_hash | ||
| end | ||
|
|
||
| def expected_hash | ||
| { | ||
| token: 'caleb', | ||
| host: 'example.com', | ||
| email: 'caleb@example.com', | ||
| full: 'Caleb Thompson <caleb@example.com>', | ||
| } | ||
| end | ||
| end | ||
|
|
||
| describe '#{address} = :full' do | ||
| it 'returns the full #{address} for email.#{address}' do | ||
| email = new_email_with_config(address => :full) | ||
|
|
||
| email.send(address).should eq params[address] | ||
| end | ||
| end | ||
|
|
||
| describe '#{address} = :email' do | ||
| it 'returns just the email address for email.#{address}' do | ||
| email = new_email_with_config(address => :email) | ||
|
|
||
| if address == :to | ||
| email.send(address).should eq ['caleb@example.com'] | ||
| else | ||
| email.send(address).should eq 'caleb@example.com' | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe '#{address} = :token' do | ||
| it 'returns the local portion of the email for email.#{address}' do | ||
| email = new_email_with_config(address => :token) | ||
|
|
||
| if address == :to | ||
| email.send(address).should eq ['caleb'] | ||
| else | ||
| email.send(address).should eq 'caleb' | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def params | ||
| { | ||
| to: ['Caleb Thompson <caleb@example.com>'], | ||
| from: 'Caleb Thompson <caleb@example.com>', | ||
| subject: 'Remember that thing?', | ||
| text: 'You know, the thing.', | ||
| } | ||
| end | ||
|
|
||
| def new_email_with_config(config) | ||
| Griddler.configuration.stub(config) | ||
| Griddler::Email.new(params).process | ||
| end | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm weary of the context of these two tests. The description states that we're testing the
body formattingbut these are with regards to the to and from email addresses. For now I'd suggest we consider pulling these out into their owndescribe.In the future I think a good bit of the responsibility in our Email class should get extracted to more focused and relevant classes. What do you guys think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a concerted effort to prevent bloat in the Email class is a good idea. I think the things that are in there now are fairly relevant though. Do you disagree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking a few days ago that it would probably be a good idea to have an email builder and turn Griddler::Email into a value object.