multi_mail 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,8 +62,8 @@ describe MultiMail::Receiver::Mandrill do
62
62
  message.subject.should == 'Test'
63
63
 
64
64
  # Body
65
- message.multipart?.should == true
66
- message.parts.size.should == 4
65
+ message.multipart?.should == true
66
+ message.parts.size.should == 4
67
67
  message.parts[0].content_type.should == 'text/plain'
68
68
  message.parts[1].content_type.should == 'text/html; charset=UTF-8'
69
69
  # @note Mandrill adds a newline at the end of each part.
@@ -77,12 +77,12 @@ describe MultiMail::Receiver::Mandrill do
77
77
  attachment1.read.should == "Nam accumsan euismod eros et rhoncus.\n\n"
78
78
 
79
79
  # Extra Mandrill parameters
80
- message['ts'].value.should == '1369860716'
81
- message['email'].value.should == 'foo+bar@govkit.org'
82
- message['dkim-signed'].value.should == 'false'
83
- message['dkim-valid'].value.should == 'false'
84
- message['spam_report-score'].value.should == '-0.7'
85
- message['spf-result'].value.should == 'pass'
80
+ message.ts.should == 1369860716
81
+ message.email.should == 'foo+bar@govkit.org'
82
+ message.dkim_signed.should == false
83
+ message.dkim_valid.should == false
84
+ message.spam_report_score.should == -0.7
85
+ message.spf_result.should == 'pass'
86
86
  end
87
87
 
88
88
  it 'should return multiple messages if there are multiple events' do
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe MultiMail::Sender::Mandrill do
3
+ describe MultiMail::Sender::Mandrill do
4
4
  let :message do
5
5
  Mail.new do
6
6
  from 'foo@example.com'
@@ -34,6 +34,13 @@ describe MultiMail::Sender::Mandrill do
34
34
  }.to raise_error(MultiMail::InvalidAPIKey, 'Invalid API key')
35
35
  end
36
36
 
37
+ it 'should raise an error if :template_name is invalid' do
38
+ expect{
39
+ message.delivery_method MultiMail::Sender::Mandrill, :api_key => ENV['MANDRILL_API_KEY'], :template_name => 'nonexistent'
40
+ message.deliver
41
+ }.to raise_error(MultiMail::InvalidTemplate, 'No such template "nonexistent"')
42
+ end
43
+
37
44
  it 'should transform send_at to a string if it is not a string' do
38
45
  sender = MultiMail::Sender::Mandrill.new(:api_user => '', :api_key => '', 'send_at' => Time.at(981203696))
39
46
  sender.send_at.should == '2001-02-03 12:34:56'
@@ -51,20 +58,26 @@ describe MultiMail::Sender::Mandrill do
51
58
  sender.async.should == false
52
59
  sender.ip_pool.should == nil
53
60
  sender.send_at.should == nil
61
+ sender.template_name.should == nil
62
+ sender.template_content.should == nil
54
63
  end
55
64
 
56
65
  it 'should assign custom settings' do
57
66
  sender = MultiMail::Sender::Mandrill.new({
58
67
  :api_key => 'xxx',
59
- :async => true,
68
+ :async => true,
60
69
  :ip_pool => 'Main Pool',
61
70
  :send_at => 'example send_at',
71
+ :template_name => 'foo',
72
+ :template_content => [{'name' => 'bar', 'content' => 'baz'}],
62
73
  })
63
74
 
64
75
  sender.api_key.should == 'xxx'
65
76
  sender.async.should == true
66
77
  sender.ip_pool.should == 'Main Pool'
67
78
  sender.send_at.should == 'example send_at'
79
+ sender.template_name.should == 'foo'
80
+ sender.template_content.should == [{'name' => 'bar', 'content' => 'baz'}]
68
81
  end
69
82
  end
70
83
 
@@ -119,27 +132,50 @@ describe MultiMail::Sender::Mandrill do
119
132
  end
120
133
 
121
134
  describe '#deliver!' do
122
- before :all do
123
- Mail.defaults do
124
- delivery_method MultiMail::Sender::Mandrill, :api_key => ENV['MANDRILL_API_KEY'], :return_response => true
135
+ context 'when :template_name is set' do
136
+ before do
137
+ Mail.defaults do
138
+ delivery_method MultiMail::Sender::Mandrill, :api_key => ENV['MANDRILL_API_KEY'], :return_response => true, :template_name => 'default'
139
+ end
125
140
  end
126
- end
127
141
 
128
- it 'should send a message' do
129
- results = message.deliver!
130
- results.size.should == 1
142
+ it 'should send a mandrill template' do
143
+ results = message.deliver!
144
+ results.size.should == 1
131
145
 
