postmark 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ ---
2
+ BUNDLE_WITHOUT: ""
3
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source :gemcutter
2
+
3
+ gem "rake"
4
+ gem "jeweler"
5
+ gem "tmail"
6
+ gem "mail"
7
+
8
+ group :test do
9
+ gem "rspec"
10
+ gem "cucumber"
11
+ gem "activesupport"
12
+ gem "json"
13
+ gem "ruby-debug"
14
+ gem "fakeweb"
15
+ gem "fakeweb-matcher"
16
+ gem "timecop"
17
+ gem "yajl-ruby"
18
+ end
@@ -0,0 +1,68 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (2.3.8)
5
+ builder (2.1.2)
6
+ columnize (0.3.1)
7
+ cucumber (0.8.5)
8
+ builder (~> 2.1.2)
9
+ diff-lcs (~> 1.1.2)
10
+ gherkin (~> 2.1.4)
11
+ json_pure (~> 1.4.3)
12
+ term-ansicolor (~> 1.0.4)
13
+ diff-lcs (1.1.2)
14
+ fakeweb (1.3.0)
15
+ fakeweb-matcher (1.1.0)
16
+ fakeweb (>= 1.2.5)
17
+ rspec (>= 1.2.0)
18
+ gemcutter (0.6.1)
19
+ gherkin (2.1.5)
20
+ trollop (~> 1.16.2)
21
+ git (1.2.5)
22
+ jeweler (1.4.0)
23
+ gemcutter (>= 0.1.0)
24
+ git (>= 1.2.5)
25
+ rubyforge (>= 2.0.0)
26
+ json (1.4.6)
27
+ json_pure (1.4.6)
28
+ linecache (0.43)
29
+ mail (2.2.5)
30
+ activesupport (>= 2.3.6)
31
+ mime-types
32
+ treetop (>= 1.4.5)
33
+ mime-types (1.16)
34
+ polyglot (0.3.1)
35
+ rake (0.8.7)
36
+ rspec (1.3.0)
37
+ ruby-debug (0.10.3)
38
+ columnize (>= 0.1)
39
+ ruby-debug-base (~> 0.10.3.0)
40
+ ruby-debug-base (0.10.3)
41
+ linecache (>= 0.3)
42
+ rubyforge (2.0.4)
43
+ json_pure (>= 1.1.7)
44
+ term-ansicolor (1.0.5)
45
+ timecop (0.3.5)
46
+ tmail (1.2.7.1)
47
+ treetop (1.4.8)
48
+ polyglot (>= 0.3.1)
49
+ trollop (1.16.2)
50
+ yajl-ruby (0.7.7)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ activesupport
57
+ cucumber
58
+ fakeweb
59
+ fakeweb-matcher
60
+ jeweler
61
+ json
62
+ mail
63
+ rake
64
+ rspec
65
+ ruby-debug
66
+ timecop
67
+ tmail
68
+ yajl-ruby
@@ -35,7 +35,13 @@ Then
35
35
  # set reply to if you need; also, you can pass array of emails.
36
36
  message.reply_to = "penny@bigbangtheory.com"
37
37
 
38
- p Postmark.send_through_postmark(message).body
38
+ Postmark.send_through_postmark(message)
39
+
40
+ If you are using the Mail gem, you can also use Postmark as a delivery method like:
41
+
42
+ message = Mail.new
43
+ message.delivery_method Mail::Postmark, {:api_key => "your-api-key"}
44
+ message.deliver
39
45
 
40
46
  You can retrieve various information about your server state using the Public bounces API - http://developer.postmarkapp.com/bounces
41
47
 
@@ -52,10 +58,9 @@ To use SSL encryption when sending email configure the library as follows:
52
58
 
53
59
  Postmark.secure = true
54
60
 
55
-
56
61
  == Requirements
57
62
 
