execute_with_rescue_with_airbrake 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a075f476d5e0d9f96a18858757b1f0f967162c8e
4
- data.tar.gz: 57fe7504b06259d529e6a56cc4910ac91728ad25
3
+ metadata.gz: b5d1379bd518fffaf16cac770009ce25a685495d
4
+ data.tar.gz: d92e9467ea3bd298841841669d1cd00aeb947c52
5
5
  SHA512:
6
- metadata.gz: da8223cb3c1484790c8d9a883faf00f705d572aef2f74c81886ff18e7914d0c0efeb912b2f42a40bda49684be01ea517c08fc7748a480bcf101c308a8648c5d2
7
- data.tar.gz: 204f405743ecb2ae9e20d55b3482429383e0d0d443c1281a802325a96016a8c24f430f20bc3392ceb261b52e9ea63538dc0b24d6a0dba647e965c1fc6d8ee848
6
+ metadata.gz: e6d1ee7602c638f994973d5bbf475452390725e682223e5f8f4b9d09c5923d85c14d58d08b145c270929a0ccbd22dc6ff30b1a6f3a34d250d0b88c84655814b2
7
+ data.tar.gz: f4dad93c3d92a645088879894012544773b8b3c1660aeb762be35afeb8427cae5f2a42c18c6ee3f0517a1d9b5fb213baba0382af897d48a932f1ecf3300985f3
data/.travis.yml CHANGED
@@ -6,6 +6,7 @@ rvm:
6
6
  - 2.0.0
7
7
  - 2.1.0
8
8
  - 2.1.1
9
+ - 2.1.2
9
10
  gemfile:
10
11
  - gemfiles/rails_3_2.gemfile
11
12
  - gemfiles/rails_4_0.gemfile
data/Appraisals CHANGED
@@ -1,11 +1,11 @@
1
1
  appraise "rails-3-2" do
2
- gem "activesupport", "3.2.17"
2
+ gem "activesupport", "3.2.18"
3
3
  end
4
4
 
5
5
  appraise "rails-4-0" do
6
- gem "activesupport", "4.0.4"
6
+ gem "activesupport", "4.0.5"
7
7
  end
8
8
 
9
9
  appraise "rails-4-1" do
10
- gem "activesupport", "4.1.0.rc1"
10
+ gem "activesupport", "4.1.1"
11
11
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ### Changelog
2
2
 
3
3
 
4
+ - **0.0.2**
5
+ - Allow `airbrake` `4.*` to be used (It only removes JS notifier)
6
+
4
7
  - **0.0.1**
5
8
  - Initial Release
data/README.md CHANGED
@@ -1,11 +1,8 @@
1
1
  # ExecuteWithRescueWithAirbrake
2
2
 
3
- TODO: Write a gem description
4
-
5
3
  The Airbrake adapter plus mixin to be used with `execute_with_rescue`.
6
4
 
7
5
  ## Support
8
- ===========
9
6
  Tested against:
