postmark 1.8.1 → 1.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.travis.yml +8 -5
  4. data/CHANGELOG.rdoc +86 -0
  5. data/CONTRIBUTING.md +18 -0
  6. data/Gemfile +6 -5
  7. data/LICENSE +1 -1
  8. data/README.md +34 -607
  9. data/RELEASE.md +12 -0
  10. data/VERSION +1 -1
  11. data/gemfiles/Gemfile.legacy +5 -4
  12. data/lib/postmark.rb +1 -18
  13. data/lib/postmark/account_api_client.rb +55 -1
  14. data/lib/postmark/api_client.rb +145 -17
  15. data/lib/postmark/bounce.rb +0 -4
  16. data/lib/postmark/client.rb +12 -4
  17. data/lib/postmark/error.rb +127 -0
  18. data/lib/postmark/handlers/mail.rb +10 -4
  19. data/lib/postmark/helpers/message_helper.rb +4 -0
  20. data/lib/postmark/http_client.rb +20 -32
  21. data/lib/postmark/mail_message_converter.rb +18 -5
  22. data/lib/postmark/message_extensions/mail.rb +83 -8
  23. data/lib/postmark/version.rb +1 -1
  24. data/postmark.gemspec +1 -1
  25. data/postmark.png +0 -0
  26. data/spec/integration/account_api_client_spec.rb +42 -10
  27. data/spec/integration/api_client_hashes_spec.rb +32 -49
  28. data/spec/integration/api_client_messages_spec.rb +33 -52
  29. data/spec/integration/api_client_resources_spec.rb +12 -44
  30. data/spec/integration/mail_delivery_method_spec.rb +21 -23
  31. data/spec/spec_helper.rb +4 -7
  32. data/spec/support/custom_matchers.rb +44 -0
  33. data/spec/support/shared_examples.rb +16 -16
  34. data/spec/unit/postmark/account_api_client_spec.rb +239 -45
  35. data/spec/unit/postmark/api_client_spec.rb +792 -406
  36. data/spec/unit/postmark/bounce_spec.rb +40 -62
  37. data/spec/unit/postmark/client_spec.rb +0 -6
  38. data/spec/unit/postmark/error_spec.rb +231 -0
  39. data/spec/unit/postmark/handlers/mail_spec.rb +59 -27
  40. data/spec/unit/postmark/helpers/hash_helper_spec.rb +5 -6
  41. data/spec/unit/postmark/helpers/message_helper_spec.rb +60 -11
  42. data/spec/unit/postmark/http_client_spec.rb +76 -61
  43. data/spec/unit/postmark/inbound_spec.rb +34 -34
  44. data/spec/unit/postmark/inflector_spec.rb +11 -13
  45. data/spec/unit/postmark/json_spec.rb +2 -2
  46. data/spec/unit/postmark/mail_message_converter_spec.rb +250 -81
  47. data/spec/unit/postmark/message_extensions/mail_spec.rb +249 -38
  48. data/spec/unit/postmark_spec.rb +37 -37
  49. metadata +41 -11
@@ -1,35 +1,33 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Postmark::Inflector do
4
-
5
4
  describe ".to_postmark" do
6
5
  it 'converts rubyish underscored format to camel cased symbols accepted by the Postmark API' do
7
- subject.to_postmark(:foo_bar).should == 'FooBar'
8
- subject.to_postmark(:_bar).should == 'Bar'
9
- subject.to_postmark(:really_long_long_long_long_symbol).should == 'ReallyLongLongLongLongSymbol'
10
- subject.to_postmark(:foo_bar_1).should == 'FooBar1'
6
+ expect(subject.to_postmark(:foo_bar)).to eq 'FooBar'
7
+ expect(subject.to_postmark(:_bar)).to eq 'Bar'
8
+ expect(subject.to_postmark(:really_long_long_long_long_symbol)).to eq 'ReallyLongLongLongLongSymbol'
9
+ expect(subject.to_postmark(:foo_bar_1)).to eq 'FooBar1'
11
10
  end
12
11
 
13
12
  it 'accepts strings as well' do
14
- subject.to_postmark('foo_bar').should == 'FooBar'
13
+ expect(subject.to_postmark('foo_bar')).to eq 'FooBar'
15
14
  end
16
15
 
17
16
  it 'acts idempotentely' do
18
- subject.to_postmark('FooBar').should == 'FooBar'
17
+ expect(subject.to_postmark('FooBar')).to eq 'FooBar'
19
18
  end
