bugsnag 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-18mode
5
+ - jruby-19mode
6
+ - rbx-18mode
7
+ - rbx-19mode
8
+ - 1.8.7
data/Gemfile CHANGED
@@ -9,6 +9,6 @@ gem "httparty", ">= 0.5", "< 1.0"
9
9
  # Include everything needed to run rake, tests, features, etc.
10
10
  group :development do
11
11
  gem "rspec", "~> 2.11.0"
12
- gem "rdoc"
13
- gem "jeweler", "~> 1.6.4"
14
- end
12
+ gem "rdoc", "~> 3.12"
13
+ gem "jeweler", "~> 1.8.4"
14
+ end
@@ -6,10 +6,11 @@ GEM
6
6
  httparty (0.9.0)
7
7
  multi_json (~> 1.0)
8
8
  multi_xml
9
- jeweler (1.6.4)
9
+ jeweler (1.8.4)
10
10
  bundler (~> 1.0)
11
11
  git (>= 1.2.5)
12
12
  rake
13
+ rdoc
13
14
  json (1.7.5)
14
15
  multi_json (1.3.6)
15
16
  multi_xml (0.5.1)
@@ -30,7 +31,7 @@ PLATFORMS
30
31
 
31
32
  DEPENDENCIES
32
33
  httparty (>= 0.5, < 1.0)
33
- jeweler (~> 1.6.4)
34
+ jeweler (~> 1.8.4)
34
35
  multi_json (~> 1.0)
35
- rdoc
36
+ rdoc (~> 3.12)
36
37
  rspec (~> 2.11.0)
data/README.md CHANGED
@@ -391,10 +391,16 @@ Contributing
391
391
 