10
7
  - Active Support of version `3.2`, `4.0` and `4.1` (pre-3.2 got wrong dependency & I don't want to support)
11
8
  - MRI `1.9.3`, `2.0.0`, `2.1.0`, `2.1.1`
@@ -32,8 +29,6 @@ Or install it yourself as:
32
29
 
33
30
  ## Usage
34
31
 
35
- TODO: Write usage instructions here
36
-
37
32
  Note: You must configurate `airbrake` first or you won't be able to send anything (I have to do the same in `spec_helper`)
38
33
 
39
34
  ### `include ExecuteWithRescue::Mixins::WithAirbrake`
@@ -71,6 +66,34 @@ class SomeServiceClass
71
66
  end
72
67
  ```
73
68
 
69
+ If you have a custom error that generates error message from the argument, (and you don't want to duplicate how it generates the message)
70
+ You can do as the following:
71
+ ```ruby
72
+ class SomeServiceClass
73
+ class CustomErrorWithMessage < StandardError
74
+ def self.new(thing)
75
+ msg = "#{thing.class} has error"
76
+ super(msg)
77
+ end
78
+ end
79
+
80
+ def perform
81
+ execute_with_rescue do
82
+ do_something
83
+ end
84
+ end
85
+
86
+ def do_something
87
+ # If you cannot provide the argument for the exception at this point then I can't help you
88
+ # You should really use `begin...rescue...end` for such customization
89
+ set_default_airbrake_notice_error_class(CustomErrorWithMessage)
90
+ set_default_airbrake_notice_error_message(CustomErrorWithMessage.new(:foo).message)
91
+
92
+ raise StandardError
93
+ end
94
+ end
95
+ ```
96
+
74
97
  ### `#notify_by_airbrake_or_raise`
75
98
  **Private** method to be called automatically by `rescue_from StandardError` from the mixin.
76
99
  Call this if you have some custom handling for some error classes
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ RSpec::Core::RakeTask.new(:spec)
9
9
 
10
10
  if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
11
11
  task :default do
12
- sh "rake appraisal:install && rake appraisal spec"
12
+ sh "appraisal install && rake appraisal spec"
13
13
  end
14
14
  else
15
15
  task :default => :spec
@@ -18,12 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "execute_with_rescue", "~> 0.0", ">= 0.0.1"
21
- spec.add_dependency "airbrake", "~> 3.1.0"
21
+ spec.add_dependency "airbrake", ">= 3.1", "<= 5"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.5"
24
24
  spec.add_development_dependency "rake"
25
- spec.add_development_dependency "appraisal", ">= 0.5.2"
26
- spec.add_development_dependency "rspec", "~> 2.14.0"
25
+ spec.add_development_dependency "appraisal", "~> 1.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "rspec-its", "~> 1.0"
27
28
  spec.add_development_dependency "coveralls", ">= 0.7"
28
29
  spec.add_development_dependency "gem-release", ">= 0.7"
29
30
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "3.2.17"
5
+ gem "activesupport", "3.2.18"
6
6
 
7
- gemspec :path=>"../"
7
+ gemspec :path => "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "4.0.4"
5
+ gem "activesupport", "4.0.5"
6
6
 
7
- gemspec :path=>"../"
7
+ gemspec :path => "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "4.1.0.rc1"
5
+ gem "activesupport", "4.1.1"
6
6
 
7
- gemspec :path=>"../"
7
+ gemspec :path => "../"
@@ -1,3 +1,3 @@
1
1
  module ExecuteWithRescueWithAirbrake
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -13,9 +13,9 @@ describe ExecuteWithRescue::Mixins::WithAirbrake do
13
13
  let!(:adapter_instance) { adapter_class.new }
14
14
  before do
15
15
  # Avoid Error
16
- test_class_instance
17
- .stub(:_execute_with_rescue_current_airbrake_adapter)
18
- .and_return(adapter_instance)
16
+ allow(test_class_instance)
17
+ .to receive(:_execute_with_rescue_current_airbrake_adapter)
18
+ .and_return(adapter_instance)
19
19
  end
20
20
  end
21
21
 
@@ -50,7 +50,9 @@ describe ExecuteWithRescue::Mixins::WithAirbrake do
50
50
  describe 'delegation' do
51
51
  include_context 'when airbrake adapter assumed exists'
52
52
 
53
- before { adapter_instance.stub(method_name) }
53
+ before do
54
+ allow(adapter_instance).to receive(method_name)
55
+ end
54
56
 
55
57
  let(:send_message) { test_class_instance.send(method_name) }
56
58
 
@@ -82,7 +84,7 @@ describe ExecuteWithRescue::Mixins::WithAirbrake do
82
84
  describe 'execution' do
83
85
  include_context 'when airbrake adapter assumed exists'
84
86
 
85
- before { Airbrake.configuration.stub(public?: true) }
87
+ before { allow(Airbrake.configuration).to receive(:public?) { true } }
86
88
 
87
89
  describe 'when there is no error raised' do
88
90
  specify do
@@ -122,6 +124,21 @@ describe ExecuteWithRescue::Mixins::WithAirbrake do
122
124
  call_service
123
125
  end
124
126
  end
127
+
128
+ describe 'setting custom airbrake options with an error that requires argument on initialize' do
129
+ let(:test_class) { TestServiceWithAirbrakeWithCustomErrorAndMessage }
130
+
131
+ specify do
132
+ expect(Airbrake)
133
+ .to(receive(:notify_or_ignore)
134
+ .with(kind_of(StandardError), {
135
+ error_class: test_class::CustomErrorWithMessage,
136
+ error_message: "#{:foo.class} has error",
137
+ }))
138
+
139
+ call_service
140
+ end
141
+ end
125
142
  end
126
143
  end
127
144
  end
@@ -14,7 +14,7 @@ describe ExecuteWithRescueWithAirbrake::Adapters::AirbrakeAdapter do
14
14
  #before { }
15
15
 
16
16
  context 'when exception should not be notified according to Airbrake' do
17
- before { Airbrake.configuration.stub(public?: false) }
17
+ before { allow(Airbrake.configuration).to receive(:public?) { false } }
18
18
 
19
19
  it 're-raise the rescue error' do
20
20
  expect { notify_or_raise }.to raise_error(exception_rescued.class,
@@ -22,7 +22,7 @@ describe ExecuteWithRescueWithAirbrake::Adapters::AirbrakeAdapter do
22
22
  end
23
23
  end
24
24
  context 'when exception should be notified according to Airbrake' do
25
- before { Airbrake.configuration.stub(public?: true) }
25
+ before { allow(Airbrake.configuration).to receive(:public?) { true } }
26
26
 
27
27
  it 'does not re-raise the rescued error' do
28
28
  expect { notify_or_raise }.to_not raise_error
@@ -30,12 +30,14 @@ describe ExecuteWithRescueWithAirbrake::Adapters::AirbrakeAdapter do
30
30
  end
31
31
 
32
32
  context 'assuming Airbrake says it error should be notified' do
33
- before { Airbrake.configuration.stub(public?: true) }
33
+ before { allow(Airbrake.configuration).to receive(:public?) { true } }
34
34
 
35
35
  it 'calls Airbrake.notify_or_ignore' do
36
- Airbrake.should_receive(:notify_or_ignore)
36
+ expect(Airbrake).to receive(:notify_or_ignore)
37
37
 
38
38
  notify_or_raise
39
+
40
+ # expect(Airbrake).to have_received(:notify_or_ignore)
39
41
  end
40
42
 
41
43
 
@@ -49,7 +51,7 @@ describe ExecuteWithRescueWithAirbrake::Adapters::AirbrakeAdapter do
49
51
 
50
52
  before do
51
53
  # Return the options only
52
- Airbrake.stub(:notify_or_ignore) {|*args| args.last }
54
+ allow(Airbrake).to receive(:notify_or_ignore) {|*args| args.last }
53
55
  end
54
56
  let(:options_hash) { notify_or_raise }
55
57
  subject { options_hash }
@@ -81,7 +83,7 @@ describe ExecuteWithRescueWithAirbrake::Adapters::AirbrakeAdapter do
81
83
 
82
84
  before do
83
85
  # Return the options only
84
- Airbrake.stub(:notify_or_ignore) {|*args| args.last }
86
+ allow(Airbrake).to receive(:notify_or_ignore) {|*args| args.last }
85
87
  end
86
88
  let(:options_hash) { notify_or_raise }
87
89
  subject { options_hash }
@@ -114,7 +116,7 @@ describe ExecuteWithRescueWithAirbrake::Adapters::AirbrakeAdapter do
114
116
 
115
117
  before do
116
118
  # Return the options only
117
- Airbrake.stub(:notify_or_ignore) {|*args| args.last }
119
+ allow(Airbrake).to receive(:notify_or_ignore) {|*args| args.last }
118
120
  end
119
121
  let(:options_hash) { notify_or_raise }
120
122
  let(:parameters_hash) { options_hash[option_key] }
@@ -33,6 +33,23 @@ class TestServiceWithAirbrakeWithErrorAndAirbrakeOption <
33
33
  super
34
34
  end
35
35
  end
36
+ class TestServiceWithAirbrakeWithCustomErrorAndMessage <
37
+ TestServiceWithAirbrakeWithErrorAndAirbrakeOption
38
+
39
+ class CustomErrorWithMessage < StandardError
40
+ def self.new(thing)
41
+ msg = "#{thing.class} has error"
42
+ super(msg)
43
+ end
44
+ end
45
+
46
+ def do_something
47
+ set_default_airbrake_notice_error_class(CustomErrorWithMessage)
48
+ set_default_airbrake_notice_error_message(CustomErrorWithMessage.new(:foo).message)
49
+
50
+ raise StandardError
51
+ end
52
+ end
36
53
 
37
54
  class TestServiceWithAirbrakeWithExecuteWithRescueCall <
38
55
  TestServiceWithAirbrake
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,7 @@ require 'airbrake'
8
8
 
9
9
  require 'fixtures/test_service_classes'
10
10
  require 'rspec'
11
+ require 'rspec/its'
11
12
 
12
13
  require 'logger'
13
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: execute_with_rescue_with_airbrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - PikachuEXE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execute_with_rescue
@@ -34,16 +34,22 @@ dependencies:
34
34
  name: airbrake
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '3.1'
40
+ - - <=
38
41
  - !ruby/object:Gem::Version
39
- version: 3.1.0
42
+ version: '5'
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
- - - ~>
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '3.1'
50
+ - - <=
45
51
  - !ruby/object:Gem::Version
46
- version: 3.1.0
52
+ version: '5'
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: bundler
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -76,30 +82,44 @@ dependencies:
76
82
  name: appraisal
77
83
  requirement: !ruby/object:Gem::Requirement
78
84
  requirements:
79
- - - '>='
85
+ - - ~>
80
86
  - !ruby/object:Gem::Version
81
- version: 0.5.2
87
+ version: '1.0'
82
88
  type: :development
83
89
  prerelease: false
84
90
  version_requirements: !ruby/object:Gem::Requirement
85
91
  requirements:
86
- - - '>='
92
+ - - ~>
87
93
  - !ruby/object:Gem::Version
88
- version: 0.5.2
94
+ version: '1.0'
89
95
  - !ruby/object:Gem::Dependency
90
96
  name: rspec
91
97
  requirement: !ruby/object:Gem::Requirement
92
98
  requirements:
93
99
  - - ~>
94
100
  - !ruby/object:Gem::Version
95
- version: 2.14.0
101
+ version: '3.0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ~>
107
+ - !ruby/object:Gem::Version
108
+ version: '3.0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: rspec-its
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ~>
114
+ - !ruby/object:Gem::Version
115
+ version: '1.0'
96
116
  type: :development
97
117
  prerelease: false
98
118
  version_requirements: !ruby/object:Gem::Requirement
99
119
  requirements:
100
120
  - - ~>
101
121
  - !ruby/object:Gem::Version
102
- version: 2.14.0
122
+ version: '1.0'
103
123
  - !ruby/object:Gem::Dependency
104
124
  name: coveralls
105
125
  requirement: !ruby/object:Gem::Requirement
@@ -146,11 +166,8 @@ files:
146
166
  - Rakefile
147
167
  - execute_with_rescue_with_airbrake.gemspec
148
168
  - gemfiles/rails_3_2.gemfile
149
- - gemfiles/rails_3_2.gemfile.lock
150
169
  - gemfiles/rails_4_0.gemfile
151
- - gemfiles/rails_4_0.gemfile.lock
152
170
  - gemfiles/rails_4_1.gemfile
153
- - gemfiles/rails_4_1.gemfile.lock
154
171
  - lib/execute_with_rescue/errors/no_airbrake_adapter.rb
155
172
  - lib/execute_with_rescue/mixins/with_airbrake.rb
156
173
  - lib/execute_with_rescue_with_airbrake.rb