20
19
  end
21
20
 
22
21
  describe ".to_ruby" do
23
22
  it 'converts camel cased symbols returned by the Postmark API to underscored Ruby symbols' do
24
- subject.to_ruby('FooBar').should == :foo_bar
25
- subject.to_ruby('LongTimeAgoInAFarFarGalaxy').should == :long_time_ago_in_a_far_far_galaxy
26
- subject.to_ruby('MessageID').should == :message_id
23
+ expect(subject.to_ruby('FooBar')).to eq :foo_bar
24
+ expect(subject.to_ruby('LongTimeAgoInAFarFarGalaxy')).to eq :long_time_ago_in_a_far_far_galaxy
25
+ expect(subject.to_ruby('MessageID')).to eq :message_id
27
26
  end
28
27
 
29
28
  it 'acts idempotentely' do
30
- subject.to_ruby(:foo_bar).should == :foo_bar
31
- subject.to_ruby(:foo_bar_1).should == :foo_bar_1
29
+ expect(subject.to_ruby(:foo_bar)).to eq :foo_bar
30
+ expect(subject.to_ruby(:foo_bar_1)).to eq :foo_bar_1
32
31
  end
33
32
  end
34
-
35
33
  end
@@ -6,8 +6,8 @@ describe Postmark::Json do
6
6
  shared_examples "json parser" do
7
7
  it 'encodes and decodes data correctly' do
8
8
  hash = Postmark::Json.decode(Postmark::Json.encode(data))
9
- hash.should have_key("bar")
10
- hash.should have_key("foo")
9
+ expect(hash).to have_key("bar")
10
+ expect(hash).to have_key("foo")
11
11
  end
12
12
  end
13
13
 
@@ -2,109 +2,154 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Postmark::MailMessageConverter do
5
-
6
- subject { Postmark::MailMessageConverter }
5
+ subject {Postmark::MailMessageConverter}
7
6
 
8
7
  let(:mail_message) do
9
8
  Mail.new do
10
- from "sheldon@bigbangtheory.com"
11
- to "lenard@bigbangtheory.com"
9
+ from "sheldon@bigbangtheory.com"
10
+ to "lenard@bigbangtheory.com"
12
11
  subject "Hello!"
13
- body "Hello Sheldon!"
12
+ body "Hello Sheldon!"
14
13
  end
15
14
  end
16
15
 
17
16
  let(:mail_html_message) do
18
- mail = Mail.new do
19
- from "sheldon@bigbangtheory.com"
20
- to "lenard@bigbangtheory.com"
21
- subject "Hello!"
17
+ Mail.new do
18
+ from "sheldon@bigbangtheory.com"
19
+ to "lenard@bigbangtheory.com"
20
+ subject "Hello!"
21
+ content_type 'text/html; charset=UTF-8'
22
+ body "<b>Hello Sheldon!</b>"
23
+ end
24
+ end
25
+
26
+ let(:mail_message_with_open_tracking) do
27
+ Mail.new do
28
+ from "sheldon@bigbangtheory.com"
29
+ to "lenard@bigbangtheory.com"
30
+ subject "Hello!"
22
31
  content_type 'text/html; charset=UTF-8'
23
32
  body "<b>Hello Sheldon!</b>"
33
+ track_opens true
24
34
  end
25
35
  end
26
36
 
27
- let(:mail_message_with_tracking) do
28
- mail = Mail.new do
29
- from "sheldon@bigbangtheory.com"
30
- to "lenard@bigbangtheory.com"
31
- subject "Hello!"
32
- content_type 'text/html; charset=UTF-8'
33
- body "<b>Hello Sheldon!</b>"
34
- track_opens true
37
+ let(:mail_message_with_open_tracking_disabled) do
38
+ Mail.new do
39
+ from "sheldon@bigbangtheory.com"
40
+ to "lenard@bigbangtheory.com"
41
+ subject "Hello!"
42
+ content_type 'text/html; charset=UTF-8'
43
+ body "<b>Hello Sheldon!</b>"
44
+ track_opens false
35
45
  end
36
46
  end
37
47
 
