exception_notification-squash_notifier 0.1.1.3 → 0.1.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 +4 -4
- data/lib/exception_notifier/squash_notifier.rb +1 -1
- data/lib/exception_notifier/squash_notifier/base.rb +14 -15
- data/lib/exception_notifier/squash_notifier/rails.rb +2 -0
- data/lib/exception_notifier/squash_notifier/version.rb +1 -1
- data/lib/exception_notifier/{squash_ruby.rb → squash_ruby/ruby.rb} +0 -0
- data/spec/exception_notifier/squash_notifier_rails_spec.rb +5 -0
- data/spec/exception_notifier/squash_notifier_spec.rb +104 -33
- data/spec/exception_notifier/squash_ruby_rails_spec.rb +9 -0
- data/spec/exception_notifier/squash_ruby_spec.rb +4 -1
- data/spec/spec_helper.rb +7 -0
- data/spec/spec_helper_rails.rb +9 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49df10a4b82e71ad0829544c5adeac202ab40884
|
4
|
+
data.tar.gz: 52715ca0a077f47f2c810b690b3a36e1ce778d8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f308ec8684dae55a9d353ea1c6229bdc5bce7b5fc0a8ffcf086fe5b73d233e7ede63c9a6f2c3f41ac2780f62fee3ab4be8dc9182bbe0a57bac8a4d6a22e24ef1
|
7
|
+
data.tar.gz: d320ce946935fc66341dc8d72514a144b4001cac4b2e26a4ddd2c3798f6d3c7e9b104e366bd56a5872deef7a3ec9dce1da7e70f5d83cf6b4827ee87242007b02
|
@@ -3,7 +3,7 @@ require "exception_notifier/squash_notifier/version"
|
|
3
3
|
require "active_support/core_ext/module/attribute_accessors"
|
4
4
|
require "exception_notifier"
|
5
5
|
|
6
|
-
require "exception_notifier/squash_ruby"
|
6
|
+
require "exception_notifier/squash_ruby/ruby"
|
7
7
|
# Extend class if you find Rails is being used:
|
8
8
|
require 'exception_notifier/squash_ruby/rails' if defined? Rails
|
9
9
|
|
@@ -1,25 +1,17 @@
|
|
1
1
|
module ExceptionNotifier
|
2
2
|
class SquashNotifier
|
3
|
-
# Factory class
|
3
|
+
# Factory class
|
4
|
+
|
5
|
+
cattr_accessor :enable_rails
|
6
|
+
self.enable_rails = true
|
7
|
+
|
4
8
|
def self.new(*args, &p)
|
5
|
-
return SquashRailsNotifier.new(*args, &p) if defined? Rails
|
9
|
+
return SquashRailsNotifier.new(*args, &p) if self.enable_rails && defined? Rails
|
6
10
|
SquashRubyNotifier.new(*args, &p)
|
7
11
|
end
|
8
12
|
|
9
13
|
class BaseNotifier
|
10
|
-
cattr_accessor :whitelisted_env_vars
|
11
|
-
# This accepts RegEx, so to not-whitelist, add an entry of /.*/
|
12
|
-
self.whitelisted_env_vars = []
|
13
|
-
|
14
|
-
def self.default_options
|
15
|
-
{
|
16
|
-
filter_env_vars: self.whitelist_env_filter
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
def default_options
|
21
|
-
self.class.default_options
|
22
|
-
end
|
14
|
+
cattr_accessor :whitelisted_env_vars, :default_options
|
23
15
|
|
24
16
|
def self.whitelist_env_filter
|
25
17
|
# Remove any entries from the 'env' var that are not in the 'whitelisted_env_var' list
|
@@ -35,6 +27,13 @@ module ExceptionNotifier
|
|
35
27
|
end
|
36
28
|
end
|
37
29
|
|
30
|
+
# This accepts RegEx, so to not-whitelist, add an entry of /.*/
|
31
|
+
self.whitelisted_env_vars = []
|
32
|
+
|
33
|
+
self.default_options = {
|
34
|
+
filter_env_vars: self.whitelist_env_filter
|
35
|
+
}
|
36
|
+
|
38
37
|
#####
|
39
38
|
|
40
39
|
def initialize(options)
|
@@ -52,6 +52,8 @@ class ExceptionNotifier::SquashNotifier::SquashRailsNotifier < ExceptionNotifier
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def occurence_data(request: nil, session: nil, rack_env: {})
|
55
|
+
fail "No 'request' supplied" unless request
|
56
|
+
|
55
57
|
#TODO: Remove when done:
|
56
58
|
# flash_key = defined?(ActionDispatch) ? ActionDispatch::Flash::KEY : 'flash'
|
57
59
|
|
File without changes
|
@@ -1,50 +1,58 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.shared_context "
|
4
|
-
let(:
|
5
|
-
|
6
|
-
|
3
|
+
RSpec.shared_context "squash_notifier_creation" do
|
4
|
+
let(:squash_notifier) { ExceptionNotifier.registered_exception_notifier(:squash) }
|
5
|
+
|
6
|
+
before(:context) do
|
7
|
+
@squash_config_options = {
|
8
|
+
api_host: 'https://no-such-host.noncom',
|
9
|
+
api_key: '00000000-0000-0000-0000-000000000000',
|
10
|
+
environment: 'development'
|
11
|
+
}
|
12
|
+
|
13
|
+
env = described_class.whitelisted_env_vars.map do |k|
|
14
|
+
k = k.to_s.sub(/^(\(.*:)(.*)(\))$/, '\2') if k.is_a? Regexp
|
15
|
+
[k.to_s, "val #{k}"]
|
16
|
+
end
|
17
|
+
@captured_env_vars = Hash[env]
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "created directly" do
|
21
|
+
it "can create a #{described_class} from a const" do
|
22
|
+
expect(squash_ruby).to receive(:configure).with(
|
23
|
+
@squash_config_options.merge(filter_env_vars: duck_type(:call))
|
24
|
+
)
|
25
|
+
expect(squash_ruby).to receive(:configuration).with(:api_key).and_return(true)
|
26
|
+
expect(squash_ruby).to receive(:configure).with(disabled: false)
|
27
|
+
expect(ExceptionNotifier::SquashNotifier.new(@squash_config_options)).to be_an described_class
|
28
|
+
end
|
7
29
|
end
|
8
30
|
end
|
9
31
|
|
10
|
-
describe ExceptionNotifier::SquashNotifier do
|
32
|
+
describe ExceptionNotifier::SquashNotifier::SquashRubyNotifier do
|
11
33
|
include_context "squash_ruby"
|
12
34
|
|
13
|
-
|
35
|
+
around(:context) do |eg|
|
36
|
+
saved = ExceptionNotifier::SquashNotifier.enable_rails
|
37
|
+
ExceptionNotifier::SquashNotifier.enable_rails = false
|
14
38
|
|
15
|
-
|
16
|
-
before(:context) do
|
17
|
-
@squash_config_options = {
|
18
|
-
api_host: 'https://no-such-host.noncom',
|
19
|
-
api_key: '00000000-0000-0000-0000-000000000000',
|
20
|
-
environment: 'development'
|
21
|
-
}
|
22
|
-
|
23
|
-
env = ExceptionNotifier::SquashNotifier.whitelisted_env_vars.map do |k|
|
24
|
-
k = k.to_s.sub(/^(\(.*:)(.*)(\))$/, '\2') if k.is_a? Regexp
|
25
|
-
[k.to_s, "val #{k}"]
|
26
|
-
end
|
27
|
-
@captured_env_vars = Hash[env]
|
28
|
-
end
|
39
|
+
eg.run
|
29
40
|
|
30
|
-
|
31
|
-
|
32
|
-
expect(squash_ruby).to receive(:configure).with(
|
33
|
-
@squash_config_options.merge(filter_env_vars: duck_type(:call))
|
34
|
-
)
|
35
|
-
expect(squash_ruby).to receive(:configuration).with(:api_key).and_return(true)
|
36
|
-
expect(squash_ruby).to receive(:configure).with(disabled: false)
|
37
|
-
expect(ExceptionNotifier::SquashNotifier.new(@squash_config_options)).to be_an ExceptionNotifier::SquashNotifier
|
38
|
-
end
|
41
|
+
ExceptionNotifier::SquashNotifier.enable_rails = saved
|
42
|
+
end
|
39
43
|
|
40
|
-
|
44
|
+
describe "with a valid instance" do
|
45
|
+
include_context "squash_notifier_creation"
|
41
46
|
|
42
47
|
describe "created via ExceptionNotifier" do
|
43
48
|
around(:context) do |eg|
|
44
49
|
ExceptionNotification.configure {|c| c.add_notifier :squash, @squash_config_options }
|
50
|
+
|
45
51
|
eg.run
|
52
|
+
|
46
53
|
ExceptionNotification.configure {|c| c.unregister_exception_notifier :squash }
|
47
54
|
end
|
55
|
+
|
48
56
|
let(:squash_notifier) { ExceptionNotifier.registered_exception_notifier(:squash) }
|
49
57
|
|
50
58
|
#Time.stubs(:current).returns('Sat, 20 Apr 2013 20:58:55 UTC +00:00')
|
@@ -57,15 +65,19 @@ describe ExceptionNotifier::SquashNotifier do
|
|
57
65
|
begin
|
58
66
|
1/0
|
59
67
|
rescue => e
|
60
|
-
expect(squash_ruby).to receive(:notify).with(e, {})
|
68
|
+
expect(squash_ruby).to receive(:notify).with(e, {}).and_return(nil)
|
61
69
|
ExceptionNotifier.notify_exception(e, {})
|
62
70
|
end
|
63
71
|
end
|
64
72
|
|
65
73
|
context "whitelisting" do
|
74
|
+
it "should have a whitelisting filter" do
|
75
|
+
expect(Squash::Ruby.configuration(:filter_env_vars)).not_to be_nil
|
76
|
+
end
|
77
|
+
|
66
78
|
it "should be the same at class and instance level" do
|
67
79
|
#NB: Need to use #class_eval, as the underlying is dynamically extended
|
68
|
-
expect(squash_notifier.whitelisted_env_vars).to eq(
|
80
|
+
expect(squash_notifier.whitelisted_env_vars).to eq(described_class.class_eval { self.whitelisted_env_vars })
|
69
81
|
end
|
70
82
|
|
71
83
|
context "with faked ENV" do
|
@@ -88,8 +100,67 @@ describe ExceptionNotifier::SquashNotifier do
|
|
88
100
|
end
|
89
101
|
|
90
102
|
describe "with Squash unregistered" do
|
91
|
-
|
103
|
+
include_context "squash_notifier_creation"
|
104
|
+
|
105
|
+
it "should not find a Squash notifier" do
|
92
106
|
expect(squash_notifier).to be_nil
|
93
107
|
end
|
94
108
|
end
|
95
109
|
end
|
110
|
+
|
111
|
+
#####
|
112
|
+
|
113
|
+
describe ExceptionNotifier::SquashNotifier::SquashRailsNotifier do
|
114
|
+
include_context "squash_ruby"
|
115
|
+
|
116
|
+
around(:context) do |eg|
|
117
|
+
saved = ExceptionNotifier::SquashNotifier.enable_rails
|
118
|
+
ExceptionNotifier::SquashNotifier.enable_rails = true
|
119
|
+
|
120
|
+
eg.run
|
121
|
+
|
122
|
+
ExceptionNotifier::SquashNotifier.enable_rails = saved
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "with a valid instance" do
|
126
|
+
include_context "squash_notifier_creation"
|
127
|
+
|
128
|
+
describe "created via ExceptionNotifier" do
|
129
|
+
around(:context) do |eg|
|
130
|
+
ExceptionNotification.configure {|c| c.add_notifier :squash, @squash_config_options }
|
131
|
+
|
132
|
+
eg.run
|
133
|
+
|
134
|
+
ExceptionNotification.configure {|c| c.unregister_exception_notifier :squash }
|
135
|
+
end
|
136
|
+
|
137
|
+
let(:squash_notifier) { ExceptionNotifier.registered_exception_notifier(:squash) }
|
138
|
+
|
139
|
+
#Time.stubs(:current).returns('Sat, 20 Apr 2013 20:58:55 UTC +00:00')
|
140
|
+
|
141
|
+
xit "notifies Squash of an standard exception when no rack-env data supplied" do
|
142
|
+
pending("Providing rack-complete data to the :env option")
|
143
|
+
|
144
|
+
begin
|
145
|
+
1/0
|
146
|
+
rescue => e
|
147
|
+
expect(squash_ruby).to receive(:notify).with(e, {}).and_return(nil)
|
148
|
+
ExceptionNotifier.notify_exception(e, {})
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
xit "notifies Squash of an Rails exception when rack-env data supplied" do
|
153
|
+
pending("Providing rack-complete data to the :env option")
|
154
|
+
|
155
|
+
begin
|
156
|
+
1/0
|
157
|
+
rescue => e
|
158
|
+
expect(squash_ruby).to receive(:configuration).with(:filter_env_vars).and_return(squash_notifier.default_options[:filter_env_vars])
|
159
|
+
#expect(squash_ruby).to receive(:notify).with(e, {env: "TEST"}).and_return(nil)
|
160
|
+
|
161
|
+
ExceptionNotifier.notify_exception(e, {env: {a: "TEST"}})
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
@@ -2,7 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Squash::Ruby do
|
4
4
|
it do
|
5
|
-
|
5
|
+
pending("monkey-patching makes me sad")
|
6
|
+
#NB: It may never be possible to make this pass, with Squash::Ruby
|
7
|
+
# monkey-patching style
|
8
|
+
expect(Squash::Ruby.client_name).to eq('squash-notifier')
|
6
9
|
end
|
7
10
|
|
8
11
|
describe "with a valid instance" do
|
data/spec/spec_helper.rb
CHANGED
@@ -11,3 +11,10 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
11
11
|
|
12
12
|
require 'exception_notification'
|
13
13
|
require 'exception_notifier/squash_notifier'
|
14
|
+
|
15
|
+
RSpec.shared_context "squash_ruby" do
|
16
|
+
let(:squash_ruby) do
|
17
|
+
class_double("Squash::Ruby").
|
18
|
+
as_stubbed_const(:transfer_nested_constants => true)
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_notification-squash_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Robertson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -158,11 +158,14 @@ files:
|
|
158
158
|
- lib/exception_notifier/squash_notifier/rails.rb
|
159
159
|
- lib/exception_notifier/squash_notifier/ruby.rb
|
160
160
|
- lib/exception_notifier/squash_notifier/version.rb
|
161
|
-
- lib/exception_notifier/squash_ruby.rb
|
162
161
|
- lib/exception_notifier/squash_ruby/rails.rb
|
162
|
+
- lib/exception_notifier/squash_ruby/ruby.rb
|
163
|
+
- spec/exception_notifier/squash_notifier_rails_spec.rb
|
163
164
|
- spec/exception_notifier/squash_notifier_spec.rb
|
165
|
+
- spec/exception_notifier/squash_ruby_rails_spec.rb
|
164
166
|
- spec/exception_notifier/squash_ruby_spec.rb
|
165
167
|
- spec/spec_helper.rb
|
168
|
+
- spec/spec_helper_rails.rb
|
166
169
|
homepage: ''
|
167
170
|
licenses:
|
168
171
|
- MIT
|
@@ -188,7 +191,10 @@ signing_key:
|
|
188
191
|
specification_version: 4
|
189
192
|
summary: Exception Notifier plugin for Squash
|
190
193
|
test_files:
|
194
|
+
- spec/exception_notifier/squash_notifier_rails_spec.rb
|
191
195
|
- spec/exception_notifier/squash_notifier_spec.rb
|
196
|
+
- spec/exception_notifier/squash_ruby_rails_spec.rb
|
192
197
|
- spec/exception_notifier/squash_ruby_spec.rb
|
193
198
|
- spec/spec_helper.rb
|
199
|
+
- spec/spec_helper_rails.rb
|
194
200
|
has_rdoc:
|