132
- result = results.first
133
- result.size.should == 4
146
+ result = results.first
147
+ result.size.should == 4
134
148
 
135
- result['reject_reason'].should == nil
136
- result['status'].should == 'sent'
137
- result['email'].should == 'bit-bucket@test.smtp.org'
138
- result['_id'].should match(/\A[0-9a-f]{32}\z/)
149
+ result['reject_reason'].should == nil
150
+ result['status'].should == 'sent'
151
+ result['email'].should == 'bit-bucket@test.smtp.org'
152
+ result['_id'].should match(/\A[0-9a-f]{32}\z/)
153
+ end
139
154
  end
140
155
 
141
- it 'should not send an empty message' do
142
- empty_message.deliver!.should == [] # response not saved
156
+ context 'when :template_name is not set' do
157
+ before do
158
+ Mail.defaults do
159
+ delivery_method MultiMail::Sender::Mandrill, :api_key => ENV['MANDRILL_API_KEY'], :return_response => true
160
+ end
161
+ end
162
+
163
+ it 'should send a message' do
164
+ results = message.deliver!
165
+ results.size.should == 1
166
+
167
+ result = results.first
168
+ result.size.should == 4
169
+
170
+ result['reject_reason'].should == nil
171
+ result['status'].should == 'sent'
172
+ result['email'].should == 'bit-bucket@test.smtp.org'
173
+ result['_id'].should match(/\A[0-9a-f]{32}\z/)
174
+ end
175
+
176
+ it 'should not send an empty message' do
177
+ empty_message.deliver!.should == [] # response not saved
178
+ end
143
179
  end
144
180
  end
145
181
  end
@@ -23,8 +23,8 @@ describe MultiMail::Receiver::Postmark do
23
23
  message.subject.should == 'Test'
24
24
 
25
25
  # Body
26
- message.multipart?.should == true
27
- message.parts.size.should == 4
26
+ message.multipart?.should == true
27
+ message.parts.size.should == 4
28
28
  message.parts[0].content_type.should == 'text/plain'
29
29
  message.parts[1].content_type.should == 'text/html; charset=UTF-8'
30
30
  message.parts[0].body.decoded.should == "bold text\n\n\n\nsome more bold text\n\n\n\nsome italic text\n\n> multiline\n> quoted\n> text\n\n\n--\nSignature block"
@@ -38,9 +38,9 @@ describe MultiMail::Receiver::Postmark do
38
38
  attachment1.read.should == "Nam accumsan euismod eros et rhoncus.\n"
39
39
 
40
40
  # Extra Postmark parameters
41
- message['MailboxHash'].value.should == 'bar'
42
- message['MessageID'].value.should == 'e27500eb-142e-4ca0-8529-e32ffd9931d6'
43
- message['Tag'].should be_nil
41
+ message.mailboxhash.should == 'bar'
42
+ message.messageid.should == 'e27500eb-142e-4ca0-8529-e32ffd9931d6'
43
+ message.tag.should be_nil
44
44
  end
45
45
  end
46
46
 
@@ -69,6 +69,54 @@ describe MultiMail::Sender::Postmark do
69
69
  end
70
70
  end
71
71
 
72
+ describe '#parameters' do
73
+ it 'should allow true, false and nil values' do
74
+ [true, false, nil].each do |value|
75
+ sender = MultiMail::Sender::Postmark.new({
76
+ :api_key => 'xxx',
77
+ :track => {
78
+ :opens => value,
79
+ }
80
+ })
81
+
82
+ sender.parameters.should == {:TrackOpens => value}
83
+ end
84
+ end
85
+
86
+ it 'should transform "yes" values' do
87
+ sender = MultiMail::Sender::Postmark.new({
88
+ :api_key => 'xxx',
89
+ :track => {
90
+ :opens => 'yes',
91
+ }
92
+ })
93
+
94
+ sender.parameters.should == {:TrackOpens => true}
95
+ end
96
+
97
+ it 'should transform "no" values' do
98
+ sender = MultiMail::Sender::Postmark.new({
99
+ :api_key => 'xxx',
100
+ :track => {
101
+ :opens => 'no',
102
+ }
103
+ })
104
+
105
+ sender.parameters.should == {:TrackOpens => false}
106
+ end
107
+
108
+ it 'should ignore "htmlonly" values' do
109
+ sender = MultiMail::Sender::Postmark.new({
110
+ :api_key => 'xxx',
111
+ :track => {
112
+ :opens => 'htmlonly',
113
+ }
114
+ })
115
+
116
+ sender.parameters.should == {}
117
+ end
118
+ end
119
+
72
120
  describe '#deliver' do