48
+ let(:mail_message_with_open_tracking_set_variable) do
49
+ mail = mail_html_message
50
+ mail.track_opens = true
51
+ mail
52
+ end
53
+
54
+ let(:mail_message_with_open_tracking_disabled_set_variable) do
55
+ mail = mail_html_message
56
+ mail.track_opens = false
57
+ mail
58
+ end
59
+
60
+ let(:mail_message_with_link_tracking_all) do
61
+ mail = mail_html_message
62
+ mail.track_links :html_and_text
63
+ mail
64
+ end
65
+
66
+ let(:mail_message_with_link_tracking_html) do
67
+ mail = mail_html_message
68
+ mail.track_links = :html_only
69
+ mail
70
+ end
71
+
72
+ let(:mail_message_with_link_tracking_text) do
73
+ mail = mail_html_message
74
+ mail.track_links = :text_only
75
+ mail
76
+ end
77
+
78
+ let(:mail_message_with_link_tracking_none) do
79
+ mail = mail_html_message
80
+ mail.track_links = :none
81
+ mail
82
+ end
38
83
 
39
84
  let(:tagged_mail_message) do
40
85
  Mail.new do
41
- from "sheldon@bigbangtheory.com"
42
- to "lenard@bigbangtheory.com"
86
+ from "sheldon@bigbangtheory.com"
87
+ to "lenard@bigbangtheory.com"
43
88
  subject "Hello!"
44
- body "Hello Sheldon!"
45
- tag "sheldon"
89
+ body "Hello Sheldon!"
90
+ tag "sheldon"
46
91
  end
47
92
  end
48
93
 
49
94
  let(:mail_message_without_body) do
50
95
  Mail.new do
51
- from "sheldon@bigbangtheory.com"
52
- to "lenard@bigbangtheory.com"
96
+ from "sheldon@bigbangtheory.com"
97
+ to "lenard@bigbangtheory.com"
53
98
  subject "Hello!"
54
99
  end
55
100
  end
56
101
 
57
102
  let(:mail_multipart_message) do
58
- mail = Mail.new do
59
- from "sheldon@bigbangtheory.com"
60
- to "lenard@bigbangtheory.com"
61
- subject "Hello!"
103
+ Mail.new do
104
+ from "sheldon@bigbangtheory.com"
105
+ to "lenard@bigbangtheory.com"
106
+ subject "Hello!"
62
107
  text_part do
63
- body "Hello Sheldon!"
108
+ body "Hello Sheldon!"
64
109
  end
65
110
  html_part do
66
- body "<b>Hello Sheldon!</b>"
111
+ body "<b>Hello Sheldon!</b>"
67
112
  end
68
113
  end
69
114
  end
70
115
 
71
116
  let(:mail_message_with_attachment) do
72
117
  Mail.new do
73
- from "sheldon@bigbangtheory.com"
74
- to "lenard@bigbangtheory.com"
118
+ from "sheldon@bigbangtheory.com"
119
+ to "lenard@bigbangtheory.com"
75
120
  subject "Hello!"
76
- body "Hello Sheldon!"
121
+ body "Hello Sheldon!"
77
122
  add_file empty_gif_path
78
123
  end
79
124
  end
80
125
 
81
126
  let(:mail_message_with_named_addresses) do
82
127
  Mail.new do
83
- from "Sheldon <sheldon@bigbangtheory.com>"
84
- to "\"Leonard Hofstadter\" <leonard@bigbangtheory.com>"
128
+ from "Sheldon <sheldon@bigbangtheory.com>"
129
+ to "\"Leonard Hofstadter\" <leonard@bigbangtheory.com>"
85
130
  subject "Hello!"
86
- body "Hello Sheldon!"
131
+ body "Hello Sheldon!"
87
132
  reply_to '"Penny The Neighbor" <penny@bigbangtheory.com>'
88
133
  end
89
134
  end
90
135
 
91
136
  let(:mail_message_quoted_printable) do
92
137
  Mail.new do
93
- from "Sheldon <sheldon@bigbangtheory.com>"
94
- to "\"Leonard Hofstadter\" <leonard@bigbangtheory.com>"
138
+ from "Sheldon <sheldon@bigbangtheory.com>"
139
+ to "\"Leonard Hofstadter\" <leonard@bigbangtheory.com>"
95
140
  subject "Hello!"
96
141
  content_type 'text/plain; charset=utf-8'
97
142
  content_transfer_encoding 'quoted-printable'
98
- body 'Он здесь бывал: еще не в галифе.'
143
+ body 'Он здесь бывал: еще не в галифе.'
99
144
  reply_to '"Penny The Neighbor" <penny@bigbangtheory.com>'
100
145
  end
101
146
  end
102
147
 
103
148
  let(:multipart_message_quoted_printable) do
104
149
  Mail.new do