58
- The gem relies on TMail for building the message. You will also need postmark account, server and sender signature set up to use it.
63
+ The gem relies on TMail or Mail for building the message. You will also need postmark account, server and sender signature set up to use it.
59
64
  If you plan using it in a rails project, check out the postmark-rails gem, which is meant to integrate with ActionMailer.
60
65
 
61
66
  The plugin will try to use ActiveSupport Json if it is already included. If not, it will attempt using the built-in ruby Json library.
@@ -80,4 +85,4 @@ http://developer.postmarkapp.com
80
85
 
81
86
  == Copyright
82
87
 
83
- Copyright (c) 2009 Wildbit LLC. See LICENSE for details.
88
+ Copyright (c) 2010 Wildbit LLC. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.8.0
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'postmark'
@@ -0,0 +1,14 @@
1
+ module Mail
2
+ class Postmark
3
+ def initialize(values)
4
+ self.settings = {:api_key => nil}.merge(values)
5
+ end
6
+
7
+ attr_accessor :settings
8
+
9
+ def deliver!(mail)
10
+ ::Postmark.api_key = settings[:api_key]
11
+ ::Postmark.send_through_postmark(mail)
12
+ end
13
+ end
14
+ end
@@ -1,11 +1,11 @@
1
1
  require 'net/http'
2
2
  require 'net/https'
3
- require 'rubygems'
4
- require 'tmail'
5
- require 'postmark/tmail_mail_extension'
6
3
  require 'postmark/bounce'
7
4
  require 'postmark/json'
8
5
  require 'postmark/http_client'
6
+ require 'postmark/tmail_mail_extension'
7
+ require 'postmark/mail_message_extension'
8
+ require 'mail/postmark'
9
9
 
10
10
  module Postmark
11
11
 
@@ -13,6 +13,7 @@ module Postmark
13
13
  class UnknownError < StandardError; end
14
14
  class InvalidMessageError < StandardError; end
15
15
  class InternalServerError < StandardError; end
16
+ class UnknownMessageType < StandardError; end
16
17
 
17
18
  module ResponseParsers
18
19
  autoload :Json, 'postmark/response_parsers/json'
@@ -71,11 +72,11 @@ module Postmark
71
72
  def configure
72
73
  yield self
73
74
  end
74
-
75
+
75
76
  def send_through_postmark(message) #:nodoc:
76
77
  @retries = 0
77
78
  begin
78
- HttpClient.post("email", Postmark::Json.encode(convert_tmail(message)))
79
+ HttpClient.post("email", Postmark::Json.encode(convert(message)))
79
80
  rescue Exception => e
80
81
  if @retries < max_retries
81
82
  @retries += 1
@@ -85,17 +86,68 @@ module Postmark
85
86
  end
86
87
  end
87
88
  end
88
-
89
+
90
+ def convert(message)
91
+ if defined?(TMail) && message.is_a?(TMail::Mail)
92
+ convert_tmail(message)
93
+ else
94
+ convert_mail(message)
95
+ end
96
+ end
97
+
89
98
  def delivery_stats
90
99
  HttpClient.get("deliverystats")
91
100
  end
92
101
 
93
102
  protected
103
+
104
+ def convert_mail(message)
105
+ options = { "From" => message.from.to_s, "Subject" => message.subject }
106
+
107
+ headers = extract_mail_headers(message)
108
+ options["Headers"] = headers unless headers.length == 0
109
+
110
+ options["To"] = message.to.join(", ")
111
+
112
+ options["Tag"] = message.tag.to_s unless message.tag.nil?
113
+
114
+ options["Cc"] = message.cc.join(", ").to_s unless message.cc.nil?
115
+
116
+ options["Bcc"] = message.bcc.join(", ").to_s unless message.bcc.nil?
117
+
118
+ if reply_to = message['reply-to']
119
+ options["ReplyTo"] = reply_to.to_s
120
+ end
121
+
122
+ html = message.body_html
123
+ text = message.body_text
124
+ if message.multipart?
125
+ options["HtmlBody"] = html
126
+ options["TextBody"] = text
127
+ elsif html
128
+ options["HtmlBody"] = html
129
+ else
130
+ options["TextBody"] = text
131
+ end
132
+ options
133
+ end
134
+
135
+ def extract_mail_headers(message)
136
+ headers = []
137
+ message.header.fields.each do |field|
138
+ key = field.name
139
+ value = field.value
140
+ next if bogus_headers.include? key.dup.downcase
141
+ name = key.split(/-/).map {|i| i.capitalize }.join('-')
142
+ headers << { "Name" => name, "Value" => value }
143
+ end
144
+ headers
145
+ end
94
146
 
