airbrake-ruby 6.0.1-java → 6.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby/config/processor.rb +6 -0
- data/lib/airbrake-ruby/config.rb +3 -3
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -1
- data/lib/airbrake-ruby/filters/git_repository_filter.rb +7 -1
- data/lib/airbrake-ruby/filters/sql_filter.rb +6 -6
- data/lib/airbrake-ruby/nested_exception.rb +10 -1
- data/lib/airbrake-ruby/notice.rb +5 -3
- data/lib/airbrake-ruby/performance_notifier.rb +38 -38
- data/lib/airbrake-ruby/stat.rb +1 -1
- data/lib/airbrake-ruby/time_truncate.rb +2 -2
- data/lib/airbrake-ruby/version.rb +1 -1
- data/lib/airbrake-ruby.rb +21 -21
- metadata +6 -123
- data/spec/airbrake_spec.rb +0 -522
- data/spec/async_sender_spec.rb +0 -65
- data/spec/backtrace_spec.rb +0 -430
- data/spec/benchmark_spec.rb +0 -35
- data/spec/code_hunk_spec.rb +0 -124
- data/spec/config/processor_spec.rb +0 -151
- data/spec/config/validator_spec.rb +0 -204
- data/spec/config_spec.rb +0 -188
- data/spec/context_spec.rb +0 -54
- data/spec/deploy_notifier_spec.rb +0 -50
- data/spec/file_cache_spec.rb +0 -35
- data/spec/filter_chain_spec.rb +0 -124
- data/spec/filters/context_filter_spec.rb +0 -32
- data/spec/filters/dependency_filter_spec.rb +0 -14
- data/spec/filters/exception_attributes_filter_spec.rb +0 -52
- data/spec/filters/gem_root_filter_spec.rb +0 -44
- data/spec/filters/git_last_checkout_filter_spec.rb +0 -61
- data/spec/filters/git_repository_filter.rb +0 -61
- data/spec/filters/git_revision_filter_spec.rb +0 -126
- data/spec/filters/keys_allowlist_spec.rb +0 -204
- data/spec/filters/keys_blocklist_spec.rb +0 -242
- data/spec/filters/root_directory_filter_spec.rb +0 -39
- data/spec/filters/sql_filter_spec.rb +0 -274
- data/spec/filters/system_exit_filter_spec.rb +0 -16
- data/spec/filters/thread_filter_spec.rb +0 -281
- data/spec/fixtures/notroot.txt +0 -7
- data/spec/fixtures/project_root/code.rb +0 -221
- data/spec/fixtures/project_root/empty_file.rb +0 -0
- data/spec/fixtures/project_root/long_line.txt +0 -1
- data/spec/fixtures/project_root/short_file.rb +0 -3
- data/spec/fixtures/project_root/vendor/bundle/ignored_file.rb +0 -5
- data/spec/helpers.rb +0 -9
- data/spec/ignorable_spec.rb +0 -14
- data/spec/inspectable_spec.rb +0 -45
- data/spec/loggable_spec.rb +0 -17
- data/spec/monotonic_time_spec.rb +0 -25
- data/spec/nested_exception_spec.rb +0 -73
- data/spec/notice_notifier/options_spec.rb +0 -269
- data/spec/notice_notifier_spec.rb +0 -361
- data/spec/notice_spec.rb +0 -300
- data/spec/performance_breakdown_spec.rb +0 -11
- data/spec/performance_notifier_spec.rb +0 -645
- data/spec/promise_spec.rb +0 -203
- data/spec/query_spec.rb +0 -11
- data/spec/queue_spec.rb +0 -18
- data/spec/remote_settings/callback_spec.rb +0 -162
- data/spec/remote_settings/settings_data_spec.rb +0 -348
- data/spec/remote_settings_spec.rb +0 -201
- data/spec/request_spec.rb +0 -9
- data/spec/response_spec.rb +0 -110
- data/spec/spec_helper.rb +0 -100
- data/spec/stashable_spec.rb +0 -23
- data/spec/stat_spec.rb +0 -39
- data/spec/sync_sender_spec.rb +0 -168
- data/spec/tdigest_spec.rb +0 -235
- data/spec/thread_pool_spec.rb +0 -196
- data/spec/time_truncate_spec.rb +0 -15
- data/spec/timed_trace_spec.rb +0 -127
- data/spec/truncator_spec.rb +0 -267
@@ -1,151 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Config::Processor do
|
2
|
-
let(:notifier) { Airbrake::NoticeNotifier.new }
|
3
|
-
|
4
|
-
describe "#process_blocklist" do
|
5
|
-
let(:config) { Airbrake::Config.new(blocklist_keys: %w[a b c]) }
|
6
|
-
|
7
|
-
context "when there ARE blocklist keys" do
|
8
|
-
it "adds the blocklist filter" do
|
9
|
-
described_class.new(config).process_blocklist(notifier)
|
10
|
-
expect(notifier.has_filter?(Airbrake::Filters::KeysBlocklist)).to eq(true)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when there are NO blocklist keys" do
|
15
|
-
let(:config) { Airbrake::Config.new(blocklist_keys: %w[]) }
|
16
|
-
|
17
|
-
it "doesn't add the blocklist filter" do
|
18
|
-
described_class.new(config).process_blocklist(notifier)
|
19
|
-
expect(notifier.has_filter?(Airbrake::Filters::KeysBlocklist))
|
20
|
-
.to eq(false)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "#process_allowlist" do
|
26
|
-
let(:config) { Airbrake::Config.new(allowlist_keys: %w[a b c]) }
|
27
|
-
|
28
|
-
context "when there ARE allowlist keys" do
|
29
|
-
it "adds the allowlist filter" do
|
30
|
-
described_class.new(config).process_allowlist(notifier)
|
31
|
-
expect(notifier.has_filter?(Airbrake::Filters::KeysAllowlist)).to eq(true)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "when there are NO allowlist keys" do
|
36
|
-
let(:config) { Airbrake::Config.new(allowlist_keys: %w[]) }
|
37
|
-
|
38
|
-
it "doesn't add the allowlist filter" do
|
39
|
-
described_class.new(config).process_allowlist(notifier)
|
40
|
-
expect(notifier.has_filter?(Airbrake::Filters::KeysAllowlist))
|
41
|
-
.to eq(false)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "#process_remote_configuration" do
|
47
|
-
before do
|
48
|
-
allow(Airbrake::RemoteSettings).to receive(:poll)
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when the config doesn't define a project_id" do
|
52
|
-
let(:config) { Airbrake::Config.new(project_id: nil) }
|
53
|
-
|
54
|
-
it "doesn't set remote settings" do
|
55
|
-
described_class.new(config).process_remote_configuration
|
56
|
-
|
57
|
-
expect(Airbrake::RemoteSettings).not_to have_received(:poll)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "when the config sets environment to 'test'" do
|
62
|
-
let(:config) { Airbrake::Config.new(project_id: 123, environment: 'test') }
|
63
|
-
|
64
|
-
it "doesn't set remote settings" do
|
65
|
-
described_class.new(config).process_remote_configuration
|
66
|
-
|
67
|
-
expect(Airbrake::RemoteSettings).not_to have_received(:poll)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "when the config defines a project_id" do
|
72
|
-
let(:config) do
|
73
|
-
Airbrake::Config.new(project_id: 123, environment: 'not-test')
|
74
|
-
end
|
75
|
-
|
76
|
-
it "sets remote settings" do
|
77
|
-
described_class.new(config).process_remote_configuration
|
78
|
-
|
79
|
-
expect(Airbrake::RemoteSettings).to have_received(:poll)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context "when the config disables the remote_config option" do
|
84
|
-
let(:config) { Airbrake::Config.new(project_id: 123, remote_config: false) }
|
85
|
-
|
86
|
-
it "doesn't set remote settings" do
|
87
|
-
described_class.new(config).process_remote_configuration
|
88
|
-
|
89
|
-
expect(Airbrake::RemoteSettings).not_to have_received(:poll)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "#add_filters" do
|
95
|
-
context "when there's a root directory" do
|
96
|
-
let(:config) { Airbrake::Config.new(root_directory: '/abc') }
|
97
|
-
|
98
|
-
it "adds RootDirectoryFilter" do
|
99
|
-
described_class.new(config).add_filters(notifier)
|
100
|
-
expect(notifier.has_filter?(Airbrake::Filters::RootDirectoryFilter))
|
101
|
-
.to eq(true)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "adds GitRevisionFilter" do
|
105
|
-
described_class.new(config).add_filters(notifier)
|
106
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitRevisionFilter))
|
107
|
-
.to eq(true)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "adds GitRepositoryFilter" do
|
111
|
-
described_class.new(config).add_filters(notifier)
|
112
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitRepositoryFilter))
|
113
|
-
.to eq(true)
|
114
|
-
end
|
115
|
-
|
116
|
-
it "adds GitLastCheckoutFilter" do
|
117
|
-
described_class.new(config).add_filters(notifier)
|
118
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitLastCheckoutFilter))
|
119
|
-
.to eq(true)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context "when there's NO root directory" do
|
124
|
-
let(:config) { Airbrake::Config.new(root_directory: nil) }
|
125
|
-
|
126
|
-
it "doesn't add RootDirectoryFilter" do
|
127
|
-
described_class.new(config).add_filters(notifier)
|
128
|
-
expect(notifier.has_filter?(Airbrake::Filters::RootDirectoryFilter))
|
129
|
-
.to eq(false)
|
130
|
-
end
|
131
|
-
|
132
|
-
it "doesn't add GitRevisionFilter" do
|
133
|
-
described_class.new(config).add_filters(notifier)
|
134
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitRevisionFilter))
|
135
|
-
.to eq(false)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "doesn't add GitRepositoryFilter" do
|
139
|
-
described_class.new(config).add_filters(notifier)
|
140
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitRepositoryFilter))
|
141
|
-
.to eq(false)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "doesn't add GitLastCheckoutFilter" do
|
145
|
-
described_class.new(config).add_filters(notifier)
|
146
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitLastCheckoutFilter))
|
147
|
-
.to eq(false)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
@@ -1,204 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Config::Validator do
|
2
|
-
let(:valid_id) { 123 }
|
3
|
-
let(:valid_key) { '123' }
|
4
|
-
let(:config) { Airbrake::Config.new(config_params) }
|
5
|
-
|
6
|
-
describe ".validate" do
|
7
|
-
context "when project_id is numerical" do
|
8
|
-
let(:config_params) { { project_id: valid_id, project_key: valid_key } }
|
9
|
-
|
10
|
-
it "returns a resolved promise" do
|
11
|
-
promise = described_class.validate(config)
|
12
|
-
expect(promise).to be_resolved
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "when project_id is a numerical String" do
|
17
|
-
let(:config_params) { { project_id: '123', project_key: valid_key } }
|
18
|
-
|
19
|
-
it "returns a resolved promise" do
|
20
|
-
promise = described_class.validate(config)
|
21
|
-
expect(promise).to be_resolved
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "when project_id is zero" do
|
26
|
-
let(:config_params) { { project_id: 0, project_key: valid_key } }
|
27
|
-
|
28
|
-
it "returns a rejected promise" do
|
29
|
-
promise = described_class.validate(config)
|
30
|
-
expect(promise.value).to eq('error' => ':project_id is required')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "when project_id consists of letters" do
|
35
|
-
let(:config_params) { { project_id: 'foo', project_key: valid_key } }
|
36
|
-
|
37
|
-
it "returns a rejected promise" do
|
38
|
-
promise = described_class.validate(config)
|
39
|
-
expect(promise.value).to eq('error' => ':project_id is required')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "when project_id is less than zero" do
|
44
|
-
let(:config_params) { { project_id: -123, project_key: valid_key } }
|
45
|
-
|
46
|
-
it "returns a rejected promise" do
|
47
|
-
promise = described_class.validate(config)
|
48
|
-
expect(promise.value).to eq('error' => ':project_id is required')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when project_key is a non-empty String" do
|
53
|
-
let(:config_params) { { project_id: valid_id, project_key: '123' } }
|
54
|
-
|
55
|
-
it "returns a resolved promise" do
|
56
|
-
promise = described_class.validate(config)
|
57
|
-
expect(promise).to be_resolved
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "when project_key is an empty String" do
|
62
|
-
let(:config_params) { { project_id: valid_id, project_key: '' } }
|
63
|
-
|
64
|
-
it "returns a rejected promise" do
|
65
|
-
promise = described_class.validate(config)
|
66
|
-
expect(promise.value).to eq('error' => ':project_key is required')
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when project_key is a non-String" do
|
71
|
-
let(:config_params) { { project_id: valid_id, project_key: 123 } }
|
72
|
-
|
73
|
-
it "returns a rejected promise" do
|
74
|
-
promise = described_class.validate(config)
|
75
|
-
expect(promise.value).to eq('error' => ':project_key is required')
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "when environment is nil" do
|
80
|
-
let(:config_params) do
|
81
|
-
{ project_id: valid_id, project_key: valid_key, environment: nil }
|
82
|
-
end
|
83
|
-
|
84
|
-
it "returns a resolved promise" do
|
85
|
-
promise = described_class.validate(config)
|
86
|
-
expect(promise).to be_resolved
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context "when environment is a String" do
|
91
|
-
let(:config_params) do
|
92
|
-
{ project_id: valid_id, project_key: valid_key, environment: 'test' }
|
93
|
-
end
|
94
|
-
|
95
|
-
it "returns a resolved promise" do
|
96
|
-
promise = described_class.validate(config)
|
97
|
-
expect(promise).to be_resolved
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "when environment is a Symbol" do
|
102
|
-
let(:config_params) do
|
103
|
-
{ project_id: valid_id, project_key: valid_key, environment: :test }
|
104
|
-
end
|
105
|
-
|
106
|
-
it "returns a resolved promise" do
|
107
|
-
promise = described_class.validate(config)
|
108
|
-
expect(promise).to be_resolved
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context "when environment is non-String and non-Symbol" do
|
113
|
-
let(:config_params) do
|
114
|
-
{ project_id: valid_id, project_key: valid_key, environment: 1.0 }
|
115
|
-
end
|
116
|
-
|
117
|
-
it "returns a rejected promise" do
|
118
|
-
promise = described_class.validate(config)
|
119
|
-
expect(promise.value).to eq(
|
120
|
-
'error' => "the 'environment' option must be configured with a " \
|
121
|
-
"Symbol (or String), but 'Float' was provided: 1.0",
|
122
|
-
)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context "when environment is String-like" do
|
127
|
-
let(:string_inquirer) { Class.new(String) }
|
128
|
-
|
129
|
-
let(:config_params) do
|
130
|
-
{
|
131
|
-
project_id: valid_id,
|
132
|
-
project_key: valid_key,
|
133
|
-
environment: string_inquirer.new('test'),
|
134
|
-
}
|
135
|
-
end
|
136
|
-
|
137
|
-
it "returns a resolved promise" do
|
138
|
-
promise = described_class.validate(config)
|
139
|
-
expect(promise).to be_resolved
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe "#check_notify_ability" do
|
145
|
-
context "when current environment is ignored" do
|
146
|
-
let(:config_params) do
|
147
|
-
{
|
148
|
-
project_id: valid_id,
|
149
|
-
project_key: valid_key,
|
150
|
-
environment: 'test',
|
151
|
-
ignore_environments: ['test'],
|
152
|
-
}
|
153
|
-
end
|
154
|
-
|
155
|
-
it "returns a rejected promise" do
|
156
|
-
promise = described_class.check_notify_ability(config)
|
157
|
-
expect(promise.value).to eq(
|
158
|
-
'error' => "current environment 'test' is ignored",
|
159
|
-
)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context "when no environment is specified but ignore_environments is" do
|
164
|
-
let(:config_params) do
|
165
|
-
{
|
166
|
-
project_id: valid_id,
|
167
|
-
project_key: valid_key,
|
168
|
-
ignore_environments: ['test'],
|
169
|
-
}
|
170
|
-
end
|
171
|
-
|
172
|
-
it "returns a resolved promise" do
|
173
|
-
promise = described_class.check_notify_ability(config)
|
174
|
-
expect(promise).to be_resolved
|
175
|
-
end
|
176
|
-
|
177
|
-
it "warns about 'no effect'" do
|
178
|
-
allow(config.logger).to receive(:warn)
|
179
|
-
|
180
|
-
described_class.check_notify_ability(config)
|
181
|
-
|
182
|
-
expect(config.logger).to have_received(:warn)
|
183
|
-
.with(/'ignore_environments' has no effect/)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
context "when the error_notifications option is false" do
|
188
|
-
let(:config_params) do
|
189
|
-
{
|
190
|
-
project_id: valid_id,
|
191
|
-
project_key: valid_key,
|
192
|
-
error_notifications: false,
|
193
|
-
}
|
194
|
-
end
|
195
|
-
|
196
|
-
it "returns a rejected promise" do
|
197
|
-
promise = described_class.check_notify_ability(config)
|
198
|
-
expect(promise.value).to eq(
|
199
|
-
'error' => "error notifications are disabled",
|
200
|
-
)
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
data/spec/config_spec.rb
DELETED
@@ -1,188 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Config do
|
2
|
-
subject(:config) { described_class.new }
|
3
|
-
|
4
|
-
let(:resolved_promise) { Airbrake::Promise.new.resolve }
|
5
|
-
let(:rejected_promise) { Airbrake::Promise.new.reject }
|
6
|
-
|
7
|
-
let(:valid_params) { { project_id: 1, project_key: '2' } }
|
8
|
-
|
9
|
-
its(:project_id) { is_expected.to be_nil }
|
10
|
-
its(:project_key) { is_expected.to be_nil }
|
11
|
-
its(:logger) { is_expected.to be_a(Logger) }
|
12
|
-
its(:app_version) { is_expected.to be_nil }
|
13
|
-
its(:versions) { is_expected.to be_empty }
|
14
|
-
its(:host) { is_expected.to eq('https://api.airbrake.io') }
|
15
|
-
its(:error_host) { is_expected.to eq('https://api.airbrake.io') }
|
16
|
-
its(:apm_host) { is_expected.to eq('https://api.airbrake.io') }
|
17
|
-
its(:error_endpoint) { is_expected.not_to be_nil }
|
18
|
-
its(:workers) { is_expected.to eq(1) }
|
19
|
-
its(:queue_size) { is_expected.to eq(100) }
|
20
|
-
its(:root_directory) { is_expected.to eq(Bundler.root.realpath.to_s) }
|
21
|
-
its(:environment) { is_expected.to be_nil }
|
22
|
-
its(:ignore_environments) { is_expected.to be_empty }
|
23
|
-
its(:timeout) { is_expected.to be_nil }
|
24
|
-
its(:blocklist_keys) { is_expected.to be_empty }
|
25
|
-
its(:allowlist_keys) { is_expected.to be_empty }
|
26
|
-
its(:performance_stats) { is_expected.to eq(true) }
|
27
|
-
its(:performance_stats_flush_period) { is_expected.to eq(15) }
|
28
|
-
its(:query_stats) { is_expected.to eq(true) }
|
29
|
-
its(:job_stats) { is_expected.to eq(true) }
|
30
|
-
its(:error_notifications) { is_expected.to eq(true) }
|
31
|
-
its(:remote_config) { is_expected.to eq(true) }
|
32
|
-
|
33
|
-
its(:remote_config_host) do
|
34
|
-
is_expected.to eq('https://notifier-configs.airbrake.io')
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#new" do
|
38
|
-
context "when user config is passed" do
|
39
|
-
subject { described_class.new(logger: StringIO.new) }
|
40
|
-
|
41
|
-
its(:logger) { is_expected.to be_a(StringIO) }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#valid?" do
|
46
|
-
context "when the config is valid" do
|
47
|
-
before do
|
48
|
-
config.project_id = 123
|
49
|
-
config.project_key = 'abc'
|
50
|
-
end
|
51
|
-
|
52
|
-
it { is_expected.to be_valid }
|
53
|
-
end
|
54
|
-
|
55
|
-
context "when the config is invalid" do
|
56
|
-
it { is_expected.not_to be_valid }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#ignored_environment?" do
|
61
|
-
context "when Validator returns a resolved promise" do
|
62
|
-
before do
|
63
|
-
allow(Airbrake::Config::Validator).to receive(:check_notify_ability)
|
64
|
-
.and_return(resolved_promise)
|
65
|
-
end
|
66
|
-
|
67
|
-
its(:ignored_environment?) { is_expected.to be_falsey }
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when Validator returns a rejected promise" do
|
71
|
-
before do
|
72
|
-
allow(Airbrake::Config::Validator).to receive(:check_notify_ability)
|
73
|
-
.and_return(rejected_promise)
|
74
|
-
end
|
75
|
-
|
76
|
-
its(:ignored_environment?) { is_expected.to be_truthy }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "#error_endpoint" do
|
81
|
-
subject { described_class.new(valid_params.merge(user_config)) }
|
82
|
-
|
83
|
-
context "when host ends with a URL with a slug with a trailing slash" do
|
84
|
-
let(:user_config) { { host: 'https://localhost/bingo/' } }
|
85
|
-
|
86
|
-
its(:error_endpoint) do
|
87
|
-
is_expected.to eq(URI('https://localhost/bingo/api/v3/projects/1/notices'))
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context "when host ends with a URL with a slug without a trailing slash" do
|
92
|
-
let(:user_config) { { host: 'https://localhost/bingo' } }
|
93
|
-
|
94
|
-
its(:error_endpoint) do
|
95
|
-
is_expected.to eq(URI('https://localhost/api/v3/projects/1/notices'))
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "#validate" do
|
101
|
-
its(:validate) { is_expected.to be_an(Airbrake::Promise) }
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "#check_configuration" do
|
105
|
-
subject { described_class.new(valid_params.merge(user_config)) }
|
106
|
-
|
107
|
-
let(:user_config) { {} }
|
108
|
-
|
109
|
-
its(:check_configuration) { is_expected.to be_an(Airbrake::Promise) }
|
110
|
-
|
111
|
-
context "when config is invalid" do
|
112
|
-
let(:user_config) { { project_id: nil } }
|
113
|
-
|
114
|
-
its(:check_configuration) { is_expected.to be_rejected }
|
115
|
-
end
|
116
|
-
|
117
|
-
context "when current environment is ignored" do
|
118
|
-
let(:user_config) { { environment: 'test', ignore_environments: ['test'] } }
|
119
|
-
|
120
|
-
its(:check_configuration) { is_expected.to be_rejected }
|
121
|
-
end
|
122
|
-
|
123
|
-
context "when config is valid and allows notifying" do
|
124
|
-
its(:check_configuration) { is_expected.not_to be_rejected }
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "#check_performance_options" do
|
129
|
-
it "returns a promise" do
|
130
|
-
resource = Airbrake::Query.new(method: '', route: '', query: '', timing: 1)
|
131
|
-
expect(config.check_performance_options(resource))
|
132
|
-
.to be_an(Airbrake::Promise)
|
133
|
-
end
|
134
|
-
|
135
|
-
context "when performance stats are disabled" do
|
136
|
-
before { config.performance_stats = false }
|
137
|
-
|
138
|
-
let(:resource) do
|
139
|
-
Airbrake::Request.new(
|
140
|
-
method: 'GET', route: '/foo', status_code: 200, timing: 1,
|
141
|
-
)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "returns a rejected promise" do
|
145
|
-
promise = config.check_performance_options(resource)
|
146
|
-
expect(promise.value).to eq(
|
147
|
-
'error' => "The Performance Stats feature is disabled",
|
148
|
-
)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
context "when query stats are disabled" do
|
153
|
-
before { config.query_stats = false }
|
154
|
-
|
155
|
-
let(:resource) do
|
156
|
-
Airbrake::Query.new(method: 'GET', route: '/foo', query: '', timing: 1)
|
157
|
-
end
|
158
|
-
|
159
|
-
it "returns a rejected promise" do
|
160
|
-
promise = config.check_performance_options(resource)
|
161
|
-
expect(promise.value).to eq(
|
162
|
-
'error' => "The Query Stats feature is disabled",
|
163
|
-
)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
context "when job stats are disabled" do
|
168
|
-
before { config.job_stats = false }
|
169
|
-
|
170
|
-
let(:resource) do
|
171
|
-
Airbrake::Queue.new(queue: 'foo_queue', error_count: 0, timing: 1)
|
172
|
-
end
|
173
|
-
|
174
|
-
it "returns a rejected promise" do
|
175
|
-
promise = config.check_performance_options(resource)
|
176
|
-
expect(promise.value).to eq(
|
177
|
-
'error' => "The Job Stats feature is disabled",
|
178
|
-
)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
describe "#logger" do
|
184
|
-
it "sets logger level to Logger::WARN" do
|
185
|
-
expect(config.logger.level).to eq(Logger::WARN)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
data/spec/context_spec.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Context do
|
2
|
-
subject(:context) { described_class.current }
|
3
|
-
|
4
|
-
before { described_class.current.clear }
|
5
|
-
|
6
|
-
after { described_class.current.clear }
|
7
|
-
|
8
|
-
describe "#merge!" do
|
9
|
-
it "merges the given context with the current one" do
|
10
|
-
context.merge!(apples: 'oranges')
|
11
|
-
expect(context.to_h).to match(apples: 'oranges')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#clear" do
|
16
|
-
it "clears the context" do
|
17
|
-
context.merge!(apples: 'oranges')
|
18
|
-
context.clear
|
19
|
-
expect(context.to_h).to be_empty
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#to_h" do
|
24
|
-
it "returns a hash representation of the context" do
|
25
|
-
expect(context.to_h).to be_a(Hash)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#empty?" do
|
30
|
-
context "when the context has data" do
|
31
|
-
it "returns true" do
|
32
|
-
context.merge!(apples: 'oranges')
|
33
|
-
expect(context).not_to be_empty
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when the context has NO data" do
|
38
|
-
it "returns false" do
|
39
|
-
expect(context).to be_empty
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "when another thread is spawned" do
|
45
|
-
it "doesn't clash with other threads' contexts" do
|
46
|
-
described_class.current.merge!(apples: 'oranges')
|
47
|
-
th = Thread.new do
|
48
|
-
described_class.current.merge!(foos: 'bars')
|
49
|
-
end
|
50
|
-
th.join
|
51
|
-
expect(described_class.current.to_h).to match(apples: 'oranges')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::DeployNotifier do
|
2
|
-
before do
|
3
|
-
Airbrake::Config.instance = Airbrake::Config.new(project_id: 1, project_key: '123')
|
4
|
-
end
|
5
|
-
|
6
|
-
describe "#notify" do
|
7
|
-
subject(:deploy_notifier) { described_class.new }
|
8
|
-
|
9
|
-
it "returns a promise" do
|
10
|
-
stub_request(:post, 'https://api.airbrake.io/api/v4/projects/1/deploys')
|
11
|
-
.to_return(status: 201, body: '{}')
|
12
|
-
expect(deploy_notifier.notify({})).to be_an(Airbrake::Promise)
|
13
|
-
end
|
14
|
-
|
15
|
-
context "when config is invalid" do
|
16
|
-
before { Airbrake::Config.instance.merge(project_id: nil) }
|
17
|
-
|
18
|
-
it "returns a rejected promise" do
|
19
|
-
promise = deploy_notifier.notify({})
|
20
|
-
expect(promise).to be_rejected
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when environment is configured" do
|
25
|
-
before { Airbrake::Config.instance.merge(environment: 'fooenv') }
|
26
|
-
|
27
|
-
it "prefers the passed environment to the config env" do
|
28
|
-
expect_any_instance_of(Airbrake::SyncSender).to receive(:send).with(
|
29
|
-
{ environment: 'barenv' },
|
30
|
-
instance_of(Airbrake::Promise),
|
31
|
-
URI('https://api.airbrake.io/api/v4/projects/1/deploys'),
|
32
|
-
)
|
33
|
-
deploy_notifier.notify(environment: 'barenv')
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when environment is not configured" do
|
38
|
-
before { Airbrake::Config.instance.merge(environment: 'fooenv') }
|
39
|
-
|
40
|
-
it "sets the environment from the config" do
|
41
|
-
expect_any_instance_of(Airbrake::SyncSender).to receive(:send).with(
|
42
|
-
{ environment: 'fooenv' },
|
43
|
-
instance_of(Airbrake::Promise),
|
44
|
-
URI('https://api.airbrake.io/api/v4/projects/1/deploys'),
|
45
|
-
)
|
46
|
-
deploy_notifier.notify({})
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/spec/file_cache_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::FileCache do
|
2
|
-
before { described_class.reset }
|
3
|
-
|
4
|
-
after { described_class.reset }
|
5
|
-
|
6
|
-
describe ".[]=" do
|
7
|
-
context "when cache limit isn't reached" do
|
8
|
-
before do
|
9
|
-
stub_const("#{described_class.name}::MAX_SIZE", 10)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "adds objects" do
|
13
|
-
described_class[:banana] = 1
|
14
|
-
described_class[:mango] = 2
|
15
|
-
|
16
|
-
expect(described_class[:banana]).to eq(1)
|
17
|
-
expect(described_class[:mango]).to eq(2)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "when cache limit is reached" do
|
22
|
-
before do
|
23
|
-
stub_const("#{described_class.name}::MAX_SIZE", 1)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "replaces old objects with new ones" do
|
27
|
-
described_class[:banana] = 1
|
28
|
-
described_class[:mango] = 2
|
29
|
-
|
30
|
-
expect(described_class[:banana]).to be_nil
|
31
|
-
expect(described_class[:mango]).to eq(2)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|