bugsnag-capistrano 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e6326e309ec379b3386a4dfa4d7b8601dbfe9e12
4
+ data.tar.gz: 7514f4a2c7af3e3f5302395c143a1295ca94366d
5
+ SHA512:
6
+ metadata.gz: 4c82887b35306b8fdb478736ecee705b29786318a7a228d5aba24526aac4cf7dd2475a201565625d49e4827df12ce65a95839a52d292245d90e4960ea45b460c
7
+ data.tar.gz: b8aa67705bfa30e71170444a8dfbed54db1203b06eaf4c18f57be03ea37cc2989a2a57da49d79dfd57d37b9be0fd47567b1f3d2e3b1457ebfe37761ef1d75f01
@@ -0,0 +1,52 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ # bundler
12
+ .bundle
13
+ Gemfile.lock
14
+
15
+ # jeweler generated
16
+ pkg
17
+ *.gem
18
+
19
+ vendor
20
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
21
+ #
22
+ # * Create a file at ~/.gitignore
23
+ # * Include files you want ignored
24
+ # * Run: git config --global core.excludesfile ~/.gitignore
25
+ #
26
+ # After doing this, these files will be ignored in all your git projects,
27
+ # saving you from having to 'pollute' every project you touch with them
28
+ #
29
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
30
+ #
31
+ # For MacOS:
32
+ #
33
+ #.DS_Store
34
+
35
+ # For TextMate
36
+ #*.tmproj
37
+ #tmtags
38
+
39
+ # For emacs:
40
+ #*~
41
+ #\#*
42
+ #.\#*
43
+
44
+ # For vim:
45
+ #*.swp
46
+
47
+ # For redcar:
48
+ #.redcar
49
+
50
+ # For rubinius:
51
+ #*.rbc
52
+ bin
@@ -0,0 +1,36 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.3.0
6
+ - 2.2.4
7
+ - 2.1.8
8
+ - 2.0.0
9
+ - 1.9.3
10
+ - jruby-19mode
11
+
12
+ before_install:
13
+ - gem update --system 2.1.11
14
+ - gem install bundler -v 1.12
15
+ - bundle --version
16
+ - gem --version
17
+
18
+ before_script:
19
+ - bundle list | grep 'bugsnag\|capistrano'
20
+ - bundle exec cap --version
21
+ script: bundle exec rake spec
22
+
23
+ jobs:
24
+ include:
25
+ - stage: test
26
+ env: CAP_2_TEST=true
27
+ install: bundle install --with test bugsnag
28
+ - stage: test
29
+ env: CAP_2_TEST=true
30
+ install: bundle install --with test --without bugsnag
31
+ - stage: test
32
+ env: CAP_2_TEST=false
33
+ install: bundle install --with test bugsnag
34
+ - stage: test
35
+ env: CAP_2_TEST=false
36
+ install: bundle install --with test --without bugsnag
@@ -0,0 +1,3 @@
1
+ ## 1.0.0 (09-11-2017)
2
+
3
+ Initial release of bugsnag-capistrano
@@ -0,0 +1,70 @@
1
+ # Contribution Guide
2
+
3
+ ## Development Dependencies
4
+
5
+ Install dependencies for testing using bundler:
6
+ ```shell
7
+ bundle install --with test
8
+ ```
9
+
10
+ ## Running the Tests
11
+
12
+ Run the tests using:
13
+
14
+ ```shell
15
+ bundle exec rake
16
+ ```
17
+
18
+ This tests Capistrano 3 functionality, without using Bugsnag to make the deployment call. To test Capistrano 2 functionality set the environment variable `CAP_2_TEST` to `true` and re-install and run the tests.
19
+
20
+ In order to test using the main Bugsnag notifier to send the deployment notification, include the group `bugsnag` in the install command:
21
+ ```shell
22
+ bundle install --with test bugsnag
23
+ ```
24
+
25
+ ## Building/Running Example Apps
26
+
27
+ Instructions on running the example apps can be found within the `README.md` files within the respective folders.
28
+
29
+ ## Submitting a Change
30
+
31
+ * [Fork](https://help.github.com/articles/fork-a-repo) the
32
+ [notifier on github](https://github.com/bugsnag/bugsnag-bugsnag-capistrano)
33
+ * Commit and push until you are happy with your contribution
34
+ * Run the tests with and ensure all pass
35
+ * [Submit a pull request](https://help.github.com/articles/using-pull-requests)
36
+ * Thank you!
37
+
38
+ ----
39
+
40
+ ## Release Guidelines
41
+
42
+ If you're a member of the core team, follow these instructions for releasing
43
+ bugsnag-capistrano.
44
+
45
+ ### Every time
46
+
47
+ * Compile new features, enhancements, and fixes into the CHANGELOG.
48
+ * Update the project version using [semantic versioning](http://semver.org).
49
+ Specifically:
50
+
51
+ > Given a version number MAJOR.MINOR.PATCH, increment the:
52
+ >
53
+ > 1. MAJOR version when you make incompatible API changes,
54
+ > 2. MINOR version when you add functionality in a backwards-compatible
55
+ > manner
56
+ > 3. PATCH version when you make backwards-compatible bug fixes.
57
+ >
58
+ > Additional labels for pre-release and build metadata are available as
59
+ > extensions to the MAJOR.MINOR.PATCH format.
60
+
61
+ * Add a git tag with the new version of the library
62
+ * Commit and push your changes and tag
63
+ * Create a new release on [the Github repository](https://github.com/bugsnag/bugsnag-capistrano)
64
+ * Release to RubyGems
65
+
66
+ ```
67
+ bundle exec rake release
68
+ ```
69
+
70
+ * Update docs.bugsnag.com with any new content
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :test, optional: true do
4
+ gem 'rake', '~> 10.1.1'
5
+ gem 'rspec'
6
+ gem 'rdoc'
7
+ gem 'pry'
8
+ gem 'addressable', '~>2.3.8'
9
+ gem 'webmock', RUBY_VERSION <= '1.9.3' ? '2.3.2': '>2.3.2'
10
+ gem 'capistrano', ENV['CAP_2_TEST'] == 'true' ? '~> 2.15': '~> 3.9'
11
+ end
12
+
13
+ group :bugsnag, optional: true do
14
+ gem 'bugsnag', '~> 6.0'
15
+ end
16
+
17
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 Bugsnag, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ # Bugsnag deploy tracking with Capistrano
2
+ [![Build status](https://travis-ci.org/bugsnag/bugsnag-bugsnag-capistrano.svg?branch=master)](https://travis-ci.org/bugsnag/bugsnag-bugsnag-capistrano)
3
+
4
+
5
+ Bugsnag Capistrano automatically notifies Bugsnag when you deploy your
6
+ application with [Capistrano](https://github.com/capistrano/capistrano),
7
+ allowing to correlate deploys with new errors and increased error rates in
8
+ Bugsnag.
9
+
10
+ [Bugsnag](http://bugsnag.com) captures errors in real-time from your web,
11
+ mobile and desktop applications, helping you to understand and resolve them
12
+ as fast as possible. [Create a free account](http://bugsnag.com) to start
13
+ capturing exceptions from your applications.
14
+
15
+ ## Features
16
+
17
+ * Automatically report unhandled exceptions and crashes
18
+ * Report handled exceptions
19
+ * Log breadcrumbs which are attached to crash reports and add insight to users' actions
20
+ * Attach user information and custom diagnostic data to determine how many people are affected by a crash
21
+
22
+ ## Getting started
23
+
24
+ 1. [Create a Bugsnag account](https://bugsnag.com)
25
+ 1. Complete the instructions in the [ruby integration guide](https://docs.bugsnag.com/platforms/ruby/) for your ruby application type
26
+ 1. Complete the instructions in the integration guide for [deploy tracking](https://docs.bugsnag.com/platforms/ruby/deploy-tracking/)
27
+ 1. Report handled exceptions using [`Bugsnag.notify()`](http://docs.bugsnag.com/platforms/bugsnag-capistrano/reporting-handled-exceptions/)
28
+ 1. Customize your integration using the [configuration options](http://docs.bugsnag.com/platforms/bugsnag-capistrano/configuration-options/)
29
+
30
+ ## Support
31
+
32
+ * Read the [bugsnag-capistrano](http://docs.bugsnag.com/platforms/bugsnag-capistrano/configuration-options) configuration reference
33
+ * Read the instructions in the integration guide for [deploy tracking](https://docs.bugsnag.com/platforms/ruby/deploy-tracking/)
34
+ * [Search open and closed issues](https://github.com/bugsnag/bugsnag-bugsnag-capistrano/issues?utf8=✓&q=is%3Aissue) for similar problems
35
+ * [Report a bug or request a feature](https://github.com/bugsnag/bugsnag-bugsnag-capistrano/issues/new)
36
+
37
+ ## Contributing
38
+
39
+ All contributors are welcome! For information on how to build, test,
40
+ and release `bugsnag-bugsnag-capistrano`, see our
41
+ [contributing guide](https://github.com/bugsnag/bugsnag-bugsnag-capistrano/blob/master/CONTRIBUTING.md).
42
+
43
+
44
+ ## License
45
+
46
+ The Bugsnag Cocoa library is free software released under the MIT License.
47
+ See [LICENSE.txt](https://github.com/bugsnag/bugsnag-bugsnag-capistrano/blob/master/LICENSE.txt)
48
+ for details.
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ require 'bundler/gem_tasks'
6
+ begin
7
+ Bundler.setup(:default)
8
+ rescue Bundler::BundlerError => e
9
+ $stderr.puts e.message
10
+ $stderr.puts "Run `bundle install` to install missing gems"
11
+ exit e.status_code
12
+ end
13
+
14
+ require 'rdoc/task'
15
+ RDoc::Task.new do |rdoc|
16
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
17
+
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = "bugsnag-capistrano #{version}"
20
+ rdoc.rdoc_files.include('README*')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ # RSpec tasks
25
+ require 'rspec/core'
26
+ require "rspec/core/rake_task"
27
+
28
+ tags = '--format documentation --tag always '
29
+
30
+ begin
31
+ require 'bugsnag'
32
+ tags += '--tag with_notifier '
33
+ rescue LoadError
34
+ tags += '--tag without_notifier '
35
+ end
36
+
37
+ RSpec::Core::RakeTask.new(:spec) do |opts|
38
+ opts.rspec_opts = tags
39
+ end
40
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "bugsnag-capistrano"
3
+ s.version = File.read("VERSION").strip
4
+
5
+ s.authors = ["Keegan Lowenstein", "Martin Holman", "Alex Moinet", "Delisa Mason"]
6
+ s.email = "keegan@bugsnag.com"
7
+
8
+ s.summary = "Notify Bugsnag when deploying with Capistrano"
9
+ s.description = "Correlate Capistrano deploys with new errors and increased error rates in Bugsnag"
10
+ s.homepage = "http://github.com/bugsnag/bugsnag-capistrano"
11
+ s.licenses = ["MIT"]
12
+
13
+ s.files = `git ls-files`.split("\n").reject {|file| file.start_with? "examples/"}
14
+ s.extra_rdoc_files = [
15
+ "LICENSE.txt",
16
+ "README.md",
17
+ "CHANGELOG.md"
18
+ ]
19
+ s.require_paths = ["lib"]
20
+ s.required_ruby_version = '>= 1.9.2'
21
+
22
+ end
@@ -0,0 +1 @@
1
+ require 'bugsnag-capistrano/capistrano'
@@ -0,0 +1,7 @@
1
+ require_relative "deploy"
2
+
3
+ if defined?(Capistrano::VERSION) && Gem::Version.new(Capistrano::VERSION).release >= Gem::Version.new('3.0.0')
4
+ load File.expand_path('../tasks/bugsnag.cap', __FILE__)
5
+ else
6
+ require_relative 'capistrano2'
7
+ end
@@ -0,0 +1,32 @@
1
+ module Bugsnag
2
+ module Capistrano
3
+ def self.load_into(configuration)
4
+ configuration.load do
5
+ after "deploy", "bugsnag:deploy"
6
+ after "deploy:migrations", "bugsnag:deploy"
7
+
8
+ namespace :bugsnag do
9
+ desc "Notify Bugsnag that new production code has been deployed"
10
+ task :deploy, :except => { :no_release => true }, :on_error => :continue do
11
+ begin
12
+ Bugsnag::Capistrano::Deploy.notify({
13
+ :api_key => fetch(:bugsnag_api_key, ENV["BUGSNAG_API_KEY"]),
14
+ :release_stage => fetch(:bugsnag_env) || ENV["BUGSNAG_RELEASE_STAGE"] || fetch(:rails_env) || fetch(:stage) || "production",
15
+ :revision => fetch(:current_revision, ENV["BUGSNAG_REVISION"]),
16
+ :repository => fetch(:repo_url, ENV["BUGSNAG_REPOSITORY"]),
17
+ :branch => fetch(:branch, ENV["BUGSNAG_BRANCH"]),
18
+ :app_version => fetch(:app_version, ENV["BUGSNAG_APP_VERSION"]),
19
+ :endpoint => fetch(:bugsnag_endpoint)
20
+ })
21
+ logger.info "Bugsnag deploy notification complete."
22
+ rescue
23
+ logger.important("Bugnsag deploy notification failed, #{$!.inspect}")
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ Bugsnag::Capistrano.load_into(Capistrano::Configuration.instance) if Capistrano::Configuration.instance
@@ -0,0 +1,97 @@
1
+ require "json"
2
+ require "net/http"
3
+
4
+ module Bugsnag
5
+ module Capistrano
6
+ class Deploy
7
+
8
+ HEADERS = {"Content-Type" => "application/json"}
9
+ DEFAULT_DEPLOY_ENDPOINT = "https://notify.bugsnag.com/deploy"
10
+
11
+ def self.notify(opts = {})
12
+ begin
13
+ require 'bugsnag'
14
+ self.notify_using_bugsnag(opts)
15
+ rescue LoadError
16
+ self.notify_without_bugsnag(opts)
17
+ end
18
+ end
19
+
20
+ def self.notify_using_bugsnag(opts = {})
21
+
22
+ configuration = Bugsnag.configuration.dup
23
+
24
+ [:api_key, :app_version, :release_stage, :endpoint, :use_ssl,
25
+ :proxy_host, :proxy_port, :proxy_user, :proxy_password].each do |param|
26
+ unless opts[param].nil?
27
+ configuration.send :"#{param}=", opts[param]
28
+ end
29
+ end
30
+
31
+ if Gem::Version.new(Bugsnag::VERSION).release >= Gem::Version.new('6.0.0')
32
+ endpoint = configuration.endpoint
33
+ else
34
+ endpoint = (configuration.use_ssl ? "https://" : "http://") + configuration.endpoint
35
+ end
36
+
37
+ parameters = {
38
+ "apiKey" => configuration.api_key,
39
+ "releaseStage" => configuration.release_stage,
40
+ "appVersion" => configuration.app_version,
41
+ "revision" => opts[:revision],
42
+ "repository" => opts[:repository],
43
+ "branch" => opts[:branch]
44
+ }.reject {|k,v| v == nil}
45
+
46
+ raise RuntimeError.new("No API key found when notifying of deploy") if !parameters["apiKey"] || parameters["apiKey"].empty?
47
+
48
+
49
+ payload_string = ::JSON.dump(parameters)
50
+ Bugsnag::Delivery::Synchronous.deliver(endpoint, payload_string, configuration)
51
+ end
52
+
53
+ def self.notify_without_bugsnag(opts = {})
54
+ endpoint = (opts[:endpoint].nil? ? DEFAULT_DEPLOY_ENDPOINT : opts[:endpoint])
55
+
56
+ parameters = {
57
+ "apiKey" => opts[:api_key],
58
+ "releaseStage" => opts[:release_stage],
59
+ "appVersion" => opts[:app_version],
60
+ "revision" => opts[:revision],
61
+ "repository" => opts[:repository],
62
+ "branch" => opts[:branch]
63
+ }.reject {|k, v| v == nil}
64
+
65
+ raise RuntimeError.new("No API key found when notifying of deploy") if !parameters["apiKey"] || parameters["apiKey"].empty?
66
+
67
+ payload_string = ::JSON.dump(parameters)
68
+ self.deliver(endpoint, payload_string)
69
+ end
70
+
71
+ def self.deliver(url, body)
72
+ logger = Logger.new(STDOUT)
73
+ logger.level = Logger::INFO
74
+ begin
75
+ request(url, body)
76
+ rescue StandardError => e
77
+ logger.warn("Notification to #{url} failed, #{e.inspect}")
78
+ logger.warn(e.backtrace)
79
+ end
80
+ end
81
+
82
+ def self.request(url, body)
83
+ uri = URI.parse(url)
84
+ http = Net::HTTP.new(uri.host, uri.port)
85
+ http.read_timeout = 15
86
+ http.open_timeout = 15
87
+
88
+ http.use_ssl = uri.scheme == "https"
89
+
90
+ uri.path == "" ? "/" : uri.path
91
+ request = Net::HTTP::Post.new(uri, HEADERS)
92
+ request.body = body
93
+ http.request(request)
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,33 @@
1
+ require "bugsnag"
2
+
3
+ namespace :bugsnag do
4
+
5
+ desc "Notify Bugsnag of a new deploy."
6
+ task :deploy do
7
+ api_key = ENV["BUGSNAG_API_KEY"]
8
+ release_stage = ENV["BUGSNAG_RELEASE_STAGE"]
9
+ app_version = ENV["BUGSNAG_APP_VERSION"]
10
+ revision = ENV["BUGSNAG_REVISION"]
11
+ repository = ENV["BUGSNAG_REPOSITORY"]
12
+ branch = ENV["BUGSNAG_BRANCH"]
13
+
14
+ Rake::Task["load"].invoke unless api_key
15
+
16
+ Bugsnag::Capistrano::Deploy.notify({
17
+ :api_key => api_key,
18
+ :release_stage => release_stage,
19
+ :app_version => app_version,
20
+ :revision => revision,
21
+ :repository => repository,
22
+ :branch => branch
23
+ })
24
+ end
25
+
26
+ end
27
+
28
+ task :load do
29
+ begin
30
+ Rake::Task["environment"].invoke
31
+ rescue
32
+ end
33
+ end
@@ -0,0 +1,46 @@
1
+ namespace :load do
2
+
3
+ task :defaults do
4
+
5
+ set :bugsnag_default_hooks, ->{ true }
6
+
7
+ end
8
+
9
+ end
10
+
11
+ namespace :deploy do
12
+
13
+ before :starting, :bugsnag_hooks do
14
+ invoke 'bugsnag:add_default_hooks' if fetch(:bugsnag_default_hooks)
15
+ end
16
+
17
+ end
18
+
19
+ namespace :bugsnag do
20
+
21
+ task :add_default_hooks do
22
+ after 'deploy:published', 'bugsnag:deploy'
23
+ end
24
+
25
+ desc 'Notify Bugsnag that new production code has been deployed'
26
+ task :deploy do
27
+ run_locally do
28
+ begin
29
+ Bugsnag::Capistrano::Deploy.notify({
30
+ :api_key => fetch(:bugsnag_api_key, ENV["BUGSNAG_API_KEY"]),
31
+ :release_stage => fetch(:bugsnag_env) || ENV["BUGSNAG_RELEASE_STAGE"] || fetch(:rails_env) || fetch(:stage) || "production",
32
+ :revision => fetch(:current_revision, ENV["BUGSNAG_REVISION"]),
33
+ :repository => fetch(:repo_url, ENV["BUGSNAG_REPOSITORY"]),
34
+ :branch => fetch(:branch, ENV["BUGSNAG_BRANCH"]),
35
+ :app_version => fetch(:app_version, ENV["BUGSNAG_APP_VERSION"]),
36
+ :endpoint => fetch(:bugsnag_endpoint)
37
+ })
38
+ info 'Bugsnag deploy notification complete.'
39
+ rescue
40
+ error "Bugsnag deploy notification failed, #{$!.inspect}"
41
+ end
42
+ end
43
+ end
44
+
45
+ end
46
+ # vi:ft=ruby
@@ -0,0 +1,65 @@
1
+ require 'webmock/rspec'
2
+ require 'rspec/expectations'
3
+ require 'rspec/mocks'
4
+
5
+ require 'webrick'
6
+
7
+ describe "bugsnag capistrano", :always do
8
+
9
+ server = nil
10
+ queue = Queue.new
11
+ cap_2 = ENV['CAP_2_TEST'] == 'true'
12
+ fixture_path = cap_2 ? '../examples/capistrano2' : '../examples/capistrano3'
13
+ exec_string = cap_2 ? 'bundle exec cap deploy' : 'bundle exec cap test deploy'
14
+ example_path = File.join(File.dirname(__FILE__), fixture_path)
15
+
16
+ before do
17
+ server = WEBrick::HTTPServer.new :Port => 0, :Logger => WEBrick::Log.new(STDOUT), :AccessLog => []
18
+ server.mount_proc '/deploy' do |req, res|
19
+ queue.push req.body
20
+ res.status = 200
21
+ res.body = "OK\n"
22
+ end
23
+ Thread.new{ server.start }
24
+ end
25
+
26
+ after do
27
+ server.stop
28
+ queue.clear
29
+ end
30
+
31
+ let(:request) { JSON.parse(queue.pop) }
32
+
33
+ it "sends a deploy notification to the set endpoint" do
34
+ ENV['BUGSNAG_ENDPOINT'] = "http://localhost:" + server.config[:Port].to_s + "/deploy"
35
+
36
+ Dir.chdir(example_path) do
37
+ system(exec_string)
38
+ end
39
+
40
+ payload = request()
41
+ expect(payload["apiKey"]).to eq('YOUR_API_KEY')
42
+ expect(payload["releaseStage"]).to eq('production')
43
+ end
44
+
45
+ it "allows modifications of deployment characteristics" do
46
+ ENV['BUGSNAG_ENDPOINT'] = "http://localhost:" + server.config[:Port].to_s + "/deploy"
47
+ ENV['BUGSNAG_API_KEY'] = "this is a test key"
48
+ ENV['BUGSNAG_RELEASE_STAGE'] = "test"
49
+ ENV['BUGSNAG_REVISION'] = "test"
50
+ ENV['BUGSNAG_APP_VERSION'] = "1"
51
+ ENV['BUGSNAG_REPOSITORY'] = "test@repo.com:test/test_repo.git"
52
+
53
+ Dir.chdir(example_path) do
54
+ system(exec_string)
55
+ end
56
+
57
+ payload = request()
58
+ expect(payload["apiKey"]).to eq('this is a test key')
59
+ expect(payload["releaseStage"]).to eq('test')
60
+ expect(payload["repository"]).to eq("test@repo.com:test/test_repo.git")
61
+ expect(payload["appVersion"]).to eq("1")
62
+ expect(payload["revision"]).to eq("test")
63
+ end
64
+ end
65
+
@@ -0,0 +1,66 @@
1
+ require 'webmock/rspec'
2
+ require 'rspec/expectations'
3
+ require 'rspec/mocks'
4
+ require 'logger'
5
+ require 'json'
6
+
7
+ require 'webrick'
8
+
9
+ require 'bugsnag-capistrano/deploy'
10
+
11
+ describe Bugsnag::Capistrano::Deploy do
12
+ describe "with notifier loadable", :with_notifier do
13
+
14
+ before do
15
+ require "bugsnag"
16
+ Bugsnag.configure do |config|
17
+ config.api_key = "TEST_API_KEY"
18
+ config.release_stage = "production"
19
+ config.logger = Logger.new(StringIO.new)
20
+ end
21
+ end
22
+
23
+ after do
24
+ Bugsnag.configuration.clear_request_data
25
+ end
26
+
27
+ it "should call notify_with_bugsnag" do
28
+ expect(Bugsnag::Delivery::Synchronous).to receive(:deliver)
29
+ Bugsnag::Capistrano::Deploy.notify()
30
+ end
31
+ end
32
+
33
+ describe "without notifier loadable", :without_notifier do
34
+ it "should call notify_without bugsnag" do
35
+ expect(Bugsnag::Capistrano::Deploy).to receive(:deliver)
36
+ Bugsnag::Capistrano::Deploy.notify({:api_key => "test"})
37
+ end
38
+ end
39
+
40
+ describe "the delivery function", :always do
41
+ it "delivers a request to the given url" do
42
+ url = "http://localhost:56456"
43
+ stub_request(:post, url)
44
+ .to_return(status:200, body: "")
45
+ Bugsnag::Capistrano::Deploy.deliver(url, nil)
46
+ end
47
+
48
+ it "delivers a body unmodified" do
49
+ body = ::JSON.dump({
50
+ "paramA" => 'a',
51
+ "paramB" => 'b',
52
+ "paramHash" => {
53
+ "one" => 1,
54
+ "two" => 2,
55
+ "three" => 3
56
+ }
57
+ })
58
+ url = "http://localhost:56456"
59
+ request = stub_request(:post, url)
60
+ .with(body: body, headers: { 'Content-Type' => 'application/json'})
61
+ .to_return(status:200, body: "")
62
+ Bugsnag::Capistrano::Deploy.deliver(url, body)
63
+ assert_requested request
64
+ end
65
+ end
66
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bugsnag-capistrano
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Keegan Lowenstein
8
+ - Martin Holman
9
+ - Alex Moinet
10
+ - Delisa Mason
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2017-11-09 00:00:00.000000000 Z
15
+ dependencies: []
16
+ description: Correlate Capistrano deploys with new errors and increased error rates
17
+ in Bugsnag
18
+ email: keegan@bugsnag.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files:
22
+ - LICENSE.txt
23
+ - README.md
24
+ - CHANGELOG.md
25
+ files:
26
+ - ".gitignore"
27
+ - ".travis.yml"
28
+ - CHANGELOG.md
29
+ - CONTRIBUTING.md
30
+ - Gemfile
31
+ - LICENSE.txt
32
+ - README.md
33
+ - Rakefile
34
+ - VERSION
35
+ - bugsnag-capistrano.gemspec
36
+ - lib/bugsnag-capistrano.rb
37
+ - lib/bugsnag-capistrano/capistrano.rb
38
+ - lib/bugsnag-capistrano/capistrano2.rb
39
+ - lib/bugsnag-capistrano/deploy.rb
40
+ - lib/bugsnag-capistrano/tasks/bugsnag-capistrano.rake
41
+ - lib/bugsnag-capistrano/tasks/bugsnag.cap
42
+ - spec/capistrano_spec.rb
43
+ - spec/deploy_spec.rb
44
+ homepage: http://github.com/bugsnag/bugsnag-capistrano
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.9.2
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.4.5
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Notify Bugsnag when deploying with Capistrano
68
+ test_files: []