392
392
  - [Fork](https://help.github.com/articles/fork-a-repo) the [notifier on github](https://github.com/bugsnag/bugsnag-ruby)
393
393
  - Commit and push until you are happy with your contribution
394
+ - Run the tests with `rake spec` and make sure they all pass
394
395
  - [Make a pull request](https://help.github.com/articles/using-pull-requests)
395
396
  - Thanks!
396
397
 
397
398
 
399
+ Build Status
400
+ ------------
401
+ [![Build Status](https://secure.travis-ci.org/bugsnag/bugsnag-ruby.png)](http://travis-ci.org/bugsnag/bugsnag-ruby)
402
+
403
+
398
404
  License
399
405
  -------
400
406
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "bugsnag"
8
- s.version = "1.2.1"
8
+ s.version = "1.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Smith"]
12
- s.date = "2012-09-30"
12
+ s.date = "2012-10-01"
13
13
  s.description = "Ruby notifier for bugsnag.com"
14
14
  s.email = "james@bugsnag.com"
15
15
  s.extra_rdoc_files = [
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".rspec",
22
+ ".travis.yml",
22
23
  "Gemfile",
23
24
  "Gemfile.lock",
24
25
  "LICENSE.txt",
@@ -48,10 +49,10 @@ Gem::Specification.new do |s|
48
49
  "lib/bugsnag/version.rb",
49
50
  "lib/resque/failure/bugsnag.rb",
50
51
  "rails/init.rb",
52
+ "spec/middleware_spec.rb",
51
53
  "spec/notification_spec.rb",
52
- "spec/spec_helper.rb",
53
- "test/helper.rb",
54
- "test/test_bugsnag.rb"
54
+ "spec/rack_spec.rb",
55
+ "spec/spec_helper.rb"
55
56
  ]
56
57
  s.homepage = "http://github.com/bugsnag/bugsnag-ruby"
57
58
  s.licenses = ["MIT"]
@@ -66,21 +67,21 @@ Gem::Specification.new do |s|
66
67
  s.add_runtime_dependency(%q<multi_json>, ["~> 1.0"])
67
68
  s.add_runtime_dependency(%q<httparty>, ["< 1.0", ">= 0.5"])
68
69
  s.add_development_dependency(%q<rspec>, ["~> 2.11.0"])
69
- s.add_development_dependency(%q<rdoc>, [">= 0"])
70
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
70
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
71
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
71
72
  else
72
73
  s.add_dependency(%q<multi_json>, ["~> 1.0"])
73
74
  s.add_dependency(%q<httparty>, ["< 1.0", ">= 0.5"])
74
75
  s.add_dependency(%q<rspec>, ["~> 2.11.0"])
75
- s.add_dependency(%q<rdoc>, [">= 0"])
76
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
76
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
77
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
77
78
  end
78
79
  else
79
80
  s.add_dependency(%q<multi_json>, ["~> 1.0"])
80
81
  s.add_dependency(%q<httparty>, ["< 1.0", ">= 0.5"])
81
82
  s.add_dependency(%q<rspec>, ["~> 2.11.0"])
82
- s.add_dependency(%q<rdoc>, [">= 0"])
83
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
83
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
84
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
84
85
  end
85
86
  end
86
87
 
@@ -61,7 +61,6 @@ module Bugsnag
61
61
  end
62
62
 
63
63
  def set_request_data(key, value)
64
- Bugsnag.warn "Overwriting request data for key #{key.to_s}" if self.request_data[key]
65
64
  self.request_data[key] = value
66
65
  end
67
66
 
@@ -22,7 +22,7 @@ module Bugsnag
22
22
  end
23
23
 
24
24
  # Hook up rack-based notification middlewares
25
- config.middleware.use Bugsnag::Middleware::RackRequest
25
+ config.middleware.use Bugsnag::Middleware::RackRequest if defined?(::Rack)
26
26
  config.middleware.use Bugsnag::Middleware::WardenUser if defined?(Warden)
27
27
  end
28
28
  end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bugsnag::MiddlewareStack do
4
+ it "should run before_bugsnag_notify callbacks, adding a tab" do
5
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
6
+ event = get_event_from_payload(payload)
7
+ event[:metaData][:some_tab].should_not be_nil
8
+ event[:metaData][:some_tab][:info].should be == "here"
9
+ event[:metaData][:some_tab][:data].should be == "also here"
10
+ end
11
+
12
+ callback_run_count = 0
13
+ Bugsnag.before_notify_callbacks << lambda {|notif|
14
+ notif.add_tab(:some_tab, {
15
+ :info => "here",
16
+ :data => "also here"
17
+ })
18
+ callback_run_count += 1
19
+ }
20
+
21
+ Bugsnag.notify(BugsnagTestException.new("It crashed"))
22
+ callback_run_count.should be == 1
23
+ end
24
+
25
+ it "should run before_bugsnag_notify callbacks, adding custom data" do
26
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
27
+ event = get_event_from_payload(payload)
28
+ event[:metaData][:custom].should_not be_nil
29
+ event[:metaData][:custom][:info].should be == "here"
30
+ event[:metaData][:custom][:data].should be == "also here"
31
+ end
32
+
33
+ callback_run_count = 0
34
+ Bugsnag.before_notify_callbacks << lambda {|notif|
35
+ notif.add_custom_data(:info, "here")
36
+ notif.add_custom_data(:data, "also here")
37
+
38
+ callback_run_count += 1
39
+ }
40
+
41
+ Bugsnag.notify(BugsnagTestException.new("It crashed"))
42
+ callback_run_count.should be == 1
43
+ end
44
+
45
+ it "overrides should override data set in before_notify" do
46
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
47
+ event = get_event_from_payload(payload)
48
+ event[:metaData][:custom].should_not be_nil
49
+ event[:metaData][:custom][:info].should be == "here2"
50
+ event[:metaData][:custom][:data].should be == "also here"
51
+ end
52
+
53
+ callback_run_count = 0
54
+ Bugsnag.before_notify_callbacks << lambda {|notif|
55
+ notif.add_custom_data(:info, "here")
56
+ notif.add_custom_data(:data, "also here")
57
+
58
+ callback_run_count += 1
59
+ }
60
+
61
+ Bugsnag.notify(BugsnagTestException.new("It crashed"), {:info => "here2"})
62
+ callback_run_count.should be == 1
63
+ end
64
+
65
+ it "should have no before or after callbacks by default" do
66
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
67
+ event = get_event_from_payload(payload)
68
+ event[:metaData].should have(0).items
69
+ end
70
+
71
+ Bugsnag.before_notify_callbacks.should have(0).items
72
+ Bugsnag.after_notify_callbacks.should have(0).items
73
+ Bugsnag.notify(BugsnagTestException.new("It crashed"))
74
+ end
75
+
76
+ it "should run after_bugsnag_notify callbacks" do
77
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
78
+ event = get_event_from_payload(payload)
79
+ end
80
+
81
+ callback_run_count = 0
82
+ Bugsnag.after_notify_callbacks << lambda {|notif|
83
+ callback_run_count += 1
84
+ }
85
+
86
+ Bugsnag.notify(BugsnagTestException.new("It crashed"))
87
+
88
+ callback_run_count.should be == 1
89
+ end
90
+ end
@@ -1,29 +1,9 @@
1
1
  require 'spec_helper'
2
- require 'bugsnag'
3
2
  require 'securerandom'
4
3
 
5
4
  module ActiveRecord; class RecordNotFound < RuntimeError; end; end
6
- class BugsnagTestException < RuntimeError; end
7
-
8
- def get_event_from_payload(payload)
9
- payload[:events].should have(1).items
10
- payload[:events].first
11
- end
12
-
13
- def get_exception_from_payload(payload)
14
- event = get_event_from_payload(payload)
15
- event[:exceptions].should have(1).items
16
- event[:exceptions].last
17
- end
18
5
 
19
6
  describe Bugsnag::Notification do
20
- before(:each) do
21
- Bugsnag.instance_variable_set(:@configuration, Bugsnag::Configuration.new)
22
- Bugsnag.configure do |config|
23
- config.api_key = "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
24
- end
25
- end
26
-
27
7
  it "should contain an api_key if one is set" do
28
8
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
29
9
  payload[:apiKey].should be == "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
@@ -202,6 +182,14 @@ describe Bugsnag::Notification do
202
182
  Bugsnag.notify(BugsnagTestException.new("It crashed"))
203
183
  end
204
184
 
185
+ it "should use the http://notify.bugsnag.com endpoint by default" do
186
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
187
+ endpoint.should be == "http://notify.bugsnag.com"
188
+ end
189
+
190
+ Bugsnag.notify(BugsnagTestException.new("It crashed"))
191
+ end
192
+
205
193
  it "should use ssl when use_ssl is true" do
206
194
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
207
195
  endpoint.should start_with "https://"
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bugsnag::Rack do
4
+ it "should call the upstream rack app with the environment" do
5
+ rack_env = {"key" => "value"}
6
+ app = lambda { |env| ['response', {}, env] }
7
+ rack_stack = Bugsnag::Rack.new(app)
8
+
9
+ response = rack_stack.call(rack_env)
10
+
11
+ response.should be == ['response', {}, rack_env]
12
+ end
13
+
14
+ context "when an exception is raised in rack middleware" do
15
+ # Build a fake crashing rack app
16
+ exception = BugsnagTestException.new("It crashed")
17
+ rack_env = {"key" => "value"}
18
+ app = lambda { |env| raise exception }
19
+ rack_stack = Bugsnag::Rack.new(app)
20
+
21
+ it "should re-raise the exception" do
22
+ expect { rack_stack.call(rack_env) }.to raise_error(BugsnagTestException)
23
+ end
24
+
25
+ it "should deliver an exception if auto_notify is enabled" do
26
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
27
+ exception_class = payload[:events].first[:exceptions].first[:errorClass]
28
+ exception_class.should be == exception.class.to_s
29
+ end
30
+
31
+ rack_stack.call(rack_env) rescue nil
32
+ end
33
+
34
+ it "should not deliver an exception if auto_notify is disabled" do
35
+ Bugsnag.configure do |config|
36
+ config.auto_notify = false
37
+ end
38
+
39
+ Bugsnag::Notification.should_not_receive(:deliver_exception_payload)
40
+
41
+ rack_stack.call(rack_env) rescue nil
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,29 @@
1
+ require 'bugsnag'
2
+
3
+ class BugsnagTestException < RuntimeError; end
4
+
5
+ def get_event_from_payload(payload)
6
+ payload[:events].should have(1).items
7
+ payload[:events].first
8
+ end
9
+
10
+ def get_exception_from_payload(payload)
11
+ event = get_event_from_payload(payload)
12
+ event[:exceptions].should have(1).items
13
+ event[:exceptions].last
14
+ end
15
+
16
+ RSpec.configure do |config|
17
+ config.order = "random"
18
+
19
+ config.before(:each) do
20
+ Bugsnag.instance_variable_set(:@configuration, Bugsnag::Configuration.new)
21
+ Bugsnag.configure do |config|
22
+ config.api_key = "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
23
+ end
24
+ end
25
+
26
+ config.after(:each) do
27
+ Bugsnag.configuration.clear_request_data
28
+ end
29
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Smith
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-09-30 00:00:00 Z
18
+ date: 2012-10-01 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -74,12 +74,13 @@ dependencies:
74
74
  requirement: &id004 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
- - - ">="
77
+ - - ~>
78
78
  - !ruby/object:Gem::Version
79
- hash: 3
79
+ hash: 31
80
80
  segments:
81
- - 0
82
- version: "0"
81
+ - 3
82
+ - 12
83
+ version: "3.12"
83
84
  prerelease: false
84
85
  type: :development
85
86
  name: rdoc
@@ -90,12 +91,12 @@ dependencies:
90
91
  requirements:
91
92
  - - ~>
92
93
  - !ruby/object:Gem::Version
93
- hash: 7
94
+ hash: 63
94
95
  segments:
95
96
  - 1
96
- - 6
97
+ - 8
97
98
  - 4
98
- version: 1.6.4
99
+ version: 1.8.4
99
100
  prerelease: false
100
101
  type: :development
101
102
  name: jeweler
@@ -112,6 +113,7 @@ extra_rdoc_files:
112
113
  files:
113
114
  - .document
114
115
  - .rspec
116
+ - .travis.yml
115
117
  - Gemfile
116
118
  - Gemfile.lock
117
119
  - LICENSE.txt
@@ -141,10 +143,10 @@ files:
141
143
  - lib/bugsnag/version.rb
142
144
  - lib/resque/failure/bugsnag.rb
143
145
  - rails/init.rb
146
+ - spec/middleware_spec.rb
144
147
  - spec/notification_spec.rb
148
+ - spec/rack_spec.rb
145
149
  - spec/spec_helper.rb
146
- - test/helper.rb
147
- - test/test_bugsnag.rb
148
150
  homepage: http://github.com/bugsnag/bugsnag-ruby
149
151
  licenses:
150
152
  - MIT
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'bugsnag'
16
-
17
- class Test::Unit::TestCase
18
- end
@@ -1,22 +0,0 @@
1
- require 'helper'
2
- require 'logger'
3
-
4
- class BugsnagTestException < RuntimeError; end
5
-
6
- class TestBugsnag < Test::Unit::TestCase
7
- should "send a normal exception" do
8
- Bugsnag.configure do |config|
9
- config.api_key = "2dd3f9aaef927b88be4e3c713b663354"
10
- config.release_stage = "production"
11
- config.project_root = File.dirname(__FILE__)
12
- config.logger = Logger.new(STDOUT)
13
- end
14
-
15
- begin
16
- raise BugsnagTestException.new("Exception test from bugsnag gem")
17
- rescue Exception => e
18
- response = Bugsnag.notify(e)
19
- flunk "oh my" if response.code != 200
20
- end
21
- end
22
- end