105
- from "sheldon@bigbangtheory.com"
106
- to "lenard@bigbangtheory.com"
107
- subject "Hello!"
150
+ from "sheldon@bigbangtheory.com"
151
+ to "lenard@bigbangtheory.com"
152
+ subject "Hello!"
108
153
  text_part do
109
154
  content_type 'text/plain; charset=utf-8'
110
155
  content_transfer_encoding 'quoted-printable'
@@ -118,107 +163,231 @@ describe Postmark::MailMessageConverter do
118
163
  end
119
164
  end
120
165
 
166
+ let(:templated_message) do
167
+ Mail.new do
168
+ from "sheldon@bigbangtheory.com"
169
+ to "lenard@bigbangtheory.com"
170
+ template_alias "hello"
171
+ template_model :name => "Sheldon"
172
+ end
173
+ end
174
+
121
175
  it 'converts plain text messages correctly' do
122
- subject.new(mail_message).run.should == {
176
+ expect(subject.new(mail_message).run).to eq({
123
177
  "From" => "sheldon@bigbangtheory.com",
124
178
  "Subject" => "Hello!",
125
179
  "TextBody" => "Hello Sheldon!",
126
- "To" => "lenard@bigbangtheory.com",
127
- 'TrackOpens' => false}
180
+ "To" => "lenard@bigbangtheory.com"})
128
181
  end
129
182
 
130
183
  it 'converts tagged text messages correctly' do
131
- subject.new(tagged_mail_message).run.should == {
184
+ expect(subject.new(tagged_mail_message).run).to eq({
132
185
  "From" => "sheldon@bigbangtheory.com",
133
186
  "Subject" => "Hello!",
134
187
  "TextBody" => "Hello Sheldon!",
135
188
  "Tag" => "sheldon",
136
- "To"=>"lenard@bigbangtheory.com",
137
- 'TrackOpens' => false}
189
+ "To" => "lenard@bigbangtheory.com"})
138
190
  end
139
191
 
140
192
  it 'converts plain text messages without body correctly' do
141
- subject.new(mail_message_without_body).run.should == {
193
+ expect(subject.new(mail_message_without_body).run).to eq({
142
194
  "From" => "sheldon@bigbangtheory.com",
143
195
  "Subject" => "Hello!",
144
- "To" => "lenard@bigbangtheory.com",
145
- 'TrackOpens' => false}
196
+ "To" => "lenard@bigbangtheory.com"})
146
197
  end
147
198
 
148
199
  it 'converts html messages correctly' do
149
- subject.new(mail_html_message).run.should == {
200
+ expect(subject.new(mail_html_message).run).to eq({
150
201
  "From" => "sheldon@bigbangtheory.com",
151
202
  "Subject" => "Hello!",
152
203
  "HtmlBody" => "<b>Hello Sheldon!</b>",
153
- "To" => "lenard@bigbangtheory.com",
154
- 'TrackOpens' => false}
204
+ "To" => "lenard@bigbangtheory.com"})
155
205
  end
156
206
 
157
207
  it 'converts multipart messages correctly' do
158
- subject.new(mail_multipart_message).run.should == {
208
+ expect(subject.new(mail_multipart_message).run).to eq({
159
209
  "From" => "sheldon@bigbangtheory.com",
160
210
  "Subject" => "Hello!",
161
211
  "HtmlBody" => "<b>Hello Sheldon!</b>",
162
212
  "TextBody" => "Hello Sheldon!",
163
- "To" => "lenard@bigbangtheory.com",
164
- 'TrackOpens' => false}
213
+ "To" => "lenard@bigbangtheory.com"})
165
214
  end
166
215
 
167
216
  it 'converts messages with attachments correctly' do
168
- subject.new(mail_message_with_attachment).run.should == {
217
+ expect(subject.new(mail_message_with_attachment).run).to eq({
169
218
  "From" => "sheldon@bigbangtheory.com",
170
219
  "Subject" => "Hello!",
171
- "Attachments" => [{"Name"=>"empty.gif",
172
- "Content"=>encoded_empty_gif_data,
173
- "ContentType"=>"image/gif"}],
174
- "TextBody"=>"Hello Sheldon!",
175
- "To"=>"lenard@bigbangtheory.com",
176
- 'TrackOpens' => false}
220
+ "Attachments" => [{"Name" => "empty.gif",
221
+ "Content" => encoded_empty_gif_data,
222
+ "ContentType" => "image/gif"}],
223
+ "TextBody" => "Hello Sheldon!",
224
+ "To" => "lenard@bigbangtheory.com"})
177
225
  end