95
147
  def convert_tmail(message)
96
148
  options = { "From" => message['from'].to_s, "To" => message['to'].to_s, "Subject" => message.subject }
97
149
 
98
- headers = extract_headers(message)
150
+ headers = extract_tmail_headers(message)
99
151
  options["Headers"] = headers unless headers.length == 0
100
152
 
101
153
  options["Tag"] = message.tag.to_s unless message.tag.nil?
@@ -121,7 +173,7 @@ module Postmark
121
173
  options
122
174
  end
123
175
 
124
- def extract_headers(message)
176
+ def extract_tmail_headers(message)
125
177
  headers = []
126
178
  message.each_header do |key, value|
127
179
  next if bogus_headers.include? key.dup.downcase
@@ -0,0 +1,25 @@
1
+ module Mail
2
+ class Message
3
+ def tag
4
+ self["TAG"]
5
+ end
6
+
7
+ def tag=(value)
8
+ self["TAG"] = value
9
+ end
10
+
11
+ def body_html
12
+ unless html_part.nil?
13
+ html_part.body.to_s
14
+ end
15
+ end
16
+
17
+ def body_text
18
+ if text_part.nil?
19
+ body.to_s
20
+ else
21
+ text_part.body.to_s
22
+ end
23
+ end
24
+ end
25
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{postmark}
8
- s.version = "0.7.1"
8
+ s.version = "0.8.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Petyo Ivanov"]
12
- s.date = %q{2010-04-23}
12
+ s.date = %q{2010-09-16}
13
13
  s.description = %q{Ruby gem for sending emails through http://postmarkapp.com HTTP API. It relieas on TMail::Mail for message construction.}
14
14
  s.email = %q{underlog@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -17,9 +17,12 @@ Gem::Specification.new do |s|
17
17
  "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
- ".document",
20
+ ".bundle/config",
21
+ ".document",
21
22
  ".gitignore",
22
23
  ".rake_tasks",
24
+ "Gemfile",
25
+ "Gemfile.lock",
23
26
  "LICENSE",
24
27
  "README.rdoc",
25
28
  "Rakefile",
@@ -27,10 +30,13 @@ Gem::Specification.new do |s|
27
30
  "features/postmark.feature",
28
31
  "features/step_definitions/postmark_steps.rb",
29
32
  "features/support/env.rb",
33
+ "init.rb",
34
+ "lib/mail/postmark.rb",
30
35
  "lib/postmark.rb",
31
36
  "lib/postmark/bounce.rb",
32
37
  "lib/postmark/http_client.rb",
33
38
  "lib/postmark/json.rb",
39
+ "lib/postmark/mail_message_extension.rb",
34
40
  "lib/postmark/response_parsers/active_support.rb",
35
41
  "lib/postmark/response_parsers/json.rb",
36
42
  "lib/postmark/response_parsers/yajl.rb",
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe "Postmark" do
4
4
 
5
- let :message do
5
+ let :tmail_message do
6
6
  TMail::Mail.new.tap do |mail|
7
7
  mail.from = "sheldon@bigbangtheory.com"
8
8
  mail.to = "lenard@bigbangtheory.com"
@@ -11,7 +11,7 @@ describe "Postmark" do
11
11
  end
12
12
  end
13
13
 
14
- let :html_message do
14
+ let :tmail_html_message do
15
15
  TMail::Mail.new.tap do |mail|
16
16
  mail.from = "sheldon@bigbangtheory.com"
17
17
  mail.to = "lenard@bigbangtheory.com"
@@ -20,6 +20,40 @@ describe "Postmark" do
20
20
  mail.content_type = "text/html"
21
21
  end
22
22
  end
23
+
24
+ let :mail_message do
25
+ Mail.new do
26
+ from "sheldon@bigbangtheory.com"
27
+ to "lenard@bigbangtheory.com"
28
+ subject "Hello!"
29
+ body "Hello Sheldon!"
30
+ end
31
+ end
32
+
33
+ let :mail_html_message do
34
+ mail = Mail.new do
35
+ from "sheldon@bigbangtheory.com"
36
+ to "lenard@bigbangtheory.com"
37
+ subject "Hello!"
38
+ html_part do
39
+ body "<b>Hello Sheldon!</b>"
40
+ end
41
+ end
42
+ end
43
+
44
+ let :mail_multipart_message do
45
+ mail = Mail.new do
46
+ from "sheldon@bigbangtheory.com"
47
+ to "lenard@bigbangtheory.com"
48
+ subject "Hello!"
49
+ text_part do
50
+ body "Hello Sheldon!"
51
+ end
52
+ html_part do
53
+ body "<b>Hello Sheldon!</b>"
54
+ end
55
+ end
56
+ end
23
57
 
24
58
  context "service call" do
25
59
 
@@ -29,28 +63,28 @@ describe "Postmark" do
29
63
 
30
64
  it "should send email successfully" do
31
65
  FakeWeb.register_uri(:post, "http://api.postmarkapp.com/email", {})
32
- Postmark.send_through_postmark(message)
66
+ Postmark.send_through_postmark(tmail_message)
33
67
  FakeWeb.should have_requested(:post, "http://api.postmarkapp.com/email")
34
68
  end
35
69
 
36
70
  it "should warn when header is invalid" do
37
71
  FakeWeb.register_uri(:post, "http://api.postmarkapp.com/email", {:status => [ "401", "Unauthorized" ], :body => "Missing API token"})
38
- lambda { Postmark.send_through_postmark(message) }.should raise_error(Postmark::InvalidApiKeyError)
72
+ lambda { Postmark.send_through_postmark(tmail_message) }.should raise_error(Postmark::InvalidApiKeyError)
39
73
  end
40
74
 
41
75
  it "should warn when json is not ok" do
42
76
  FakeWeb.register_uri(:post, "http://api.postmarkapp.com/email", {:status => [ "422", "Invalid" ], :body => "Invalid JSON"})
43
- lambda { Postmark.send_through_postmark(message) }.should raise_error(Postmark::InvalidMessageError)
77
+ lambda { Postmark.send_through_postmark(tmail_message) }.should raise_error(Postmark::InvalidMessageError)
44
78
  end
45
79
 
46
80
  it "should warn when server fails" do
47
81
  FakeWeb.register_uri(:post, "http://api.postmarkapp.com/email", {:status => [ "500", "Internal Server Error" ]})
48
- lambda { Postmark.send_through_postmark(message) }.should raise_error(Postmark::InternalServerError)
82
+ lambda { Postmark.send_through_postmark(tmail_message) }.should raise_error(Postmark::InternalServerError)
49
83
  end
50
84
 
51
85
  it "should warn when unknown stuff fails" do
52
86
  FakeWeb.register_uri(:post, "http://api.postmarkapp.com/email", {:status => [ "485", "Custom HTTP response status" ]})
53
- lambda { Postmark.send_through_postmark(message) }.should raise_error(Postmark::UnknownError)
87
+ lambda { Postmark.send_through_postmark(tmail_message) }.should raise_error(Postmark::UnknownError)
54
88
  end
55
89
 
56
90
  it "should retry 3 times" do
@@ -59,7 +93,7 @@ describe "Postmark" do
59
93
  { :status => [ 500, "Internal Server Error" ] },
60
94
  { } ]
61
95
  )
