forked from thoughtbot/griddler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add 'be_normalized_to' matcher for testing params normalization
- Loading branch information
Showing
4 changed files
with
54 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -2,13 +2,12 @@ | |
|
||
describe Griddler::Adapters::CloudmailinAdapter, '.normalize_params' do | ||
it 'normalizes parameters' do | ||
params = default_params | ||
|
||
normalized_params = Griddler::Adapters::CloudmailinAdapter.normalize_params(params) | ||
normalized_params[:to].should eq ['Some Identifier <[email protected]>'] | ||
normalized_params[:from].should eq 'Joe User <[email protected]>' | ||
normalized_params[:subject].should eq 'Re: [ThisApp] That thing' | ||
normalized_params[:text].should include('Dear bob') | ||
Griddler::Adapters::CloudmailinAdapter.normalize_params(default_params).should be_normalized_to({ | ||
to: ['Some Identifier <[email protected]>'], | ||
from: 'Joe User <[email protected]>', | ||
subject: 'Re: [ThisApp] That thing', | ||
text: /Dear bob/ | ||
}) | ||
end | ||
|
||
it 'passes the received array of files' do | ||
|
This file contains 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 |
---|---|---|
|
@@ -2,16 +2,15 @@ | |
|
||
describe Griddler::Adapters::MandrillAdapter, '.normalize_params' do | ||
it 'normalizes parameters' do | ||
params = default_params | ||
|
||
normalized_params = Griddler::Adapters::MandrillAdapter.normalize_params(params) | ||
normalized_params.each do |params| | ||
params[:to].should eq ['The Token <[email protected]>'] | ||
params[:from].should eq '[email protected]' | ||
params[:subject].should eq 'hello' | ||
params[:text].should include('Dear bob') | ||
params[:html].should include('<p>Dear bob</p>') | ||
params[:raw_body].should include('raw') | ||
Griddler::Adapters::MandrillAdapter.normalize_params(default_params).each do |params| | ||
params.should be_normalized_to({ | ||
to: ['The Token <[email protected]>'], | ||
from: '[email protected]', | ||
subject: 'hello', | ||
text: %r{Dear bob}, | ||
html: %r{<p>Dear bob</p>}, | ||
raw_body: %r{raw} | ||
}) | ||
end | ||
end | ||
|
||
|
This file contains 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 |
---|---|---|
|
@@ -2,14 +2,13 @@ | |
|
||
describe Griddler::Adapters::PostmarkAdapter, '.normalize_params' do | ||
it 'normalizes parameters' do | ||
params = default_params | ||
|
||
normalized_params = Griddler::Adapters::PostmarkAdapter.normalize_params(params) | ||
normalized_params[:to].should eq ['Robert Paulson <[email protected]>'] | ||
normalized_params[:from].should eq '[email protected]' | ||
normalized_params[:subject].should eq 'Reminder: First and Second Rule' | ||
normalized_params[:text].should include('Dear bob') | ||
normalized_params[:html].should include('<p>Dear bob</p>') | ||
Griddler::Adapters::PostmarkAdapter.normalize_params(default_params).should be_normalized_to({ | ||
to: ['Robert Paulson <[email protected]>'], | ||
from: '[email protected]', | ||
subject: 'Reminder: First and Second Rule', | ||
text: /Dear bob/, | ||
html: %r{<p>Dear bob</p>} | ||
}) | ||
end | ||
|
||
it 'passes the received array of files' do | ||
|
@@ -35,16 +34,14 @@ | |
end | ||
|
||
it 'gets rid of the original postmark params' do | ||
params = default_params | ||
|
||
normalized_params = Griddler::Adapters::PostmarkAdapter.normalize_params(params) | ||
|
||
normalized_params[:ToFull].should be_nil | ||
normalized_params[:FromFull].should be_nil | ||
normalized_params[:Subject].should be_nil | ||
normalized_params[:TextBody].should be_nil | ||
normalized_params[:HtmlBody].should be_nil | ||
normalized_params[:Attachments].should be_nil | ||
Griddler::Adapters::PostmarkAdapter.normalize_params(default_params).should be_normalized_to({ | ||
ToFull: nil, | ||
FromFull: nil, | ||
Subject: nil, | ||
TextBody: nil, | ||
HtmlBody: nil, | ||
Attachments: nil | ||
}) | ||
end | ||
|
||
def default_params | ||
|
This file contains 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