178
226
 
179
227
  it 'converts messages with named addresses correctly' do
180
- subject.new(mail_message_with_named_addresses).run.should == {
228
+ expect(subject.new(mail_message_with_named_addresses).run).to eq({
181
229
  "From" => "Sheldon <sheldon@bigbangtheory.com>",
182
230
  "Subject" => "Hello!",
183
231
  "TextBody" => "Hello Sheldon!",
184
232
  "To" => "Leonard Hofstadter <leonard@bigbangtheory.com>",
185
- "ReplyTo" => 'Penny The Neighbor <penny@bigbangtheory.com>',
186
- 'TrackOpens' => false
187
- }
233
+ "ReplyTo" => 'Penny The Neighbor <penny@bigbangtheory.com>'})
188
234
  end
189
235
 
190
- it 'recognizes when open tracking is enabled' do
191
- subject.new(mail_message_with_tracking).run.should == {
192
- "From" => "sheldon@bigbangtheory.com",
193
- "Subject" => "Hello!",
194
- "HtmlBody" => "<b>Hello Sheldon!</b>",
195
- "To" => "lenard@bigbangtheory.com",
196
- "TrackOpens" => true}
236
+ it 'convertes templated messages correctly' do
237
+ expect(subject.new(templated_message).run).to eq({
238
+ "From" => "sheldon@bigbangtheory.com",
239
+ "TemplateAlias" => "hello",
240
+ "TemplateModel" => {:name => "Sheldon"},
241
+ "To" => "lenard@bigbangtheory.com"})
242
+ end
243
+
244
+ context 'open tracking' do
245
+ context 'setup inside of mail' do
246
+ it 'converts open tracking enabled messages correctly' do
247
+ expect(subject.new(mail_message_with_open_tracking).run).to eq({
248
+ "From" => "sheldon@bigbangtheory.com",
249
+ "Subject" => "Hello!",
250
+ "HtmlBody" => "<b>Hello Sheldon!</b>",
251
+ "To" => "lenard@bigbangtheory.com",
252
+ "TrackOpens" => true})
253
+ end
254
+
255
+ it 'converts open tracking disabled messages correctly' do
256
+ expect(subject.new(mail_message_with_open_tracking_disabled).run).to eq({
257
+ "From" => "sheldon@bigbangtheory.com",
258
+ "Subject" => "Hello!",
259
+ "HtmlBody" => "<b>Hello Sheldon!</b>",
260
+ "To" => "lenard@bigbangtheory.com",
261
+ "TrackOpens" => false})
262
+ end
263
+ end
264
+
265
+ context 'setup with tracking variable' do
266
+ it 'converts open tracking enabled messages correctly' do
267
+ expect(subject.new(mail_message_with_open_tracking_set_variable).run).to eq({
268
+ "From" => "sheldon@bigbangtheory.com",
269
+ "Subject" => "Hello!",
270
+ "HtmlBody" => "<b>Hello Sheldon!</b>",
271
+ "To" => "lenard@bigbangtheory.com",
272
+ "TrackOpens" => true})
273
+ end
274
+
275
+ it 'converts open tracking disabled messages correctly' do
276
+ expect(subject.new(mail_message_with_open_tracking_disabled_set_variable).run).to eq({
277
+ "From" => "sheldon@bigbangtheory.com",
278
+ "Subject" => "Hello!",
279
+ "HtmlBody" => "<b>Hello Sheldon!</b>",
280
+ "To" => "lenard@bigbangtheory.com",
281
+ "TrackOpens" => false})
282
+ end
283
+ end
284
+ end
285
+
286
+ context 'link tracking' do
287
+ it 'converts html and text link tracking enabled messages correctly' do
288
+ expect(subject.new(mail_message_with_link_tracking_all).run).to eq({
289
+ "From" => "sheldon@bigbangtheory.com",
290
+ "Subject" => "Hello!",
291
+ "HtmlBody" => "<b>Hello Sheldon!</b>",
292
+ "To" => "lenard@bigbangtheory.com",
293
+ "TrackLinks" => 'HtmlAndText'})
294
+ end
295
+
296
+ it 'converts html only link tracking enabled messages correctly' do
297
+ expect(subject.new(mail_message_with_link_tracking_html).run).to eq({
298
+ "From" => "sheldon@bigbangtheory.com",
299
+ "Subject" => "Hello!",
300
+ "HtmlBody" => "<b>Hello Sheldon!</b>",
301
+ "To" => "lenard@bigbangtheory.com",
302
+ "TrackLinks" => 'HtmlOnly'})
303
+ end
304
+
305
+ it 'converts text only link tracking enabled messages correctly' do
306
+ expect(subject.new(mail_message_with_link_tracking_text).run).to eq({
307
+ "From" => "sheldon@bigbangtheory.com",
308
+ "Subject" => "Hello!",
309
+ "HtmlBody" => "<b>Hello Sheldon!</b>",
310
+ "To" => "lenard@bigbangtheory.com",
311
+ "TrackLinks" => 'TextOnly'})
312
+ end
313
+
314
+ it 'converts link tracking disabled messages correctly' do
315
+ expect(subject.new(mail_message_with_link_tracking_none).run).to eq ({
316
+ "From" => "sheldon@bigbangtheory.com",
317
+ "Subject" => "Hello!",
318
+ "HtmlBody" => "<b>Hello Sheldon!</b>",
319
+ "To" => "lenard@bigbangtheory.com",
320
+ "TrackLinks" => 'None'})
321
+ end
322
+
323
+ it 'converts link tracking options when set via header' do
324
+ msg = mail_html_message
325
+ msg[:track_links] = :html_and_text
326
+ expect(subject.new(msg).run).to include('TrackLinks' => 'HtmlAndText')
327
+ end
328
+ end
329
+
330
+ context 'metadata' do
331
+ it 'converts single metadata field' do
332
+ metadata = {:test => 'test'}
333
+ msg = mail_html_message
334
+ msg.metadata = metadata
335
+ expect(subject.new(msg).run).to include('Metadata' => metadata)
336
+ end
337
+
338
+ it 'converts unicode metadata field metadata' do
339
+ metadata = {:test => "Велик"}
340
+ msg = mail_html_message
341
+ msg.metadata = metadata
342
+ expect(subject.new(msg).run).to include('Metadata' => metadata)
343
+ end
344
+
345
+ it 'converts multiple metadata fields' do
346
+ metadata = {}
347
+ 10.times {|i| metadata["test#{i + 1}"] = "t" * 80}
348
+ msg = mail_html_message
349
+ msg.metadata = metadata
350
+ expect(subject.new(msg).run).to include('Metadata' => metadata)
351
+ end
197
352
  end
