-
Notifications
You must be signed in to change notification settings - Fork 57
/
configuration_spec.rb
65 lines (53 loc) · 1.82 KB
/
configuration_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'spec_helper'
describe HealthMonitor::Configuration do
describe 'defaults' do
it { expect(subject.providers).to eq(Set.new([HealthMonitor::Providers::Database])) }
it { expect(subject.error_callback).to be_nil }
it { expect(subject.basic_auth_credentials).to be_nil }
end
describe 'providers' do
HealthMonitor::Configuration::PROVIDERS.each do |provider_name|
before do
subject.instance_variable_set('@providers', Set.new)
stub_const("HealthMonitor::Providers::#{provider_name.capitalize}", Class.new)
end
it "responds to #{provider_name}" do
expect(subject).to respond_to(provider_name)
end
it "configures #{provider_name}" do
expect {
subject.send(provider_name)
}.to change { subject.providers }.to(Set.new(["HealthMonitor::Providers::#{provider_name.capitalize}".constantize]))
end
it "returns #{provider_name}'s class" do
expect(subject.send(provider_name)).to eq("HealthMonitor::Providers::#{provider_name.capitalize}".constantize)
end
end
end
describe '#add_custom_provider' do
before do
subject.instance_variable_set('@providers', Set.new)
end
context 'inherits' do
class CustomProvider < HealthMonitor::Providers::Base
end
it 'accepts' do
expect {
subject.add_custom_provider(CustomProvider)
}.to change { subject.providers }.to(Set.new([CustomProvider]))
end
it "returns CustomProvider class" do
expect(subject.add_custom_provider(CustomProvider)).to eq(CustomProvider)
end
end
context 'does not inherit' do
class TestClass
end
it 'does not accept' do
expect {
subject.add_custom_provider(TestClass)
}.to raise_error(ArgumentError)
end
end
end
end