73
121
  before :all do
74
122
  Mail.defaults do
@@ -24,7 +24,7 @@ describe MultiMail::Receiver::SendGrid do
24
24
  message.subject.should == 'Test'
25
25
 
26
26
  # Body
27
- message.multipart?.should == true
27
+ message.multipart?.should == true
28
28
  # @note SendGrid adds additional HTML parts as attachments, which is
29
29
  # sensible, but it does not match the behavior of other email APIs.
30
30
  message.parts.size.should == 6
@@ -47,10 +47,10 @@ describe MultiMail::Receiver::SendGrid do
47
47
  attachment1.read.should == "Nam accumsan euismod eros et rhoncus.\n"
48
48
 
49
49
  # Extra SendGrid parameters
50
- message['dkim'].value.should == 'none'
51
- message['SPF'].value.should == 'pass'
52
- message['spam_report'].value.should == "Spam detection software, running on the system \"mx3.sendgrid.net\", has\r\nidentified this incoming email as possible spam. The original message\r\nhas been attached to this so you can view it (if it isn't spam) or label\r\nsimilar future email. If you have any questions, see\r\nthe administrator of that system for details.\r\n\r\nContent preview: bold text some more bold text some italic text [...] \r\n\r\nContent analysis details: (-2.6 points, 5.0 required)\r\n\r\n pts rule name description\r\n---- ---------------------- --------------------------------------------------\r\n-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low\r\n trust\r\n [209.85.223.172 listed in list.dnswl.org]\r\n-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%\r\n [score: 0.0000]\r\n 0.0 HTML_MESSAGE BODY: HTML included in message\r\n\r\n"
53
- message['spam_score'].value.should == '-2.599'
50
+ message.dkim.should == 'none'
51
+ message.spf.should == 'pass'
52
+ message.spam_report.should == "Spam detection software, running on the system \"mx3.sendgrid.net\", has\r\nidentified this incoming email as possible spam. The original message\r\nhas been attached to this so you can view it (if it isn't spam) or label\r\nsimilar future email. If you have any questions, see\r\nthe administrator of that system for details.\r\n\r\nContent preview: bold text some more bold text some italic text [...] \r\n\r\nContent analysis details: (-2.6 points, 5.0 required)\r\n\r\n pts rule name description\r\n---- ---------------------- --------------------------------------------------\r\n-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low\r\n trust\r\n [209.85.223.172 listed in list.dnswl.org]\r\n-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%\r\n [score: 0.0000]\r\n 0.0 HTML_MESSAGE BODY: HTML included in message\r\n\r\n"
53
+ message.spam_score.should == '-2.599'
54
54
  end
55
55
 
56
56
  # No postbin is capable of handling mixed encodings, and most fail to even
@@ -56,7 +56,7 @@ describe MultiMail::Sender::SendGrid do
56
56
 
57
57
  it 'should raise an error if :api_key is missing' do
58
58
  expect{
59
- message.delivery_method MultiMail::Sender::SendGrid, :api_user => 'xxx'
59
+ message.delivery_method MultiMail::Sender::SendGrid, :api_user => 'non-existent'
60
60
  }.to raise_error(ArgumentError, "Missing required arguments: api_key")
61
61
  end
62
62
 
@@ -68,13 +68,13 @@ describe MultiMail::Sender::SendGrid do
68
68
 
69
69
  it 'should raise an error if :api_key is nil' do
70
70
  expect{
71
- message.delivery_method MultiMail::Sender::SendGrid, :api_user => 'xxx', :api_key => nil
71
+ message.delivery_method MultiMail::Sender::SendGrid, :api_user => 'non-existent', :api_key => nil
72
72
  }.to raise_error(ArgumentError, "Missing required arguments: api_key")
73
73
  end
74
74
 
75
75
  it 'should raise an error if :api_user is invalid' do
76
76
  expect{
77
- message.delivery_method MultiMail::Sender::SendGrid, :api_user => 'xxx', :api_key => ENV['SENDGRID_API_KEY']
77
+ message.delivery_method MultiMail::Sender::SendGrid, :api_user => 'non-existent', :api_key => ENV['SENDGRID_API_KEY']
78
78
  message.deliver
79
79
  }.to raise_error(MultiMail::InvalidAPIKey, 'Bad username / password')
80
80
  end
@@ -38,7 +38,7 @@ describe MultiMail::Receiver::Simple do
38
38
  message.subject.should == 'Test'
39
39
 
40
40
  # Body
41
- message.multipart?.should == true
41
+ message.multipart?.should == true
42
42
  message.parts.size.should == 2
