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
|
# File 'lib/webhookdb/spec_helpers/async.rb', line 10
def self.included(context)
Sidekiq::Testing.inline!
Amigo::QueueBackoffJob.reset
context.before(:each) do |example|
if (sidekiq_mode = example.metadata[:sidekiq])
Sidekiq::Testing.send(:"#{sidekiq_mode}!")
else
Sidekiq::Testing.inline!
end
Webhookdb::Postgres.do_not_defer_events = true if example.metadata[:do_not_defer_events]
if example.metadata[:slack]
Webhookdb::Slack.http_client = Webhookdb::Slack::NoOpHttpClient.new
Webhookdb::Slack.suppress_all = false
end
if example.metadata[:sentry]
Webhookdb::Sentry.dsn = "http://public:[email protected]/someproject"
Webhookdb::Sentry.run_after_configured_hooks
end
end
context.after(:each) do |example|
Webhookdb::Postgres.do_not_defer_events = false if example.metadata[:do_not_defer_events]
if example.metadata[:slack]
Webhookdb::Slack.http_client = nil
Webhookdb::Slack.reset_configuration
end
Webhookdb::Sentry.reset_configuration if example.metadata[:sentry]
Sidekiq::Queues.clear_all if example.metadata[:sidekiq] && Sidekiq::Testing.fake?
end
super
end
|