Module: Webhookdb::SpecHelpers::Sentry

Defined in:
lib/webhookdb/spec_helpers/sentry.rb

Class Method Summary collapse

Class Method Details

.included(context) ⇒ Object



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
# File 'lib/webhookdb/spec_helpers/sentry.rb', line 7

def self.included(context)
  context.before(:each) do |example|
    if example.[:sentry]
      # We need to fake doing what Sentry would be doing for initialization,
      # so we can assert it has the right data in its scope.
      Webhookdb::Sentry.dsn = "https://public:[email protected]/whdb"
      hub = Sentry::Hub.new(
        Sentry::Client.new(Sentry::Configuration.new),
        Sentry::Scope.new,
      )
      expect(Sentry).to_not be_initialized
      Sentry.instance_variable_set(:@main_hub, hub)
      expect(Sentry).to be_initialized
    end
  end

  context.after(:each) do |example|
    if example.[:sentry]
      Webhookdb::Sentry.reset_configuration
      expect(Sentry).to_not be_initialized
    end
  end

  super
end