spec/lib/flapjack/data/event_spec.rb in flapjack-1.2.0rc2 vs spec/lib/flapjack/data/event_spec.rb in flapjack-1.2.0
- old
+ new
@@ -4,10 +4,11 @@
describe Flapjack::Data::Event do
let(:entity_name) { 'xyz-example.com' }
let(:check) { 'ping' }
let(:redis) { double(::Redis) }
+ let(:multi) { double('multi') }
let!(:time) { Time.now}
let(:event_data) { {'type' => 'service',
'state' => 'critical',
@@ -77,14 +78,13 @@
expect(redis).to receive(:brpoplpush).
with('events', /^events_archive:/, 0).and_return(bad_event_json)
expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => redis)
expect(redis).to receive(:sadd).
with('known_events_archive_keys', /^events_archive:/)
- expect(redis).to receive(:multi)
- expect(redis).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
- expect(redis).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
- expect(redis).to receive(:exec)
+ expect(redis).to receive(:multi).and_yield(multi)
+ expect(multi).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
+ expect(multi).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
expect(redis).to receive(:expire)
result = Flapjack::Data::Event.next('events', :block => true,
:archive_events => true, :redis => redis)
expect(result).to be_nil
@@ -110,14 +110,13 @@
expect(redis).to receive(:brpoplpush).
with('events', /^events_archive:/, 0).and_return(bad_event_json)
expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => redis)
expect(redis).to receive(:sadd).
with('known_events_archive_keys', /^events_archive:/)
- expect(redis).to receive(:multi)
- expect(redis).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
- expect(redis).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
- expect(redis).to receive(:exec)
+ expect(redis).to receive(:multi).and_yield(multi)
+ expect(multi).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
+ expect(multi).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
expect(redis).to receive(:expire)
result = Flapjack::Data::Event.next('events', :block => true,
:archive_events => true, :redis => redis)
expect(result).to be_nil
@@ -143,14 +142,13 @@
expect(redis).to receive(:brpoplpush).
with('events', /^events_archive:/, 0).and_return(bad_event_json)
expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => redis)
expect(redis).to receive(:sadd).
with('known_events_archive_keys', /^events_archive:/)
- expect(redis).to receive(:multi)
- expect(redis).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
- expect(redis).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
- expect(redis).to receive(:exec)
+ expect(redis).to receive(:multi).and_yield(multi)
+ expect(multi).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
+ expect(multi).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
expect(redis).to receive(:expire)
result = Flapjack::Data::Event.next('events', :block => true,
:archive_events => true, :redis => redis)
expect(result).to be_nil
@@ -178,14 +176,13 @@
expect(redis).to receive(:brpoplpush).
with('events', /^events_archive:/, 0).and_return(bad_event_json)
expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => redis)
expect(redis).to receive(:sadd).
with('known_events_archive_keys', /^events_archive:/)
- expect(redis).to receive(:multi)
- expect(redis).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
- expect(redis).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
- expect(redis).to receive(:exec)
+ expect(redis).to receive(:multi).and_yield(multi)
+ expect(multi).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
+ expect(multi).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
expect(redis).to receive(:expire)
result = Flapjack::Data::Event.next('events', :block => true,
:archive_events => true, :redis => redis)
expect(result).to be_nil
@@ -269,13 +266,12 @@
expect(redis).to receive(:brpoplpush).
with('events', /^events_archive:/, 0).and_return(bad_event_json)
expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => redis)
expect(redis).to receive(:sadd).
with('known_events_archive_keys', /^events_archive:/)
- expect(redis).to receive(:multi)
- expect(redis).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
- expect(redis).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
- expect(redis).to receive(:exec)
+ expect(redis).to receive(:multi).and_yield(multi)
+ expect(multi).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
+ expect(multi).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
expect(redis).to receive(:expire)
result = Flapjack::Data::Event.next('events', :block => true,
:archive_events => true, :redis => redis)
expect(result).to be_nil