62
- lambda { Postmark.send_through_postmark(message) }.should_not raise_error
96
+ lambda { Postmark.send_through_postmark(tmail_message) }.should_not raise_error
63
97
  end
64
98
  end
65
99
 
@@ -77,49 +111,119 @@ describe "Postmark" do
77
111
  end
78
112
 
79
113
  context "tmail parse" do
114
+ def be_serialized_to(json)
115
+ simple_matcher "be serialized to #{json}" do |message|
116
+ Postmark.send(:convert_tmail, tmail_message).should == JSON.parse(json)
117
+ end
118
+ end
119
+
80
120
  it "should set text body for plain message" do
81
- Postmark.send(:convert_tmail, message)['TextBody'].should_not be_nil
121
+ Postmark.send(:convert_tmail, tmail_message)['TextBody'].should_not be_nil
82
122
  end
83
123
 
84
124
  it "should set html body for html message" do
85
- Postmark.send(:convert_tmail, html_message)['HtmlBody'].should_not be_nil
125
+ Postmark.send(:convert_tmail, 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"}]}]
86
131
  end
87
- end
88
132
 
89
- def be_serialized_to(json)
90
- simple_matcher "be serialized to #{json}" do |message|
91
- Postmark.send(:convert_tmail, message).should == JSON.parse(json)
133
+ it "should encode reply to" do
134
+ tmail_message.reply_to = ['a@a.com', 'b@b.com']
135
+ 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!"}]
92
136
  end
93
- end
94
137
 
95
- it "should encode custom headers headers properly" do
96
- message["CUSTOM-HEADER"] = "header"
97
- 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"}]}]
98
- end
138
+ it "should encode tag" do
139
+ tmail_message.tag = "invite"
140
+ tmail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "Tag":"invite", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
141
+ end
99
142
 
100
- it "should encode reply to" do
101
- message.reply_to = ['a@a.com', 'b@b.com']
102
- 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!"}]
103
- end
143
+ it "should encode multiple recepients (TO)" do
144
+ tmail_message.to = ['a@a.com', 'b@b.com']
145
+ tmail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"a@a.com, b@b.com", "TextBody":"Hello Sheldon!"}]
146
+ end
104
147
 
