airbrake-ruby 4.0.1 → 4.1.0
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.rb +7 -71
- data/lib/airbrake-ruby/config.rb +19 -22
- data/lib/airbrake-ruby/config/validator.rb +71 -43
- data/lib/airbrake-ruby/deploy_notifier.rb +4 -4
- data/lib/airbrake-ruby/notice_notifier.rb +3 -4
- data/lib/airbrake-ruby/performance_notifier.rb +4 -5
- data/lib/airbrake-ruby/promise.rb +30 -20
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/airbrake_spec.rb +4 -4
- data/spec/backtrace_spec.rb +4 -4
- data/spec/config/validator_spec.rb +128 -133
- data/spec/config_spec.rb +72 -227
- data/spec/deploy_notifier_spec.rb +14 -3
- data/spec/filters/git_repository_filter.rb +6 -6
- data/spec/notice_notifier_spec.rb +11 -4
- data/spec/notice_notifier_spec/options_spec.rb +12 -12
- data/spec/notice_spec.rb +24 -24
- data/spec/performance_notifier_spec.rb +10 -1
- data/spec/promise_spec.rb +32 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/sync_sender_spec.rb +4 -4
- data/spec/tdigest_spec.rb +2 -2
- data/spec/truncator_spec.rb +2 -2
- metadata +2 -2
data/spec/airbrake_spec.rb
CHANGED
@@ -25,15 +25,15 @@ RSpec.describe Airbrake do
|
|
25
25
|
|
26
26
|
context "when user config doesn't contain a project id" do
|
27
27
|
it "raises error" do
|
28
|
-
expect { described_class.configure { |c| c.project_key = '1' } }
|
29
|
-
to raise_error(Airbrake::Error, ':project_id is required')
|
28
|
+
expect { described_class.configure { |c| c.project_key = '1' } }
|
29
|
+
.to raise_error(Airbrake::Error, ':project_id is required')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "when user config doesn't contain a project key" do
|
34
34
|
it "raises error" do
|
35
|
-
expect { described_class.configure { |c| c.project_id = 1 } }
|
36
|
-
to raise_error(Airbrake::Error, ':project_key is required')
|
35
|
+
expect { described_class.configure { |c| c.project_id = 1 } }
|
36
|
+
.to raise_error(Airbrake::Error, ':project_key is required')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/spec/backtrace_spec.rb
CHANGED
@@ -20,8 +20,8 @@ RSpec.describe Airbrake::Backtrace do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "returns a properly formatted array of hashes" do
|
23
|
-
expect(described_class.parse(AirbrakeTestError.new))
|
24
|
-
to eq(parsed_backtrace)
|
23
|
+
expect(described_class.parse(AirbrakeTestError.new))
|
24
|
+
.to eq(parsed_backtrace)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -65,8 +65,8 @@ RSpec.describe Airbrake::Backtrace do
|
|
65
65
|
it "returns a properly formatted array of hashes" do
|
66
66
|
allow(described_class).to receive(:java_exception?).and_return(true)
|
67
67
|
|
68
|
-
expect(described_class.parse(JavaAirbrakeTestError.new))
|
69
|
-
to eq(backtrace_array)
|
68
|
+
expect(described_class.parse(JavaAirbrakeTestError.new))
|
69
|
+
.to eq(backtrace_array)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -1,188 +1,183 @@
|
|
1
1
|
RSpec.describe Airbrake::Config::Validator do
|
2
|
-
|
2
|
+
let(:valid_id) { 123 }
|
3
|
+
let(:valid_key) { '123' }
|
4
|
+
let(:config) { Airbrake::Config.new(config_params) }
|
3
5
|
|
4
|
-
describe "
|
5
|
-
context "when
|
6
|
-
let(:
|
6
|
+
describe ".validate" do
|
7
|
+
context "when project_id is numerical" do
|
8
|
+
let(:config_params) { { project_id: valid_id, project_key: valid_key } }
|
7
9
|
|
8
|
-
it "returns
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
it "sets correct error message" do
|
13
|
-
expect { subject.valid_project_id? }.to(
|
14
|
-
change { subject.error_message }.to(/:project_id is required/)
|
15
|
-
)
|
10
|
+
it "returns a resolved promise" do
|
11
|
+
promise = described_class.validate(config)
|
12
|
+
expect(promise).to be_resolved
|
16
13
|
end
|
17
14
|
end
|
18
15
|
|
19
|
-
context "when project_id is a String" do
|
20
|
-
let(:
|
16
|
+
context "when project_id is a numerical String" do
|
17
|
+
let(:config_params) { { project_id: '123', project_key: valid_key } }
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
it "sets correct error message" do
|
28
|
-
expect { subject.valid_project_id? }.
|
29
|
-
to(
|
30
|
-
change { subject.error_message }.to(/:project_id is required/)
|
31
|
-
)
|
32
|
-
end
|
19
|
+
it "returns a resolved promise" do
|
20
|
+
promise = described_class.validate(config)
|
21
|
+
expect(promise).to be_resolved
|
33
22
|
end
|
23
|
+
end
|
34
24
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
it "returns false" do
|
39
|
-
expect(subject.valid_project_id?).to be false
|
40
|
-
end
|
25
|
+
context "when project_id is zero" do
|
26
|
+
let(:config_params) { { project_id: 0, project_key: valid_key } }
|
41
27
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
)
|
46
|
-
end
|
28
|
+
it "returns a rejected promise" do
|
29
|
+
promise = described_class.validate(config)
|
30
|
+
expect(promise.value).to eq('error' => ':project_id is required')
|
47
31
|
end
|
32
|
+
end
|
48
33
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
it "returns true" do
|
53
|
-
expect(subject.valid_project_id?).to be true
|
54
|
-
end
|
34
|
+
context "when project_id consists of letters" do
|
35
|
+
let(:config_params) { { project_id: 'foo', project_key: valid_key } }
|
55
36
|
|
56
|
-
|
57
|
-
|
58
|
-
|
37
|
+
it "returns a rejected promise" do
|
38
|
+
promise = described_class.validate(config)
|
39
|
+
expect(promise.value).to eq('error' => ':project_id is required')
|
59
40
|
end
|
60
41
|
end
|
61
42
|
|
62
|
-
context "when
|
63
|
-
let(:
|
43
|
+
context "when project_id is less than zero" do
|
44
|
+
let(:config_params) { { project_id: -123, project_key: valid_key } }
|
64
45
|
|
65
|
-
it "returns
|
66
|
-
|
46
|
+
it "returns a rejected promise" do
|
47
|
+
promise = described_class.validate(config)
|
48
|
+
expect(promise.value).to eq('error' => ':project_id is required')
|
67
49
|
end
|
50
|
+
end
|
68
51
|
|
69
|
-
|
70
|
-
|
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
|
71
58
|
end
|
72
59
|
end
|
73
|
-
end
|
74
60
|
|
75
|
-
|
76
|
-
|
77
|
-
context "and when it's empty" do
|
78
|
-
let(:config) { Airbrake::Config.new(project_key: '') }
|
61
|
+
context "when project_key is an empty String" do
|
62
|
+
let(:config_params) { { project_id: valid_id, project_key: '' } }
|
79
63
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
it "sets correct error message" do
|
85
|
-
expect { subject.valid_project_key? }.
|
86
|
-
to change { subject.error_message }.
|
87
|
-
to(/:project_key is required/)
|
88
|
-
end
|
64
|
+
it "returns a rejected promise" do
|
65
|
+
promise = described_class.validate(config)
|
66
|
+
expect(promise.value).to eq('error' => ':project_key is required')
|
89
67
|
end
|
68
|
+
end
|
90
69
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
it "returns true" do
|
95
|
-
expect(subject.valid_project_key?).to be true
|
96
|
-
end
|
70
|
+
context "when project_key is a non-String" do
|
71
|
+
let(:config_params) { { project_id: valid_id, project_key: 123 } }
|
97
72
|
|
98
|
-
|
99
|
-
|
100
|
-
|
73
|
+
it "returns a rejected promise" do
|
74
|
+
promise = described_class.validate(config)
|
75
|
+
expect(promise.value).to eq('error' => ':project_key is required')
|
101
76
|
end
|
102
77
|
end
|
103
78
|
|
104
|
-
context "when
|
105
|
-
let(:
|
106
|
-
|
107
|
-
it "returns false" do
|
108
|
-
expect(subject.valid_project_key?).to be false
|
79
|
+
context "when environment is nil" do
|
80
|
+
let(:config_params) do
|
81
|
+
{ project_id: valid_id, project_key: valid_key, environment: nil }
|
109
82
|
end
|
110
83
|
|
111
|
-
it "
|
112
|
-
|
113
|
-
|
114
|
-
)
|
84
|
+
it "returns a resolved promise" do
|
85
|
+
promise = described_class.validate(config)
|
86
|
+
expect(promise).to be_resolved
|
115
87
|
end
|
116
88
|
end
|
117
|
-
end
|
118
89
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
it "returns true" do
|
124
|
-
expect(subject.valid_environment?).to be true
|
90
|
+
context "when environment is a String" do
|
91
|
+
let(:config_params) do
|
92
|
+
{ project_id: valid_id, project_key: valid_key, environment: 'test' }
|
125
93
|
end
|
126
94
|
|
127
|
-
it "
|
128
|
-
|
95
|
+
it "returns a resolved promise" do
|
96
|
+
promise = described_class.validate(config)
|
97
|
+
expect(promise).to be_resolved
|
129
98
|
end
|
130
99
|
end
|
131
100
|
|
132
|
-
context "when
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
it "returns false" do
|
137
|
-
expect(subject.valid_environment?).to be false
|
138
|
-
end
|
139
|
-
|
140
|
-
it "sets the error message" do
|
141
|
-
expect { subject.valid_environment? }.to(
|
142
|
-
change { subject.error_message }.
|
143
|
-
to(/the 'environment' option must be configured with a Symbol/)
|
144
|
-
)
|
145
|
-
end
|
101
|
+
context "when environment is a Symbol" do
|
102
|
+
let(:config_params) do
|
103
|
+
{ project_id: valid_id, project_key: valid_key, environment: :test }
|
146
104
|
end
|
147
105
|
|
148
|
-
|
149
|
-
|
106
|
+
it "returns a resolved promise" do
|
107
|
+
promise = described_class.validate(config)
|
108
|
+
expect(promise).to be_resolved
|
109
|
+
end
|
110
|
+
end
|
150
111
|
|
151
|
-
|
152
|
-
|
153
|
-
|
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
|
154
116
|
|
155
|
-
|
156
|
-
|
157
|
-
|
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
|
+
)
|
158
123
|
end
|
124
|
+
end
|
159
125
|
|
160
|
-
|
161
|
-
|
126
|
+
context "when environment is String-like" do
|
127
|
+
let(:string_inquirer) { Class.new(String) }
|
162
128
|
|
163
|
-
|
164
|
-
|
165
|
-
|
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
|
166
136
|
|
167
|
-
|
168
|
-
|
169
|
-
|
137
|
+
it "returns a resolved promise" do
|
138
|
+
promise = described_class.validate(config)
|
139
|
+
expect(promise).to be_resolved
|
170
140
|
end
|
141
|
+
end
|
142
|
+
end
|
171
143
|
|
172
|
-
|
173
|
-
|
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
|
174
162
|
|
175
|
-
|
176
|
-
|
177
|
-
|
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
|
178
171
|
|
179
|
-
|
180
|
-
|
181
|
-
|
172
|
+
it "returns a rejected promise" do
|
173
|
+
promise = described_class.check_notify_ability(config)
|
174
|
+
expect(promise).to be_resolved
|
175
|
+
end
|
182
176
|
|
183
|
-
|
184
|
-
|
185
|
-
|
177
|
+
it "warns about 'no effect'" do
|
178
|
+
expect(config.logger).to receive(:warn)
|
179
|
+
.with(/'ignore_environments' has no effect/)
|
180
|
+
described_class.check_notify_ability(config)
|
186
181
|
end
|
187
182
|
end
|
188
183
|
end
|
data/spec/config_spec.rb
CHANGED
@@ -1,264 +1,109 @@
|
|
1
1
|
RSpec.describe Airbrake::Config do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
it "sets the default versions" do
|
25
|
-
expect(subject.versions).to be_empty
|
26
|
-
end
|
27
|
-
|
28
|
-
it "sets the default host" do
|
29
|
-
expect(subject.host).to eq('https://api.airbrake.io')
|
30
|
-
end
|
31
|
-
|
32
|
-
it "sets the default endpoint" do
|
33
|
-
expect(subject.endpoint).not_to be_nil
|
34
|
-
end
|
35
|
-
|
36
|
-
it "creates a new Config and merges it with the user config" do
|
37
|
-
config = described_class.new(logger: StringIO.new)
|
38
|
-
expect(config.logger).to be_a(StringIO)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "raises error on unknown config options" do
|
42
|
-
expect { described_class.new(unknown_option: true) }.
|
43
|
-
to raise_error(Airbrake::Error, /unknown option/)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets the default number of workers" do
|
47
|
-
expect(subject.workers).to eq(1)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "sets the default number of queue size" do
|
51
|
-
expect(subject.queue_size).to eq(100)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "sets the default root_directory" do
|
55
|
-
expect(subject.root_directory).to eq Bundler.root.realpath.to_s
|
56
|
-
end
|
57
|
-
|
58
|
-
it "doesn't set the default environment" do
|
59
|
-
expect(subject.environment).to be_nil
|
60
|
-
end
|
61
|
-
|
62
|
-
it "doesn't set default notify_environments" do
|
63
|
-
expect(subject.ignore_environments).to be_empty
|
64
|
-
end
|
65
|
-
|
66
|
-
it "doesn't set default timeout" do
|
67
|
-
expect(subject.timeout).to be_nil
|
68
|
-
end
|
69
|
-
|
70
|
-
it "doesn't set default blacklist" do
|
71
|
-
expect(subject.blacklist_keys).to be_empty
|
72
|
-
end
|
73
|
-
|
74
|
-
it "doesn't set default whitelist" do
|
75
|
-
expect(subject.whitelist_keys).to be_empty
|
76
|
-
end
|
77
|
-
|
78
|
-
it "disables performance stats by default" do
|
79
|
-
expect(subject.performance_stats).to be_falsey
|
80
|
-
end
|
2
|
+
let(:resolved_promise) { Airbrake::Promise.new.resolve }
|
3
|
+
let(:rejected_promise) { Airbrake::Promise.new.reject }
|
4
|
+
|
5
|
+
let(:valid_params) { { project_id: 1, project_key: '2' } }
|
6
|
+
|
7
|
+
its(:project_id) { is_expected.to be_nil }
|
8
|
+
its(:project_key) { is_expected.to be_nil }
|
9
|
+
its(:logger) { is_expected.to be_a(Logger) }
|
10
|
+
its(:app_version) { is_expected.to be_nil }
|
11
|
+
its(:versions) { is_expected.to be_empty }
|
12
|
+
its(:host) { is_expected.to eq('https://api.airbrake.io') }
|
13
|
+
its(:endpoint) { is_expected.not_to be_nil }
|
14
|
+
its(:workers) { is_expected.to eq(1) }
|
15
|
+
its(:queue_size) { is_expected.to eq(100) }
|
16
|
+
its(:root_directory) { is_expected.to eq(Bundler.root.realpath.to_s) }
|
17
|
+
its(:environment) { is_expected.to be_nil }
|
18
|
+
its(:ignore_environments) { is_expected.to be_empty }
|
19
|
+
its(:timeout) { is_expected.to be_nil }
|
20
|
+
its(:blacklist_keys) { is_expected.to be_empty }
|
21
|
+
its(:whitelist_keys) { is_expected.to be_empty }
|
22
|
+
its(:performance_stats) { is_expected.to be_falsey }
|
23
|
+
its(:performance_stats_flush_period) { is_expected.to eq(15) }
|
81
24
|
|
82
|
-
|
83
|
-
|
84
|
-
|
25
|
+
describe "#new" do
|
26
|
+
context "when user config is passed" do
|
27
|
+
subject { described_class.new(logger: StringIO.new) }
|
28
|
+
its(:logger) { is_expected.to be_a(StringIO) }
|
85
29
|
end
|
86
30
|
end
|
87
31
|
|
88
32
|
describe "#valid?" do
|
89
|
-
context "when
|
90
|
-
|
91
|
-
|
92
|
-
project_id: nil,
|
93
|
-
project_key: '123'
|
94
|
-
)
|
95
|
-
expect(config).not_to be_valid
|
96
|
-
end
|
33
|
+
context "when #validate returns a resolved promise" do
|
34
|
+
before { expect(subject).to receive(:validate).and_return(resolved_promise) }
|
35
|
+
it { is_expected.to be_valid }
|
97
36
|
end
|
98
37
|
|
99
|
-
context "when
|
100
|
-
|
101
|
-
|
102
|
-
project_id: 123,
|
103
|
-
project_key: nil
|
104
|
-
)
|
105
|
-
expect(config).not_to be_valid
|
106
|
-
end
|
38
|
+
context "when #validate returns a rejected promise" do
|
39
|
+
before { expect(subject).to receive(:validate).and_return(rejected_promise) }
|
40
|
+
it { is_expected.not_to be_valid }
|
107
41
|
end
|
42
|
+
end
|
108
43
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
project_key: Object.new,
|
115
|
-
environment: :bingo,
|
116
|
-
ignore_environments: [:bingo]
|
117
|
-
)
|
118
|
-
expect(config).to be_valid
|
119
|
-
end
|
44
|
+
describe "#ignored_environment?" do
|
45
|
+
context "when Validator returns a resolved promise" do
|
46
|
+
before do
|
47
|
+
expect(Airbrake::Config::Validator).to receive(:check_notify_ability)
|
48
|
+
.and_return(resolved_promise)
|
120
49
|
end
|
121
50
|
|
122
|
-
|
123
|
-
it "returns true" do
|
124
|
-
config = described_class.new(
|
125
|
-
project_id: 123,
|
126
|
-
project_key: '321',
|
127
|
-
environment: :bingo,
|
128
|
-
ignore_environments: [:bingo]
|
129
|
-
)
|
130
|
-
expect(config).to be_valid
|
131
|
-
end
|
132
|
-
end
|
51
|
+
its(:ignored_environment?) { is_expected.to be_falsey }
|
133
52
|
end
|
134
53
|
|
135
|
-
context "when
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
project_key: '321'
|
140
|
-
)
|
141
|
-
expect(config).not_to be_valid
|
54
|
+
context "when Validator returns a rejected promise" do
|
55
|
+
before do
|
56
|
+
expect(Airbrake::Config::Validator).to receive(:check_notify_ability)
|
57
|
+
.and_return(rejected_promise)
|
142
58
|
end
|
143
|
-
end
|
144
59
|
|
145
|
-
|
146
|
-
it "returns true" do
|
147
|
-
config = described_class.new(
|
148
|
-
project_id: '123',
|
149
|
-
project_key: '321'
|
150
|
-
)
|
151
|
-
expect(config).to be_valid
|
152
|
-
end
|
60
|
+
its(:ignored_environment?) { is_expected.to be_truthy }
|
153
61
|
end
|
62
|
+
end
|
154
63
|
|
155
|
-
|
156
|
-
|
157
|
-
config = described_class.new(
|
158
|
-
project_id: 123,
|
159
|
-
project_key: 321
|
160
|
-
)
|
161
|
-
expect(config).not_to be_valid
|
162
|
-
end
|
163
|
-
end
|
64
|
+
describe "#endpoint" do
|
65
|
+
subject { described_class.new(valid_params.merge(user_config)) }
|
164
66
|
|
165
|
-
context "when
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
)
|
171
|
-
expect(config).not_to be_valid
|
67
|
+
context "when host ends with a URL with a slug with a trailing slash" do
|
68
|
+
let(:user_config) { { host: 'https://localhost/bingo/' } }
|
69
|
+
|
70
|
+
its(:endpoint) do
|
71
|
+
is_expected.to eq(URI('https://localhost/bingo/api/v3/projects/1/notices'))
|
172
72
|
end
|
173
73
|
end
|
174
74
|
|
175
|
-
context "when
|
176
|
-
|
177
|
-
end
|
75
|
+
context "when host ends with a URL with a slug without a trailing slash" do
|
76
|
+
let(:user_config) { { host: 'https://localhost/bingo' } }
|
178
77
|
|
179
|
-
|
180
|
-
|
181
|
-
project_id: 123,
|
182
|
-
project_key: '321',
|
183
|
-
environment: ['bingo']
|
184
|
-
)
|
185
|
-
expect(config).not_to be_valid
|
78
|
+
its(:endpoint) do
|
79
|
+
is_expected.to eq(URI('https://localhost/api/v3/projects/1/notices'))
|
186
80
|
end
|
187
81
|
end
|
188
82
|
end
|
189
83
|
|
190
|
-
describe "#
|
191
|
-
|
192
|
-
|
193
|
-
it "prints a warning" do
|
194
|
-
config = described_class.new(ignore_environments: [:bingo])
|
84
|
+
describe "#validate" do
|
85
|
+
its(:validate) { is_expected.to be_an(Airbrake::Promise) }
|
86
|
+
end
|
195
87
|
|
196
|
-
|
197
|
-
|
198
|
-
)
|
199
|
-
expect(config.ignored_environment?).to be_falsey
|
200
|
-
end
|
201
|
-
end
|
88
|
+
describe "#check_configuration" do
|
89
|
+
let(:user_config) { {} }
|
202
90
|
|
203
|
-
|
204
|
-
it "doesn't print a warning" do
|
205
|
-
config = described_class.new(
|
206
|
-
environment: :bango,
|
207
|
-
ignore_environments: [:bingo]
|
208
|
-
)
|
91
|
+
subject { described_class.new(valid_params.merge(user_config)) }
|
209
92
|
|
210
|
-
|
211
|
-
expect(config.ignored_environment?).to be_falsey
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
93
|
+
its(:check_configuration) { is_expected.to be_an(Airbrake::Promise) }
|
215
94
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
it "returns true" do
|
220
|
-
config = described_class.new(
|
221
|
-
environment: 'bango',
|
222
|
-
ignore_environments: [:bango]
|
223
|
-
)
|
224
|
-
expect(config.ignored_environment?).to be_truthy
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
context "when 'environment' is a Symbol" do
|
230
|
-
context "and when 'ignore_environments' contains Strings" do
|
231
|
-
it "returns true" do
|
232
|
-
config = described_class.new(
|
233
|
-
environment: :bango,
|
234
|
-
ignore_environments: %w[bango]
|
235
|
-
)
|
236
|
-
expect(config.ignored_environment?).to be_truthy
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
95
|
+
context "when config is invalid" do
|
96
|
+
let(:user_config) { { project_id: nil } }
|
97
|
+
its(:check_configuration) { is_expected.to be_rejected }
|
240
98
|
end
|
241
|
-
end
|
242
|
-
|
243
|
-
describe "#endpoint" do
|
244
|
-
context "when host is configured with a URL with a slug" do
|
245
|
-
let(:config) { described_class.new(project_id: 1, project_key: '2') }
|
246
99
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
to eq('https://localhost/bingo/api/v3/projects/1/notices')
|
252
|
-
end
|
253
|
-
end
|
100
|
+
context "when current environment is ignored" do
|
101
|
+
let(:user_config) { { environment: 'test', ignore_environments: ['test'] } }
|
102
|
+
its(:check_configuration) { is_expected.to be_rejected }
|
103
|
+
end
|
254
104
|
|
255
|
-
|
256
|
-
|
257
|
-
config.host = 'https://localhost/bingo'
|
258
|
-
expect(config.endpoint.to_s).
|
259
|
-
to eq('https://localhost/api/v3/projects/1/notices')
|
260
|
-
end
|
261
|
-
end
|
105
|
+
context "when config is valid and allows notifying" do
|
106
|
+
its(:check_configuration) { is_expected.not_to be_rejected }
|
262
107
|
end
|
263
108
|
end
|
264
109
|
end
|