198
353
 
199
354
  it 'correctly decodes unicode in messages transfered as quoted-printable' do
200
- subject.new(mail_message_quoted_printable).run.should \
201
- include('TextBody' => 'Он здесь бывал: еще не в галифе.')
355
+ expect(subject.new(mail_message_quoted_printable).run).to include('TextBody' => 'Он здесь бывал: еще не в галифе.')
202
356
  end
203
357
 
204
358
  it 'correctly decodes unicode in multipart quoted-printable messages' do
205
- subject.new(multipart_message_quoted_printable).run.should \
206
- include('TextBody' => 'Загадочное послание.',
207
- 'HtmlBody' => '<b>Загадочное послание.</b>')
359
+ expect(subject.new(multipart_message_quoted_printable).run).to include(
360
+ 'TextBody' => 'Загадочное послание.',
361
+ 'HtmlBody' => '<b>Загадочное послание.</b>')
208
362
  end
209
363
 
210
364
  context 'when bcc is empty' do
211
365
  it 'excludes bcc from message' do
212
366
  mail_message.bcc = nil
213
- mail_message.to_postmark_hash.keys.should_not include('Bcc')
367
+ expect(mail_message.to_postmark_hash.keys).not_to include('Bcc')
214
368
  end
215
369
  end
216
370
 
217
371
  context 'when cc is empty' do
218
372
  it 'excludes cc from message' do
219
373
  mail_message.cc = nil
220
- mail_message.to_postmark_hash.keys.should_not include('Cc')
374
+ expect(mail_message.to_postmark_hash.keys).not_to include('Cc')
221
375
  end
222
376
  end
223
377
 
378
+ describe 'passing message stream' do
379
+ context 'when not set' do
380
+ specify { expect(subject.new(mail_message).run).not_to include('MessageStream') }
381
+ end
382
+
383
+ context 'when set' do
384
+ before do
385
+ mail_message.message_stream = 'weekly-newsletter'
386
+ end
387
+
388
+ it 'passes message stream to the API call' do
389
+ expect(subject.new(mail_message).run).to include('MessageStream' => 'weekly-newsletter')
390
+ end
391
+ end
392
+ end
224
393
  end