43
43
  message.parts[0].content_type.should == 'text/plain; charset=us-ascii'
44
44
  message.parts[0].body.should == "bold text\n\n\n> multiline\n> quoted\n> text\n\n--\nSignature block"
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  require 'rubygems'
2
2
 
3
+ require 'simplecov'
3
4
  require 'coveralls'
4
- Coveralls.wear!
5
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
6
+ SimpleCov.start do
7
+ add_filter 'spec'
8
+ end
5
9
 
6
10
  require 'digest/sha1'
7
11
  require 'net/http'
@@ -9,20 +13,8 @@ require 'yaml'
9
13
 
10
14
  require 'rspec'
11
15
  require 'rack'
12
- require 'vcr'
13
16
  require File.dirname(__FILE__) + '/../lib/multi_mail'
14
17
 
15
- if RUBY_VERSION >= '1.9'
16
- VCR.configure do |c|
17
- c.cassette_library_dir = 'spec/cassettes'
18
- c.hook_into :faraday
19
-
20
- c.around_http_request do |request| # Ruby 1.9+
21
- VCR.use_cassette(Digest::SHA1.hexdigest(request.uri + request.body + request.headers.to_s), &request)
22
- end
23
- end
24
- end
25
-
26
18
  # Requires supporting ruby files with custom matchers and macros, etc,
27
19
  # in spec/support/ and its subdirectories.
28
20
  Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_mail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
- - Open North
7
+ - James McKinney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-12 00:00:00.000000000 Z
11
+ date: 2015-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.0
19
+ version: 0.9.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.0
26
+ version: 0.9.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mail
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.5.3
33
+ version: '2.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.5.3
40
+ version: '2.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.4'
47
+ version: '1.5'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.4'
54
+ version: '1.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: json
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.7.7
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.7.7
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rake
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,20 +94,6 @@ dependencies:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
96
  version: '2.10'
111
- - !ruby/object:Gem::Dependency
112
- name: vcr
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 2.4.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 2.4.0
125
97
  - !ruby/object:Gem::Dependency
126
98
  name: mandrill-api
127
99
  requirement: !ruby/object:Gem::Requirement
@@ -156,47 +128,33 @@ dependencies:
156
128
  requirements:
157
129
  - - "~>"
158
130
  - !ruby/object:Gem::Version
159
- version: 1.6.7
131
+ version: 1.8.0
160
132
  type: :development
161
133
  prerelease: false
162
134
  version_requirements: !ruby/object:Gem::Requirement
163
135
  requirements:
164
136
  - - "~>"
165
137
  - !ruby/object:Gem::Version
166
- version: 1.6.7
167
- - !ruby/object:Gem::Dependency
168
- name: sendgrid_webapi
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
138
+ version: 1.8.0
181
139
  description:
182
- email:
183
- - info@opennorth.ca
140
+ email:
184
141
  executables:
185
142
  - multi_mail_post
186
143
  extensions: []
187
144
  extra_rdoc_files: []
188
145
  files:
189
146
  - ".gitignore"
147
+ - ".rspec"
190
148
  - ".travis.yml"
191
149
  - ".yardopts"
192
150
  - Gemfile
193
151
  - LICENSE
194
152
  - README.md
195
153
  - Rakefile
196
- - USAGE
197
154
  - bin/multi_mail_post
198
155
  - lib/mail_ext/message.rb
199
156
  - lib/multi_mail.rb
157
+ - lib/multi_mail/cloudmailin/message.rb
200
158
  - lib/multi_mail/cloudmailin/receiver.rb
201
159
  - lib/multi_mail/mailgun/message.rb
202
160
  - lib/multi_mail/mailgun/receiver.rb
@@ -273,7 +231,7 @@ files:
273
231
  - spec/service_spec.rb
274
232
  - spec/simple/receiver_spec.rb
275
233
  - spec/spec_helper.rb
276
- homepage: http://github.com/opennorth/multi_mail
234
+ homepage: https://github.com/jpmckinney/multi_mail
277
235
  licenses:
278
236
  - MIT
279
237
  metadata: {}
@@ -293,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
251
  version: '0'
294
252
  requirements: []
295
253
  rubyforge_project:
296
- rubygems_version: 2.2.2
254
+ rubygems_version: 2.4.5
297
255
  signing_key:
298
256
  specification_version: 4
299
257
  summary: Easily switch between email APIs
@@ -352,3 +310,4 @@ test_files:
352
310
  - spec/service_spec.rb
353
311
  - spec/simple/receiver_spec.rb
354
312
  - spec/spec_helper.rb
313
+ has_rdoc: