postmark 0.9.10 → 0.9.11
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.
- data/.bundle/config +2 -3
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/CHANGELOG.rdoc +7 -0
- data/Gemfile +11 -0
- data/README.rdoc +4 -1
- data/Rakefile +3 -63
- data/VERSION +1 -1
- data/lib/postmark.rb +115 -114
- data/lib/postmark/http_client.rb +55 -56
- data/lib/postmark/message_extensions/shared.rb +8 -8
- data/lib/postmark/version.rb +3 -0
- data/postmark.gemspec +39 -82
- data/spec/postmark_spec.rb +37 -115
- data/spec/shared_examples.rb +41 -0
- data/spec/spec_helper.rb +15 -4
- metadata +135 -131
- data/spec/spec.opts +0 -3
@@ -1,6 +1,6 @@
|
|
1
1
|
module Postmark
|
2
2
|
module SharedMessageExtensions
|
3
|
-
|
3
|
+
|
4
4
|
def tag
|
5
5
|
self['TAG']
|
6
6
|
end
|
@@ -8,15 +8,15 @@ module Postmark
|
|
8
8
|
def tag=(value)
|
9
9
|
self['TAG'] = value
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def postmark_attachments=(value)
|
13
|
-
@_attachments =
|
13
|
+
@_attachments = Array.wrap(value)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def postmark_attachments
|
17
17
|
return if @_attachments.nil?
|
18
|
-
|
19
|
-
@_attachments.
|
18
|
+
|
19
|
+
@_attachments.map do |item|
|
20
20
|
if item.is_a?(Hash)
|
21
21
|
item
|
22
22
|
elsif item.is_a?(File)
|
@@ -28,6 +28,6 @@ module Postmark
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
end
|
33
|
-
end
|
33
|
+
end
|
data/postmark.gemspec
CHANGED
@@ -1,92 +1,49 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "postmark/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = "postmark"
|
7
|
+
s.version = Postmark::VERSION
|
8
|
+
s.homepage = "http://postmarkapp.com"
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
|
11
|
+
s.authors = ["Petyo Ivanov", "Ilya Sabanin", "Artem Chistyakov"]
|
12
|
+
s.date = "2012-01-31"
|
13
|
+
s.email = "ilya@wildbit.com"
|
14
|
+
s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
|
15
|
+
|
16
|
+
s.summary = "Official Postmark API wrapper."
|
17
|
+
s.description = "Use this gem to send emails through Postmark HTTP API and retrieve info about bounces."
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
9
23
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Petyo Ivanov", "Ilya Sabanin", "Artem Chistyakov"]
|
12
|
-
s.date = %q{2012-01-31}
|
13
|
-
s.description = %q{Use this gem to send emails through Postmark HTTP API and retrieve info about bounces.}
|
14
|
-
s.email = %q{ilya@wildbit.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".bundle/config",
|
21
|
-
".document",
|
22
|
-
".rake_tasks",
|
23
|
-
"CHANGELOG.rdoc",
|
24
|
-
"LICENSE",
|
25
|
-
"README.rdoc",
|
26
|
-
"Rakefile",
|
27
|
-
"VERSION",
|
28
|
-
"init.rb",
|
29
|
-
"lib/postmark.rb",
|
30
|
-
"lib/postmark/attachments_fix_for_mail.rb",
|
31
|
-
"lib/postmark/bounce.rb",
|
32
|
-
"lib/postmark/handlers/mail.rb",
|
33
|
-
"lib/postmark/http_client.rb",
|
34
|
-
"lib/postmark/json.rb",
|
35
|
-
"lib/postmark/message_extensions/mail.rb",
|
36
|
-
"lib/postmark/message_extensions/shared.rb",
|
37
|
-
"lib/postmark/message_extensions/tmail.rb",
|
38
|
-
"lib/postmark/response_parsers/active_support.rb",
|
39
|
-
"lib/postmark/response_parsers/json.rb",
|
40
|
-
"lib/postmark/response_parsers/yajl.rb",
|
41
|
-
"postmark.gemspec",
|
42
|
-
"spec/bounce_spec.rb",
|
43
|
-
"spec/postmark_spec.rb",
|
44
|
-
"spec/spec.opts",
|
45
|
-
"spec/spec_helper.rb"
|
46
|
-
]
|
47
|
-
s.homepage = %q{http://postmarkapp.com}
|
48
24
|
s.post_install_message = %q{
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
s.require_paths = ["lib"]
|
55
|
-
s.rubygems_version = %q{1.3.7}
|
56
|
-
s.summary = %q{Official Postmark API wrapper.}
|
25
|
+
==================
|
26
|
+
Thanks for installing the postmark gem. If you don't have an account, please sign up at http://postmarkapp.com/.
|
27
|
+
Review the README.rdoc for implementation details and examples.
|
28
|
+
==================
|
29
|
+
}
|
57
30
|
|
58
|
-
|
59
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
60
|
-
s.specification_version = 3
|
31
|
+
s.required_rubygems_version = ">= 1.3.7"
|
61
32
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
76
|
-
s.add_dependency(%q<fakeweb>, [">= 0"])
|
77
|
-
s.add_dependency(%q<fakeweb-matcher>, [">= 0"])
|
78
|
-
s.add_dependency(%q<timecop>, [">= 0"])
|
79
|
-
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
80
|
-
end
|
33
|
+
s.add_dependency "rake"
|
34
|
+
s.add_dependency "json"
|
35
|
+
|
36
|
+
s.add_development_dependency "tmail"
|
37
|
+
s.add_development_dependency "mail"
|
38
|
+
s.add_development_dependency "rspec-core", "~> 2.0"
|
39
|
+
s.add_development_dependency "activesupport", "~> 3.0"
|
40
|
+
s.add_development_dependency "fakeweb"
|
41
|
+
s.add_development_dependency "fakeweb-matcher"
|
42
|
+
s.add_development_dependency "timecop"
|
43
|
+
s.add_development_dependency "yajl-ruby"
|
44
|
+
if RUBY_VERSION < '1.9.0'
|
45
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
81
46
|
else
|
82
|
-
s.
|
83
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
84
|
-
s.add_dependency(%q<json>, [">= 0"])
|
85
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
86
|
-
s.add_dependency(%q<fakeweb>, [">= 0"])
|
87
|
-
s.add_dependency(%q<fakeweb-matcher>, [">= 0"])
|
88
|
-
s.add_dependency(%q<timecop>, [">= 0"])
|
89
|
-
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
47
|
+
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
90
48
|
end
|
91
49
|
end
|
92
|
-
|
data/spec/postmark_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Postmark do
|
4
4
|
|
5
5
|
let :tmail_message do
|
6
6
|
TMail::Mail.new.tap do |mail|
|
@@ -61,39 +61,49 @@ describe "Postmark" do
|
|
61
61
|
Postmark.sleep_between_retries = 0
|
62
62
|
end
|
63
63
|
|
64
|
+
def stub_web!(data={})
|
65
|
+
data[:body] ||= response_body(data[:status].nil? ? 200 : data[:status].first)
|
66
|
+
FakeWeb.register_uri(:post, "http://api.postmarkapp.com/email", data)
|
67
|
+
end
|
68
|
+
|
69
|
+
def response_body(status, message="")
|
70
|
+
body = {"ErrorCode" => status, "Message" => message}.to_json
|
71
|
+
end
|
72
|
+
|
64
73
|
it "should send email successfully" do
|
65
|
-
|
66
|
-
Postmark.send_through_postmark(
|
74
|
+
stub_web!
|
75
|
+
Postmark.send_through_postmark(mail_message)
|
67
76
|
FakeWeb.should have_requested(:post, "http://api.postmarkapp.com/email")
|
68
77
|
end
|
69
78
|
|
70
79
|
it "should warn when header is invalid" do
|
71
|
-
|
72
|
-
lambda { Postmark.send_through_postmark(
|
80
|
+
stub_web!({:status => [ "401", "Unauthorized" ]})
|
81
|
+
lambda { Postmark.send_through_postmark(mail_message) }.should raise_error(Postmark::InvalidApiKeyError)
|
73
82
|
end
|
74
83
|
|
75
84
|
it "should warn when json is not ok" do
|
76
|
-
|
77
|
-
lambda { Postmark.send_through_postmark(
|
85
|
+
stub_web!({:status => [ "422", "Invalid" ]})
|
86
|
+
lambda { Postmark.send_through_postmark(mail_message) }.should raise_error(Postmark::InvalidMessageError)
|
78
87
|
end
|
79
88
|
|
80
89
|
it "should warn when server fails" do
|
81
|
-
|
82
|
-
lambda { Postmark.send_through_postmark(
|
90
|
+
stub_web!({:status => [ "500", "Internal Server Error" ]})
|
91
|
+
lambda { Postmark.send_through_postmark(mail_message) }.should raise_error(Postmark::InternalServerError)
|
83
92
|
end
|
84
93
|
|
85
94
|
it "should warn when unknown stuff fails" do
|
86
|
-
|
87
|
-
lambda { Postmark.send_through_postmark(
|
95
|
+
stub_web!({:status => [ "485", "Custom HTTP response status" ]})
|
96
|
+
lambda { Postmark.send_through_postmark(mail_message) }.should raise_error(Postmark::UnknownError)
|
88
97
|
end
|
89
98
|
|
90
99
|
it "should retry 3 times" do
|
91
100
|
FakeWeb.register_uri(:post, "http://api.postmarkapp.com/email",
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
101
|
+
[
|
102
|
+
{ :status => [ 500, "Internal Server Error" ], :body => response_body(500, 'Internal Server Error') },
|
103
|
+
{ :status => [ 500, "Internal Server Error" ], :body => response_body(500, 'Internal Server Error') },
|
104
|
+
{ :body => response_body(500, 'Internal Server Error') }
|
105
|
+
])
|
106
|
+
lambda { Postmark.send_through_postmark(mail_message) }.should_not raise_error
|
97
107
|
end
|
98
108
|
end
|
99
109
|
|
@@ -110,117 +120,29 @@ describe "Postmark" do
|
|
110
120
|
end
|
111
121
|
end
|
112
122
|
|
113
|
-
context "tmail parse" do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should set text body for plain message" do
|
121
|
-
Postmark.send(:convert_message_to_options_hash, tmail_message)['TextBody'].should_not be_nil
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should set html body for html message" do
|
125
|
-
Postmark.send(:convert_message_to_options_hash, tmail_html_message)['HtmlBody'].should_not be_nil
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should encode custom headers headers properly" do
|
129
|
-
tmail_message["CUSTOM-HEADER"] = "header"
|
130
|
-
tmail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!", "Headers":[{"Name":"Custom-Header", "Value":"header"}]}]
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should encode from properly when name is used" do
|
134
|
-
tmail_message.from = "Sheldon Lee Cooper <sheldon@bigbangtheory.com>"
|
135
|
-
tmail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"Sheldon Lee Cooper <sheldon@bigbangtheory.com>", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should encode reply to" do
|
139
|
-
tmail_message.reply_to = ['a@a.com', 'b@b.com']
|
140
|
-
tmail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "ReplyTo":"a@a.com, b@b.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should encode tag" do
|
144
|
-
tmail_message.tag = "invite"
|
145
|
-
tmail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "Tag":"invite", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should encode multiple recepients (TO)" do
|
149
|
-
tmail_message.to = ['a@a.com', 'b@b.com']
|
150
|
-
tmail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"a@a.com, b@b.com", "TextBody":"Hello Sheldon!"}]
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should encode multiple recepients (CC)" do
|
154
|
-
tmail_message.cc = ['a@a.com', 'b@b.com']
|
155
|
-
tmail_message.should be_serialized_to %q[{"Cc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should encode multiple recepients (BCC)" do
|
159
|
-
tmail_message.bcc = ['a@a.com', 'b@b.com']
|
160
|
-
tmail_message.should be_serialized_to %q[{"Bcc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
161
|
-
end
|
123
|
+
context "tmail parse", :ruby => 1.8 do
|
124
|
+
require 'tmail'
|
125
|
+
subject { tmail_message }
|
126
|
+
it_behaves_like :mail
|
162
127
|
end
|
163
128
|
|
164
|
-
context "mail parse" do
|
165
|
-
|
166
|
-
|
167
|
-
Postmark.send(:convert_message_to_options_hash, mail_message).should == JSON.parse(json)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should set text body for plain message" do
|
172
|
-
Postmark.send(:convert_message_to_options_hash, mail_message)['TextBody'].should_not be_nil
|
173
|
-
end
|
129
|
+
context "when mail parse" do
|
130
|
+
subject { mail_message }
|
131
|
+
it_behaves_like :mail
|
174
132
|
|
175
133
|
it "should set html body for html message" do
|
176
134
|
Postmark.send(:convert_message_to_options_hash, mail_html_message)['HtmlBody'].should_not be_nil
|
177
135
|
end
|
178
|
-
|
179
|
-
it "should set html and text body for multipart message" do
|
180
|
-
Postmark.send(:convert_message_to_options_hash, mail_multipart_message)['HtmlBody'].should_not be_nil
|
181
|
-
Postmark.send(:convert_message_to_options_hash, mail_multipart_message)['TextBody'].should_not be_nil
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should encode custom headers properly" do
|
185
|
-
mail_message.header["CUSTOM-HEADER"] = "header"
|
186
|
-
mail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!", "Headers":[{"Name":"Custom-Header", "Value":"header"}]}]
|
187
|
-
end
|
188
|
-
|
189
|
-
it "should encode from properly when name is used" do
|
190
|
-
mail_message.from = "Sheldon Lee Cooper <sheldon@bigbangtheory.com>"
|
191
|
-
mail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"Sheldon Lee Cooper <sheldon@bigbangtheory.com>", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
192
|
-
end
|
193
136
|
|
194
|
-
it "should encode
|
195
|
-
|
196
|
-
|
197
|
-
end
|
198
|
-
|
199
|
-
it "should encode tag" do
|
200
|
-
mail_message.tag = "invite"
|
201
|
-
mail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "Tag":"invite", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should encode multiple recepients (TO)" do
|
205
|
-
mail_message.to = ['a@a.com', 'b@b.com']
|
206
|
-
mail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"a@a.com, b@b.com", "TextBody":"Hello Sheldon!"}]
|
207
|
-
end
|
208
|
-
|
209
|
-
it "should encode multiple recepients (CC)" do
|
210
|
-
mail_message.cc = ['a@a.com', 'b@b.com']
|
211
|
-
mail_message.should be_serialized_to %q[{"Cc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
212
|
-
end
|
213
|
-
|
214
|
-
it "should encode multiple recepients (BCC)" do
|
215
|
-
mail_message.bcc = ['a@a.com', 'b@b.com']
|
216
|
-
mail_message.should be_serialized_to %q[{"Bcc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
217
|
-
end
|
137
|
+
it "should encode custom headers properly" do
|
138
|
+
subject.header["CUSTOM-HEADER"] = "header"
|
139
|
+
subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!", "Headers":[{"Name":"Custom-Header", "Value":"header"}]}]
|
140
|
+
end
|
218
141
|
end
|
219
142
|
|
220
143
|
context "mail delivery method" do
|
221
144
|
it "should be able to set delivery_method" do
|
222
145
|
mail_message.delivery_method Mail::Postmark
|
223
|
-
puts mail_message.delivery_method
|
224
146
|
end
|
225
147
|
|
226
148
|
it "should wrap Postmark.send_through_postmark" do
|
@@ -0,0 +1,41 @@
|
|
1
|
+
shared_examples :mail do
|
2
|
+
it "should set text body for plain message" do
|
3
|
+
Postmark.send(:convert_message_to_options_hash, subject)['TextBody'].should_not be_nil
|
4
|
+
end
|
5
|
+
|
6
|
+
it "should encode from properly when name is used" do
|
7
|
+
subject.from = "Sheldon Lee Cooper <sheldon@bigbangtheory.com>"
|
8
|
+
subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"Sheldon Lee Cooper <sheldon@bigbangtheory.com>", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should encode reply to" do
|
12
|
+
subject.reply_to = ['a@a.com', 'b@b.com']
|
13
|
+
subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "ReplyTo":"a@a.com, b@b.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should encode tag" do
|
17
|
+
subject.tag = "invite"
|
18
|
+
subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "Tag":"invite", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should encode multiple recepients (TO)" do
|
22
|
+
subject.to = ['a@a.com', 'b@b.com']
|
23
|
+
subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"a@a.com, b@b.com", "TextBody":"Hello Sheldon!"}]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should encode multiple recepients (CC)" do
|
27
|
+
subject.cc = ['a@a.com', 'b@b.com']
|
28
|
+
subject.should be_serialized_to %q[{"Cc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should encode multiple recepients (BCC)" do
|
32
|
+
subject.bcc = ['a@a.com', 'b@b.com']
|
33
|
+
subject.should be_serialized_to %q[{"Bcc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should accept string as reply_to field" do
|
37
|
+
subject.reply_to = ['Anton Astashov <b@b.com>']
|
38
|
+
puts subject.reply_to.inspect
|
39
|
+
subject.should be_serialized_to %q[{"From": "sheldon@bigbangtheory.com", "ReplyTo": "b@b.com", "To": "lenard@bigbangtheory.com", "Subject": "Hello!", "TextBody": "Hello Sheldon!"}]
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
Bundler.setup(:development)
|
4
6
|
require 'mail'
|
5
|
-
require 'tmail'
|
7
|
+
#require 'tmail'
|
6
8
|
require 'postmark'
|
7
9
|
require 'active_support'
|
8
10
|
require 'json'
|
@@ -10,8 +12,9 @@ require 'ruby-debug'
|
|
10
12
|
require 'fakeweb'
|
11
13
|
require 'fakeweb_matcher'
|
12
14
|
require 'timecop'
|
13
|
-
require '
|
14
|
-
require '
|
15
|
+
require 'rspec'
|
16
|
+
require 'rspec/autorun'
|
17
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'shared_examples.rb')
|
15
18
|
|
16
19
|
if ENV['JSONGEM']
|
17
20
|
# `JSONGEM=Yajl rake spec`
|
@@ -19,6 +22,14 @@ if ENV['JSONGEM']
|
|
19
22
|
puts "Setting ResponseParser class to #{Postmark::ResponseParsers.const_get Postmark.response_parser_class}"
|
20
23
|
end
|
21
24
|
|
22
|
-
|
25
|
+
RSpec.configure do |config|
|
26
|
+
config.filter_run_excluding :ruby => lambda { |version|
|
27
|
+
RUBY_VERSION.to_s !~ /^#{version.to_s}/
|
28
|
+
}
|
29
|
+
end
|
23
30
|
|
31
|
+
RSpec::Matchers.define :be_serialized_to do |json|
|
32
|
+
match do |mail_message|
|
33
|
+
Postmark.convert_message_to_options_hash(mail_message).should == JSON.parse(json)
|
34
|
+
end
|
24
35
|
end
|