capistrano-mailgun 1.3.0 → 2.0.0pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -3
- data/README.md +8 -78
- data/capistrano-mailgun.gemspec +5 -1
- data/lib/capistrano-mailgun.rb +15 -97
- data/lib/capistrano-mailgun/version.rb +1 -1
- data/spec/capistrano-mailgun_spec.rb +14 -97
- data/spec/integration_spec.rb +5 -9
- data/spec/spec_helper.rb +1 -0
- metadata +56 -8
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,13 +6,15 @@ Mailgun.org is an excellent, API-driven email provider. So, bust out your nine,
|
|
6
6
|
easily from inside your Capistrano recipes.
|
7
7
|
|
8
8
|
`Capistrano::Mailgun` provides a simple interface for notifying of deploys, exposing your Capistrano
|
9
|
-
variables to your ERB template built on top of a more robust public interface to the Mailgun API.
|
9
|
+
variables to your ERB template built on top of a more robust public interface to the Mailgun API. It's built on
|
10
|
+
top of [Capnotify](https://github.com/spikegrobstein/capnotify), so it's extensible via Capnotify plugins and
|
11
|
+
accepts Capnotify configuration options.
|
10
12
|
|
11
13
|
## Installation
|
12
14
|
|
13
15
|
Add this line to your application's Gemfile:
|
14
16
|
|
15
|
-
gem 'capistrano-mailgun'
|
17
|
+
gem 'capistrano-mailgun', '~> 2.0'
|
16
18
|
|
17
19
|
And then execute:
|
18
20
|
|
@@ -151,25 +153,6 @@ An array of email addresses who should be BCC'd when `mailgun.notify_of_deploy`
|
|
151
153
|
follow the same rules as the `mailgun_recipients` variable with respect to the handling of unqualified
|
152
154
|
eail addresses.
|
153
155
|
|
154
|
-
### mailgun_text_template (required for notify_of_deploy)
|
155
|
-
|
156
|
-
This is the path to the ERB template that `mailgun.notify_of_deploy` will use to create the text body of
|
157
|
-
your email. This is only required if you do not use the `mailgun_html_template` variable. You can
|
158
|
-
specify both text and html templates and the emails will contain the proper bodies where the client
|
159
|
-
supports it.
|
160
|
-
|
161
|
-
The default setting for this is `:deploy_text` which is a built-in template. See "Built-in Templates"
|
162
|
-
below for more information.
|
163
|
-
|
164
|
-
### mailgun_html_template (required for notify_of_deploy)
|
165
|
-
|
166
|
-
This is the path to the ERB template that will be used to generate the HTML body of the email. It is only
|
167
|
-
required if you do not specify the `mailgun_text_template` variable. You can specify both text and html
|
168
|
-
templates and emails will contain the proper bodies where the client supports it.
|
169
|
-
|
170
|
-
The default setting for this is `:deploy_html` which is a built-in template. See "Built-in Templates"
|
171
|
-
below for more information.
|
172
|
-
|
173
156
|
### mailgun_recipient_domain
|
174
157
|
|
175
158
|
The domain that will be automatically appended to incomplete email addresses in the `mailgun_recipients`.
|
@@ -217,28 +200,6 @@ or with the built-in `mailgun_notify` task.
|
|
217
200
|
|
218
201
|
See above `Disabling Emails` section for examples.
|
219
202
|
|
220
|
-
### mailgun_include_servers
|
221
|
-
|
222
|
-
Tnis variable is set to `false` by default. Setting to true will add the list of servers that are included in
|
223
|
-
the `deploy:update_code` task, which is any server that got code deployed to it.
|
224
|
-
|
225
|
-
This is useful for when you deploy to only a subset of servers using Capistrano's `HOSTS` or `ROLES` environment
|
226
|
-
variables in your deploy.
|
227
|
-
|
228
|
-
To enable the inclusion of the server list, you can add the following to your deployment configuration:
|
229
|
-
|
230
|
-
set :mailgun_include_servers, true
|
231
|
-
|
232
|
-
### github_url
|
233
|
-
|
234
|
-
If your project is hosted on Github and you'd like to have links to the Github repository in the deployment
|
235
|
-
notifications, set this. It should be in the following format:
|
236
|
-
|
237
|
-
https://github.com/USERNAME/PROJECT
|
238
|
-
|
239
|
-
This is used for linking to commits from the log and linking to the Github page for the exact revision that
|
240
|
-
was deployed.
|
241
|
-
|
242
203
|
## Capistrano Tasks
|
243
204
|
|
244
205
|
### mailgun_notify
|
@@ -283,11 +244,6 @@ documentation:
|
|
283
244
|
|
284
245
|
http://documentation.mailgun.net/api-sending.html
|
285
246
|
|
286
|
-
This function also takes the following additional options:
|
287
|
-
|
288
|
-
* `:text_template` -- a path to an ERB template for the text body of the email.
|
289
|
-
* `:html_template` -- a path to an ERB template for the HTML body of the email.
|
290
|
-
|
291
247
|
The templates will have access to all of your Capistrano variables and anything else that Capistrano can see
|
292
248
|
such as methods and Capistrano plugins (including `Capistrano::Mailgun`).
|
293
249
|
|
@@ -296,35 +252,6 @@ will be passed directly to the Mailgun API.
|
|
296
252
|
|
297
253
|
No validation is done from this function, so errors from Mailgun will percolate up to you.
|
298
254
|
|
299
|
-
### deployer_username
|
300
|
-
|
301
|
-
This is a default capistrano variable that is defined in the gem. It will use the `git config user.name` if `scm` is
|
302
|
-
configured as `:git` or use `whoami` if not. This is handy if you want to notify people of which user
|
303
|
-
actually did the deployment.
|
304
|
-
|
305
|
-
## Built-in Templates
|
306
|
-
|
307
|
-
`Capistrano::Mailgun` comes with built-in templates for use with `mailgun.notify_of_deploy`. There are both HTML and Text
|
308
|
-
templates which include information such as the sha1 and ref that has been deployed as well as logs of the last
|
309
|
-
commits. Use of the Capistrano variable `github_url` will enable links back to the repository and direct links
|
310
|
-
to the commits in the log.
|
311
|
-
|
312
|
-
These files live inside the gem in the `lib/templates` directory, so feel free to pull them out, copy into
|
313
|
-
your project and customize.
|
314
|
-
|
315
|
-
By default, `mailgun.notify_of_deploy` sets `mailgun_text_template` to `:default_text` and `mailgun_html_template`
|
316
|
-
to `:default_html`, which signals it to use these built-in templates. Overriding those variables with absolute
|
317
|
-
paths to your own templates will signal mailgun to use those. Setting either variable to `nil` will prevent
|
318
|
-
`mailgun.notify_of_deploy` from using anything for either the text or HTML portion of the email.
|
319
|
-
|
320
|
-
## Limitations
|
321
|
-
|
322
|
-
* Only supports ERB for templates. This should be changed in a future release.
|
323
|
-
* Currently requires that ERB templates are on the filesystem. Future releases may allow for inline templates.
|
324
|
-
* Support for VCSs other than `:git` is lacking. `Capistrano::Mailgun` has been built with git and Github in mind.
|
325
|
-
If anyone has interest in adding support for other another version control system, that would be great.
|
326
|
-
Using this with a VCS other than Git may yeild unpredictable results.
|
327
|
-
|
328
255
|
## Contributing
|
329
256
|
|
330
257
|
1. Fork it
|
@@ -335,10 +262,13 @@ paths to your own templates will signal mailgun to use those. Setting either var
|
|
335
262
|
|
336
263
|
## Acknowledgements
|
337
264
|
|
265
|
+
`Capistrano::Mailgun` is a [Capnotify](https://github.com/spikegrobstein/capnotify) extension. See Capnotify for additional
|
266
|
+
configuration options.
|
267
|
+
|
338
268
|
`Capistrano::Mailgun` is written by Spike Grobstein and is used in production at [Ticket Evolution](http://www.ticketevolution.com)
|
339
269
|
|
340
270
|
`Capistrano::Mailgun` leverages the awesome email sending API of [Mailgun.org](http://mailgun.org). You should definitely check it out.
|
341
271
|
|
342
272
|
## License
|
343
273
|
|
344
|
-
`Capistrano::Mailgun` is ©2012 Spike Grobstein and licensed under the MIT License. See `LICENSE` file.
|
274
|
+
`Capistrano::Mailgun` is ©2012-2013 Spike Grobstein and licensed under the MIT License. See `LICENSE` file.
|
data/capistrano-mailgun.gemspec
CHANGED
@@ -16,6 +16,10 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = Capistrano::Mailgun::VERSION
|
18
18
|
|
19
|
-
gem.add_dependency "
|
19
|
+
gem.add_dependency "capnotify", '~> 0.2.0'
|
20
20
|
gem.add_dependency "rest-client"
|
21
|
+
|
22
|
+
gem.add_development_dependency 'rspec'
|
23
|
+
gem.add_development_dependency 'pry'
|
24
|
+
gem.add_development_dependency 'awesome_print'
|
21
25
|
end
|
data/lib/capistrano-mailgun.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require "capistrano-mailgun/version"
|
2
2
|
require 'restclient'
|
3
|
-
require 'erb'
|
4
|
-
|
5
3
|
|
6
4
|
module Capistrano
|
7
5
|
module Mailgun
|
@@ -11,6 +9,7 @@ module Capistrano
|
|
11
9
|
# the library in a Capistrano recipe.
|
12
10
|
def self.load_into(config)
|
13
11
|
config.load do
|
12
|
+
require 'capnotify'
|
14
13
|
|
15
14
|
Capistrano.plugin :mailgun, Capistrano::Mailgun
|
16
15
|
|
@@ -20,6 +19,7 @@ module Capistrano
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
22
|
+
# TODO: This should use capnotify's subject
|
23
23
|
_cset(:mailgun_subject) do
|
24
24
|
[ "[Deployment]", fetch(:stage, '').to_s.capitalize, fetch(:application, '').capitalize, 'deploy completed'].join(' ').gsub(/\s+/, ' ')
|
25
25
|
end
|
@@ -30,30 +30,6 @@ module Capistrano
|
|
30
30
|
_cset(:mailgun_recipients) { abort "Please specify mailgun_recipients" }
|
31
31
|
_cset(:mailgun_recipient_domain) { abort "Please set mailgun_recipient_domain accordingly" }
|
32
32
|
|
33
|
-
# some internal variables that mailgun will use as the app runs
|
34
|
-
_cset(:mailgun_deploy_servers) { find_servers_for_task( find_task('deploy:update_code') ) }
|
35
|
-
|
36
|
-
# set these to nil to not use, or set to path to your custom template
|
37
|
-
_cset :mailgun_text_template, :deploy_text
|
38
|
-
_cset :mailgun_html_template, :deploy_html
|
39
|
-
|
40
|
-
_cset :mailgun_include_servers, false
|
41
|
-
|
42
|
-
_cset(:deployer_username) do
|
43
|
-
if fetch(:scm, '').to_sym == :git
|
44
|
-
`git config user.name`.chomp
|
45
|
-
else
|
46
|
-
`whoami`.chomp
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# before update_code, fetch the current revision
|
51
|
-
# this is needed to ensure that no matter when capistrano-mailgun fetches the commit logs that it
|
52
|
-
# has the correct starting point.
|
53
|
-
before 'deploy:update_code' do
|
54
|
-
set :mailgun_previous_revision, fetch(:current_revision, nil) # the revision that's currently deployed at this moment
|
55
|
-
end
|
56
|
-
|
57
33
|
# default mailgun email tasks
|
58
34
|
desc <<-DESC
|
59
35
|
Send a mailgun deployment notification.
|
@@ -66,6 +42,13 @@ module Capistrano
|
|
66
42
|
mailgun.notify_of_deploy
|
67
43
|
end
|
68
44
|
|
45
|
+
on(:load) do
|
46
|
+
capnotify.components.unshift(Capnotify::Component.new(:mailgun_message) do |c|
|
47
|
+
c.header = 'Mailgun Message'
|
48
|
+
|
49
|
+
c.content = fetch(:mailgun_message, nil)
|
50
|
+
end)
|
51
|
+
end
|
69
52
|
|
70
53
|
|
71
54
|
end # config.load
|
@@ -73,10 +56,9 @@ module Capistrano
|
|
73
56
|
|
74
57
|
# Simple wrapper for sending an email with a given template
|
75
58
|
# Supports all options that the Mailgun API supports. In addition, it also accepts:
|
76
|
-
# * +:text_template+ -- the path to the template for the text body. It will be processed and interpolated and set the +text+ field when doing the API call.
|
77
|
-
# * +:html_template+ -- the path to the template for the html body. It will be processed and interpolated and set the +html+ field when doing the API call.
|
78
59
|
#
|
79
60
|
# If +mailgun_off+ is set, this function will do absolutely nothing.
|
61
|
+
# TODO: Maybe we should call this +mailgun_disarm+?
|
80
62
|
def send_email(options)
|
81
63
|
return if exists?(:mailgun_off)
|
82
64
|
options = process_send_email_options(options)
|
@@ -89,9 +71,6 @@ module Capistrano
|
|
89
71
|
# * +mailgun_recipients+
|
90
72
|
# * +mailgun_from+
|
91
73
|
# * +mailgun_subject+
|
92
|
-
# Requires one or both of the following:
|
93
|
-
# * +mailgun_text_template+
|
94
|
-
# * +mailgun_html_template+
|
95
74
|
#
|
96
75
|
# See README for explanations of the above variables.
|
97
76
|
def notify_of_deploy
|
@@ -104,13 +83,6 @@ module Capistrano
|
|
104
83
|
options[:cc] = fetch(:mailgun_cc) if fetch(:mailgun_cc, nil)
|
105
84
|
options[:bcc] = fetch(:mailgun_bcc) if fetch(:mailgun_bcc, nil)
|
106
85
|
|
107
|
-
if fetch(:mailgun_text_template, nil).nil? && fetch(:mailgun_html_template, nil).nil?
|
108
|
-
abort "You must specify one (or both) of mailgun_text_template and mailgun_html_template to use notify_of_deploy"
|
109
|
-
end
|
110
|
-
|
111
|
-
options[:text_template] = fetch(:mailgun_text_template, nil)
|
112
|
-
options[:html_template] = fetch(:mailgun_html_template, nil)
|
113
|
-
|
114
86
|
send_email options
|
115
87
|
end
|
116
88
|
|
@@ -118,7 +90,7 @@ module Capistrano
|
|
118
90
|
# Optionally, it will take a +default_domain+ which will automatically be appended to any unqualified recipients (eg: 'spike' => 'spike@example.com')
|
119
91
|
def build_recipients(recipients, default_domain=nil)
|
120
92
|
[*recipients].map do |r|
|
121
|
-
if r.match
|
93
|
+
if r.match(/.+?@.+?$/) # the email contains an @ so it's fully-qualified.
|
122
94
|
r
|
123
95
|
else
|
124
96
|
"#{ r }@#{ default_domain || fetch(:mailgun_recipient_domain) }"
|
@@ -126,71 +98,17 @@ module Capistrano
|
|
126
98
|
end.uniq.sort.join(',')
|
127
99
|
end
|
128
100
|
|
129
|
-
# git log between +first_ref+ to +last_ref+
|
130
|
-
# memoizes the output so this function can be called multiple times without re-running
|
131
|
-
# FIXME: memoization does not account for arguments
|
132
|
-
#
|
133
|
-
# returns an array of 2-element arrays in the form of
|
134
|
-
# [ ref, log_text ]
|
135
|
-
def log_output(first_ref, last_ref)
|
136
|
-
return @log_output unless @log_output.nil?
|
137
|
-
|
138
|
-
begin
|
139
|
-
raise "Ref missing" if first_ref.nil? || last_ref.nil? # jump to resque block.
|
140
|
-
|
141
|
-
log_output = run_locally("git log --oneline #{ first_ref }..#{ last_ref }")
|
142
|
-
|
143
|
-
@log_output = log_output = log_output.split("\n").map do |line|
|
144
|
-
fields = line.split("\s", 2)
|
145
|
-
[ fields[0], fields[1] ]
|
146
|
-
end
|
147
|
-
rescue
|
148
|
-
[ [ 'n/a', 'Log output not available.' ] ]
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
101
|
private
|
153
102
|
|
154
|
-
def default_deploy_text_template_path
|
155
|
-
default_template_path 'default.txt.erb'
|
156
|
-
end
|
157
|
-
|
158
|
-
def default_deploy_html_template_path
|
159
|
-
default_template_path 'default.html.erb'
|
160
|
-
end
|
161
|
-
|
162
|
-
def default_template_path(name)
|
163
|
-
File.join( File.dirname(__FILE__), 'templates', name)
|
164
|
-
end
|
165
|
-
|
166
|
-
def find_template(t)
|
167
|
-
case t
|
168
|
-
when :deploy_text then default_deploy_text_template_path
|
169
|
-
when :deploy_html then default_deploy_html_template_path
|
170
|
-
else
|
171
|
-
abort "Unknown template symbol: #{ t }" if t.is_a?(Symbol)
|
172
|
-
abort "Template not found: #{ t }" unless File.exists?(t)
|
173
|
-
t
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
103
|
# apply templates and all that jazz
|
178
|
-
|
179
|
-
|
180
|
-
html_template = options.delete(:html_template)
|
181
|
-
|
104
|
+
# TODO: technically, options should not be a blank hash. technically there should be at least a :to field
|
105
|
+
def process_send_email_options(options={})
|
182
106
|
options[:to] = build_recipients(options[:to]) unless options[:to].nil?
|
183
107
|
options[:cc] = build_recipients(options[:cc]) unless options[:cc].nil?
|
184
108
|
options[:bcc] = build_recipients(options[:bcc]) unless options[:bcc].nil?
|
185
109
|
|
186
|
-
options[:text] =
|
187
|
-
options[:html] =
|
188
|
-
|
189
|
-
# clean up the text template a little
|
190
|
-
if options[:text]
|
191
|
-
options[:text].gsub! /^ +/, ''
|
192
|
-
options[:text].gsub! /\n{3,}/, "\n\n"
|
193
|
-
end
|
110
|
+
options[:text] = fetch(:capnotify_deployment_notification_text) if fetch(:capnotify_deployment_notification_text_template_path, nil)
|
111
|
+
options[:html] = fetch(:capnotify_deployment_notification_html) if fetch(:capnotify_deployment_notification_html_template_path, nil)
|
194
112
|
|
195
113
|
options
|
196
114
|
end
|
@@ -9,7 +9,13 @@ describe Capistrano::Mailgun do
|
|
9
9
|
before do
|
10
10
|
Capistrano::Mailgun.load_into(config)
|
11
11
|
|
12
|
+
config.load do
|
13
|
+
set :application, 'testapp'
|
14
|
+
end
|
15
|
+
|
12
16
|
RestClient.stub(:post)
|
17
|
+
|
18
|
+
config.trigger(:load)
|
13
19
|
end
|
14
20
|
|
15
21
|
let(:mailgun) { config.mailgun }
|
@@ -66,53 +72,6 @@ describe Capistrano::Mailgun do
|
|
66
72
|
|
67
73
|
end
|
68
74
|
|
69
|
-
context "#find_template" do
|
70
|
-
|
71
|
-
def find_template(t)
|
72
|
-
mailgun.send(:find_template, t)
|
73
|
-
end
|
74
|
-
|
75
|
-
context "when dealing with a path" do
|
76
|
-
|
77
|
-
it "should return the path if the file exists" do
|
78
|
-
File.stub!(:exists? => true)
|
79
|
-
|
80
|
-
find_template('asdf').should == 'asdf'
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should not raise an error if the file exists" do
|
84
|
-
File.stub!(:exists? => true)
|
85
|
-
|
86
|
-
lambda { find_template('adsf') }.should_not raise_error
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should raise an error if the path doesn't exist" do
|
90
|
-
File.stub!(:exists? => false)
|
91
|
-
|
92
|
-
lambda { find_template('asdf') }.should raise_error
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
context "when dealing with a symbol" do
|
98
|
-
|
99
|
-
it "should return the default_deploy_text_template_path for :deploy_text" do
|
100
|
-
mailgun.should_receive(:default_deploy_text_template_path)
|
101
|
-
|
102
|
-
find_template(:deploy_text)
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should return the default_deploy_html_template_path for :deploy_html" do
|
106
|
-
mailgun.should_receive(:default_deploy_html_template_path)
|
107
|
-
|
108
|
-
find_template(:deploy_html)
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
|
116
75
|
context "when ensuring cap variables are defined" do
|
117
76
|
|
118
77
|
def should_require(var)
|
@@ -288,12 +247,14 @@ describe Capistrano::Mailgun do
|
|
288
247
|
context "#mailgun_deploy_servers" do
|
289
248
|
|
290
249
|
it "should find servers that are included in 'deploy'" do
|
250
|
+
pending
|
291
251
|
server_hostnames.count.should == 2
|
292
252
|
server_hostnames.should include('server-a')
|
293
253
|
server_hostnames.should include('server-b')
|
294
254
|
end
|
295
255
|
|
296
256
|
it "should not find servers that are not included in 'deploy'" do
|
257
|
+
pending
|
297
258
|
server_hostnames.should_not include('server-c')
|
298
259
|
end
|
299
260
|
end
|
@@ -313,10 +274,12 @@ describe Capistrano::Mailgun do
|
|
313
274
|
end
|
314
275
|
|
315
276
|
it "should include the servers in the text template" do
|
277
|
+
pending
|
316
278
|
result[:text].should match('server-a')
|
317
279
|
end
|
318
280
|
|
319
281
|
it "should include the servers in the html template" do
|
282
|
+
pending
|
320
283
|
result[:html].should match('server-a')
|
321
284
|
result[:html].should match('mailgun_servers')
|
322
285
|
end
|
@@ -329,10 +292,12 @@ describe Capistrano::Mailgun do
|
|
329
292
|
end
|
330
293
|
|
331
294
|
it "should not include the servers in the text template" do
|
295
|
+
pending
|
332
296
|
result[:text].should_not match('server-a')
|
333
297
|
end
|
334
298
|
|
335
299
|
it "should not include the servers in the html template" do
|
300
|
+
pending
|
336
301
|
result[:html].should_not match('server-a')
|
337
302
|
result[:html].should_not match('mailgun_servers')
|
338
303
|
end
|
@@ -349,56 +314,8 @@ describe Capistrano::Mailgun do
|
|
349
314
|
config.load { set :mailgun_domain, 'example.com' }
|
350
315
|
end
|
351
316
|
|
352
|
-
it "should
|
353
|
-
|
354
|
-
|
355
|
-
result[:text].should include(test_mailgun_domain)
|
356
|
-
result[:text].should_not include('<%=')
|
357
|
-
end
|
358
|
-
|
359
|
-
it "should not change text if no text_template is passed" do
|
360
|
-
ERB.should_not_receive(:new)
|
361
|
-
File.should_not_receive(:open)
|
362
|
-
|
363
|
-
mailgun.send(:process_send_email_options, :text => 'normal text')[:text].should == 'normal text'
|
364
|
-
end
|
365
|
-
|
366
|
-
it "should set html to the rendered html template if html_template is passed" do
|
367
|
-
result = mailgun.send(:process_send_email_options, :html_template => fixture_path('html_body.erb'))
|
368
|
-
|
369
|
-
result[:html].should include(test_mailgun_domain)
|
370
|
-
result[:html].should_not include('<%=')
|
371
|
-
end
|
372
|
-
|
373
|
-
it "should not change html if no html_template is passed" do
|
374
|
-
ERB.should_not_receive(:new)
|
375
|
-
File.should_not_receive(:open)
|
376
|
-
|
377
|
-
mailgun.send(:process_send_email_options, :html => 'normal html')[:html].should == 'normal html'
|
378
|
-
end
|
379
|
-
|
380
|
-
end
|
381
|
-
|
382
|
-
context "#log_output" do
|
383
|
-
|
384
|
-
context "when it raises an error" do
|
385
|
-
|
386
|
-
before do
|
387
|
-
mailgun.should_receive(:run_locally).and_raise(Capistrano::LocalArgumentError.new)
|
388
|
-
end
|
389
|
-
|
390
|
-
it "should only return a 1-element array if an error is returned from git-log" do
|
391
|
-
result = mailgun.log_output('a', 'b')
|
392
|
-
|
393
|
-
result.class.should == Array
|
394
|
-
result.length.should == 1
|
395
|
-
end
|
396
|
-
|
397
|
-
it "should capture the error and not raise if git-log fails" do
|
398
|
-
lambda { mailgun.log_output('a', 'b') }.should_not raise_error
|
399
|
-
end
|
400
|
-
|
401
|
-
end
|
317
|
+
it "should not return :text field if capnotify_deployment_notification_text_template is unset"
|
318
|
+
it "should not return :html field if capnotify_deployment_notification_html_template is unset"
|
402
319
|
|
403
320
|
end
|
404
321
|
|
data/spec/integration_spec.rb
CHANGED
@@ -10,6 +10,8 @@ describe "Integration testing for Capistrano::Mailgun" do
|
|
10
10
|
Capistrano::Mailgun.load_into(config)
|
11
11
|
|
12
12
|
RestClient.stub(:post)
|
13
|
+
|
14
|
+
config.trigger(:load)
|
13
15
|
end
|
14
16
|
|
15
17
|
let(:mailgun) { config.mailgun }
|
@@ -47,9 +49,7 @@ describe "Integration testing for Capistrano::Mailgun" do
|
|
47
49
|
|
48
50
|
|
49
51
|
it "should allow user to unset text template" do
|
50
|
-
config.
|
51
|
-
set :mailgun_text_template, nil
|
52
|
-
end
|
52
|
+
config.set :capnotify_deployment_notification_text_template_path, nil
|
53
53
|
|
54
54
|
RestClient.should_receive(:post) do |url, opts|
|
55
55
|
opts.has_key?(:text).should be_false
|
@@ -58,9 +58,7 @@ describe "Integration testing for Capistrano::Mailgun" do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should allow user to unset html template" do
|
61
|
-
config.
|
62
|
-
set :mailgun_html_template, nil
|
63
|
-
end
|
61
|
+
config.set :capnotify_deployment_notification_html_template_path, nil
|
64
62
|
|
65
63
|
RestClient.should_receive(:post) do |url, opts|
|
66
64
|
opts.has_key?(:text).should be_true
|
@@ -141,9 +139,7 @@ describe "Integration testing for Capistrano::Mailgun" do
|
|
141
139
|
|
142
140
|
context "when using mailgun_message" do
|
143
141
|
it "should include a mailgun_message if set" do
|
144
|
-
config.
|
145
|
-
set :mailgun_message, '_custom_message_'
|
146
|
-
end
|
142
|
+
config.set :mailgun_message, '_custom_message_'
|
147
143
|
|
148
144
|
RestClient.should_receive(:post) do |url, opts|
|
149
145
|
opts[:text].should include('_custom_message_')
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-mailgun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0pre
|
5
|
+
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Spike Grobstein
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: capnotify
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.2.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rest-client
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
@@ -28,14 +44,46 @@ dependencies:
|
|
28
44
|
- !ruby/object:Gem::Version
|
29
45
|
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
47
|
+
name: rspec
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
33
49
|
none: false
|
34
50
|
requirements:
|
35
51
|
- - ! '>='
|
36
52
|
- !ruby/object:Gem::Version
|
37
53
|
version: '0'
|
38
|
-
type: :
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: awesome_print
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
39
87
|
prerelease: false
|
40
88
|
version_requirements: !ruby/object:Gem::Requirement
|
41
89
|
none: false
|
@@ -84,9 +132,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
133
|
none: false
|
86
134
|
requirements:
|
87
|
-
- - ! '
|
135
|
+
- - ! '>'
|
88
136
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
137
|
+
version: 1.3.1
|
90
138
|
requirements: []
|
91
139
|
rubyforge_project:
|
92
140
|
rubygems_version: 1.8.24
|