105
- it "should encode tag" do
106
- message.tag = "invite"
107
- message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "Tag":"invite", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
108
- end
148
+ it "should encode multiple recepients (CC)" do
149
+ tmail_message.cc = ['a@a.com', 'b@b.com']
150
+ 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!"}]
151
+ end
109
152
 
110
- it "should encode multiple recepients (TO)" do
111
- message.to = ['a@a.com', 'b@b.com']
112
- message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"a@a.com, b@b.com", "TextBody":"Hello Sheldon!"}]
153
+ it "should encode multiple recepients (BCC)" do
154
+ tmail_message.bcc = ['a@a.com', 'b@b.com']
155
+ 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!"}]
156
+ end
113
157
  end
158
+
159
+ context "mail parse" do
160
+ def be_serialized_to(json)
161
+ simple_matcher "be serialized to #{json}" do |message|
162
+ Postmark.send(:convert_mail, mail_message).should == JSON.parse(json)
163
+ end
164
+ end
165
+
166
+ it "should set text body for plain message" do
167
+ Postmark.send(:convert_mail, mail_message)['TextBody'].should_not be_nil
168
+ end
114
169
 
115
- it "should encode multiple recepients (CC)" do
116
- message.cc = ['a@a.com', 'b@b.com']
117
- 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!"}]
170
+ it "should set html body for html message" do
171
+ Postmark.send(:convert_mail, mail_html_message)['HtmlBody'].should_not be_nil
172
+ end
173
+
174
+ it "should set html and text body for multipart message" do
175
+ Postmark.send(:convert_mail, mail_multipart_message)['HtmlBody'].should_not be_nil
176
+ Postmark.send(:convert_mail, mail_multipart_message)['TextBody'].should_not be_nil
177
+ end
178
+
179
+ it "should encode custom headers properly" do
180
+ mail_message.header["CUSTOM-HEADER"] = "header"
181
+ 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"}]}]
182
+ end
183
+
184
+ it "should encode reply to" do
185
+ mail_message.reply_to = ['a@a.com', 'b@b.com']
186
+ mail_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!"}]
187
+ end
188
+
189
+ it "should encode tag" do
190
+ mail_message.tag = "invite"
191
+ mail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "Tag":"invite", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
192
+ end
193
+
194
+ it "should encode multiple recepients (TO)" do
195
+ mail_message.to = ['a@a.com', 'b@b.com']
196
+ mail_message.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"a@a.com, b@b.com", "TextBody":"Hello Sheldon!"}]
197
+ end
198
+
199
+ it "should encode multiple recepients (CC)" do
200
+ mail_message.cc = ['a@a.com', 'b@b.com']
201
+ 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!"}]
202
+ end
203
+
204
+ it "should encode multiple recepients (BCC)" do
205
+ mail_message.bcc = ['a@a.com', 'b@b.com']
206
+ 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!"}]
207
+ end
118
208
  end
