Sha256: cdd06bd3cfcb108d8adcc18b7b1a14f458ca68fca01b8d7525688711c27c9d78

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe PgLocksMonitor::DefaultNotifier do
  it "requires correct config if Slack notifications enabled" do
    expect {
      PgLocksMonitor::DefaultNotifier.call({})
    }.not_to raise_error
    PgLocksMonitor.configure do |config|
      config.notify_slack = true
    end

    expect {
      PgLocksMonitor::DefaultNotifier.call({})
    }.to raise_error(RuntimeError)
  end

  describe "Slack notification enabled" do
    before do
      PgLocksMonitor.configure do |config|
        config.notify_slack = true
        config.slack_webhook_url = "https://hooks.slack.com/services/123456789/123456789/123456789"
        config.slack_channel = "pg-locks-monitor"
      end
    end

    after do
      PgLocksMonitor.configure do |config|
        config.notify_slack = false
        config.slack_webhook_url = nil
        config.slack_channel = nil
      end
    end

    it "sends the Slack notification" do
      expect_any_instance_of(Slack::Notifier).to receive(:ping)
      PgLocksMonitor::DefaultNotifier.call({ locks: "data" })
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg-locks-monitor-0.3.2 spec/default_notifier_spec.rb
pg-locks-monitor-0.3.1 spec/default_notifier_spec.rb
pg-locks-monitor-0.3.0 spec/default_notifier_spec.rb