airbrake-ruby 6.1.0-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/filters/git_last_checkout_filter.rb +1 -1
- data/lib/airbrake-ruby/nested_exception.rb +10 -1
- data/lib/airbrake-ruby/notice.rb +5 -3
- data/lib/airbrake-ruby/version.rb +1 -1
- metadata +4 -122
- 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 -167
- 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_spec.rb +0 -72
- 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 -30
- data/spec/timed_trace_spec.rb +0 -127
- data/spec/truncator_spec.rb +0 -267
@@ -1,167 +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 be(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 be(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 be(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 be(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 sets :ignore_environments and :environment matches" do
|
72
|
-
let(:config) do
|
73
|
-
Airbrake::Config.new(
|
74
|
-
project_id: 123,
|
75
|
-
ignore_environments: %w[dev],
|
76
|
-
environment: 'dev',
|
77
|
-
)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "doesn't set remote settings" do
|
81
|
-
described_class.new(config).process_remote_configuration
|
82
|
-
|
83
|
-
expect(Airbrake::RemoteSettings).not_to have_received(:poll)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
context "when the config defines a project_id" do
|
88
|
-
let(:config) do
|
89
|
-
Airbrake::Config.new(project_id: 123, environment: 'not-test')
|
90
|
-
end
|
91
|
-
|
92
|
-
it "sets remote settings" do
|
93
|
-
described_class.new(config).process_remote_configuration
|
94
|
-
|
95
|
-
expect(Airbrake::RemoteSettings).to have_received(:poll)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context "when the config disables the remote_config option" do
|
100
|
-
let(:config) { Airbrake::Config.new(project_id: 123, remote_config: false) }
|
101
|
-
|
102
|
-
it "doesn't set remote settings" do
|
103
|
-
described_class.new(config).process_remote_configuration
|
104
|
-
|
105
|
-
expect(Airbrake::RemoteSettings).not_to have_received(:poll)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "#add_filters" do
|
111
|
-
context "when there's a root directory" do
|
112
|
-
let(:config) { Airbrake::Config.new(root_directory: '/abc') }
|
113
|
-
|
114
|
-
it "adds RootDirectoryFilter" do
|
115
|
-
described_class.new(config).add_filters(notifier)
|
116
|
-
expect(notifier.has_filter?(Airbrake::Filters::RootDirectoryFilter))
|
117
|
-
.to be(true)
|
118
|
-
end
|
119
|
-
|
120
|
-
it "adds GitRevisionFilter" do
|
121
|
-
described_class.new(config).add_filters(notifier)
|
122
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitRevisionFilter))
|
123
|
-
.to be(true)
|
124
|
-
end
|
125
|
-
|
126
|
-
it "adds GitRepositoryFilter" do
|
127
|
-
described_class.new(config).add_filters(notifier)
|
128
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitRepositoryFilter))
|
129
|
-
.to be(true)
|
130
|
-
end
|
131
|
-
|
132
|
-
it "adds GitLastCheckoutFilter" do
|
133
|
-
described_class.new(config).add_filters(notifier)
|
134
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitLastCheckoutFilter))
|
135
|
-
.to be(true)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context "when there's NO root directory" do
|
140
|
-
let(:config) { Airbrake::Config.new(root_directory: nil) }
|
141
|
-
|
142
|
-
it "doesn't add RootDirectoryFilter" do
|
143
|
-
described_class.new(config).add_filters(notifier)
|
144
|
-
expect(notifier.has_filter?(Airbrake::Filters::RootDirectoryFilter))
|
145
|
-
.to be(false)
|
146
|
-
end
|
147
|
-
|
148
|
-
it "doesn't add GitRevisionFilter" do
|
149
|
-
described_class.new(config).add_filters(notifier)
|
150
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitRevisionFilter))
|
151
|
-
.to be(false)
|
152
|
-
end
|
153
|
-
|
154
|
-
it "doesn't add GitRepositoryFilter" do
|
155
|
-
described_class.new(config).add_filters(notifier)
|
156
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitRepositoryFilter))
|
157
|
-
.to be(false)
|
158
|
-
end
|
159
|
-
|
160
|
-
it "doesn't add GitLastCheckoutFilter" do
|
161
|
-
described_class.new(config).add_filters(notifier)
|
162
|
-
expect(notifier.has_filter?(Airbrake::Filters::GitLastCheckoutFilter))
|
163
|
-
.to be(false)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
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 be(true) }
|
27
|
-
its(:performance_stats_flush_period) { is_expected.to eq(15) }
|
28
|
-
its(:query_stats) { is_expected.to be(true) }
|
29
|
-
its(:job_stats) { is_expected.to be(true) }
|
30
|
-
its(:error_notifications) { is_expected.to be(true) }
|
31
|
-
its(:remote_config) { is_expected.to be(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
|
-
metric = Airbrake::Query.new(method: '', route: '', query: '', timing: 1)
|
131
|
-
expect(config.check_performance_options(metric))
|
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(:metric) 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(metric)
|
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(:metric) 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(metric)
|
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(:metric) 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(metric)
|
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
|