stoplight 3.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +176 -198
- data/lib/stoplight/builder.rb +68 -0
- data/lib/stoplight/circuit_breaker.rb +92 -0
- data/lib/stoplight/configurable.rb +95 -0
- data/lib/stoplight/configuration.rb +126 -0
- data/lib/stoplight/data_store/base.rb +9 -0
- data/lib/stoplight/data_store/memory.rb +46 -5
- data/lib/stoplight/data_store/redis.rb +75 -6
- data/lib/stoplight/default.rb +2 -0
- data/lib/stoplight/error.rb +1 -0
- data/lib/stoplight/light/deprecated.rb +44 -0
- data/lib/stoplight/light/lockable.rb +45 -0
- data/lib/stoplight/light/runnable.rb +34 -16
- data/lib/stoplight/light.rb +69 -63
- data/lib/stoplight/rspec/generic_notifier.rb +42 -0
- data/lib/stoplight/rspec.rb +3 -0
- data/lib/stoplight/version.rb +1 -1
- data/lib/stoplight.rb +33 -10
- data/spec/spec_helper.rb +7 -0
- data/spec/stoplight/builder_spec.rb +165 -0
- data/spec/stoplight/circuit_breaker_spec.rb +35 -0
- data/spec/stoplight/configurable_spec.rb +25 -0
- data/spec/stoplight/data_store/base_spec.rb +7 -0
- data/spec/stoplight/data_store/memory_spec.rb +12 -123
- data/spec/stoplight/data_store/redis_spec.rb +28 -129
- data/spec/stoplight/error_spec.rb +10 -0
- data/spec/stoplight/light/lockable_spec.rb +93 -0
- data/spec/stoplight/light/runnable_spec.rb +12 -233
- data/spec/stoplight/light_spec.rb +4 -28
- data/spec/stoplight/notifier/generic_spec.rb +35 -35
- data/spec/stoplight/notifier/io_spec.rb +1 -0
- data/spec/stoplight/notifier/logger_spec.rb +3 -0
- data/spec/stoplight_spec.rb +17 -6
- data/spec/support/configurable.rb +69 -0
- data/spec/support/data_store/base/clear_failures.rb +18 -0
- data/spec/support/data_store/base/clear_state.rb +20 -0
- data/spec/support/data_store/base/get_all.rb +44 -0
- data/spec/support/data_store/base/get_failures.rb +30 -0
- data/spec/support/data_store/base/get_state.rb +7 -0
- data/spec/support/data_store/base/names.rb +29 -0
- data/spec/support/data_store/base/record_failures.rb +70 -0
- data/spec/support/data_store/base/set_state.rb +15 -0
- data/spec/support/data_store/base/with_notification_lock.rb +27 -0
- data/spec/support/data_store/base.rb +21 -0
- data/spec/support/database_cleaner.rb +26 -0
- data/spec/support/exception_helpers.rb +9 -0
- data/spec/support/light/runnable/color.rb +79 -0
- data/spec/support/light/runnable/run.rb +247 -0
- data/spec/support/light/runnable.rb +4 -0
- metadata +56 -225
- data/lib/stoplight/notifier/bugsnag.rb +0 -37
- data/lib/stoplight/notifier/hip_chat.rb +0 -43
- data/lib/stoplight/notifier/honeybadger.rb +0 -44
- data/lib/stoplight/notifier/pagerduty.rb +0 -21
- data/lib/stoplight/notifier/raven.rb +0 -40
- data/lib/stoplight/notifier/rollbar.rb +0 -39
- data/lib/stoplight/notifier/slack.rb +0 -21
- data/spec/stoplight/notifier/bugsnag_spec.rb +0 -90
- data/spec/stoplight/notifier/hip_chat_spec.rb +0 -91
- data/spec/stoplight/notifier/honeybadger_spec.rb +0 -88
- data/spec/stoplight/notifier/pagerduty_spec.rb +0 -40
- data/spec/stoplight/notifier/raven_spec.rb +0 -90
- data/spec/stoplight/notifier/rollbar_spec.rb +0 -90
- data/spec/stoplight/notifier/slack_spec.rb +0 -46
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
# require 'slack-notifier'
|
6
|
-
module Slack
|
7
|
-
class Notifier
|
8
|
-
def initialize(*); end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
RSpec.describe Stoplight::Notifier::Slack do
|
13
|
-
it_behaves_like 'a generic notifier'
|
14
|
-
|
15
|
-
it 'is a class' do
|
16
|
-
expect(described_class).to be_a(Class)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'is a subclass of Base' do
|
20
|
-
expect(described_class).to be < Stoplight::Notifier::Base
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#slack' do
|
24
|
-
it 'reads Slack::Notifier client' do
|
25
|
-
slack = Slack::Notifier.new('WEBHOOK_URL')
|
26
|
-
expect(described_class.new(slack).slack).to eql(slack)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#notify' do
|
31
|
-
let(:light) { Stoplight::Light.new(name, &code) }
|
32
|
-
let(:name) { ('a'..'z').to_a.shuffle.join }
|
33
|
-
let(:code) { -> {} }
|
34
|
-
let(:from_color) { Stoplight::Color::GREEN }
|
35
|
-
let(:to_color) { Stoplight::Color::RED }
|
36
|
-
let(:notifier) { described_class.new(slack) }
|
37
|
-
let(:slack) { double(Slack::Notifier).as_null_object }
|
38
|
-
|
39
|
-
it 'pings Slack' do
|
40
|
-
error = nil
|
41
|
-
message = notifier.formatter.call(light, from_color, to_color, error)
|
42
|
-
expect(slack).to receive(:ping).with(message)
|
43
|
-
notifier.notify(light, from_color, to_color, error)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|