Sha256: 1b92a3ddb5136576904110ceaedda815057931e3878930086c830809b3016cee

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe Appsignal::Hooks::PumaHook do
  context "with puma" do
    before(:all) do
      class Puma
        def self.cli_config
          @cli_config ||= CliConfig.new
        end
      end

      class CliConfig
        attr_accessor :options

        def initialize
          @options = {}
        end
      end
    end
    after(:all) { Object.send(:remove_const, :Puma) }

    its(:dependencies_present?) { should be_true }

    context "with a nil before worker shutdown" do
      before do
        Puma.cli_config.options.delete(:before_worker_shutdown)
        Appsignal::Hooks::PumaHook.new.install
      end

      it "should add a before shutdown worker callback" do
        Puma.cli_config.options[:before_worker_shutdown].first.should be_a(Proc)
      end
    end

    context "with an existing before worker shutdown" do
      before do
        Puma.cli_config.options[:before_worker_shutdown] = []
        Appsignal::Hooks::PumaHook.new.install
      end

      it "should add a before shutdown worker callback" do
        Puma.cli_config.options[:before_worker_shutdown].first.should be_a(Proc)
      end
    end
  end

  context "without puma" do
    its(:dependencies_present?) { should be_false }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
appsignal-0.12.rc.12 spec/lib/appsignal/hooks/puma_spec.rb
appsignal-0.12.rc.11 spec/lib/appsignal/hooks/puma_spec.rb
appsignal-0.12.rc.10 spec/lib/appsignal/hooks/puma_spec.rb
appsignal-0.12.rc.9 spec/lib/appsignal/hooks/puma_spec.rb
appsignal-0.12.rc.8 spec/lib/appsignal/hooks/puma_spec.rb