119
-
120
- it "should encode multiple recepients (BCC)" do
121
- message.bcc = ['a@a.com', 'b@b.com']
122
- 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!"}]
209
+
210
+ context "mail delivery method" do
211
+ it "should be able to set delivery_method" do
212
+ mail_message.delivery_method Mail::Postmark
213
+ puts mail_message.delivery_method
214
+ end
215
+
216
+ it "should wrap Postmark.send_through_postmark" do
217
+ message = mail_message
218
+ Postmark.should_receive(:send_through_postmark).with(message)
219
+ mail_message.delivery_method Mail::Postmark
220
+ mail_message.deliver
221
+ end
222
+
223
+ it "should allow setting of api_key" do
224
+ mail_message.delivery_method Mail::Postmark, {:api_key => 'api-key'}
225
+ mail_message.delivery_method.settings[:api_key].should == 'api-key'
226
+ end
123
227
  end
124
228
 
125
229
  context "JSON library support" do
@@ -1,5 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'mail'
4
+ require 'tmail'
3
5
  require 'postmark'
4
6
  require 'rubygems'
5
7
  require 'active_support'
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 7
8
- - 1
9
- version: 0.7.1
7
+ - 8
8
+ - 0
9
+ version: 0.8.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Petyo Ivanov
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-23 00:00:00 +03:00
17
+ date: 2010-09-16 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -63,9 +63,12 @@ extra_rdoc_files:
63
63
  - LICENSE
64
64
  - README.rdoc
65
65
  files:
66
+ - .bundle/config
66
67
  - .document
67
68
  - .gitignore
68
69
  - .rake_tasks
70
+ - Gemfile
71
+ - Gemfile.lock
69
72
  - LICENSE
70
73
  - README.rdoc
71
74
  - Rakefile
@@ -73,10 +76,13 @@ files:
73
76
  - features/postmark.feature
74
77
  - features/step_definitions/postmark_steps.rb
75
78
  - features/support/env.rb
79
+ - init.rb
80
+ - lib/mail/postmark.rb
76
81
  - lib/postmark.rb
77
82
  - lib/postmark/bounce.rb
78
83
  - lib/postmark/http_client.rb
79
84
  - lib/postmark/json.rb
85
+ - lib/postmark/mail_message_extension.rb
80
86
  - lib/postmark/response_parsers/active_support.rb
81
87
  - lib/postmark/response_parsers/json.rb
82
88
  - lib/postmark/response_parsers/yajl.rb