Sha256: c4f9dd4493dfe44b3ed03b86a43e791f6705e89c39e0c9d212c29c6a358f1c9f

Contents?: true

Size: 1.07 KB

Versions: 49

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe "Unicorn integration" do
  let(:file) { File.expand_path('lib/appsignal/integrations/unicorn.rb') }
  before(:all) do
    module Unicorn
      class HttpServer
        def worker_loop(worker)
        end
      end

      class Worker
        def close
        end
      end
    end
  end
  before do
    load file
    start_agent
  end

  it "adds behavior to Unicorn::HttpServer#worker_loop" do
    server = Unicorn::HttpServer.new
    worker = double

    Appsignal.agent.should_receive(:forked!)
    server.should_receive(:original_worker_loop).with(worker)

    server.worker_loop(worker)
  end

  it "should add behavior to Unicorn::Worker#close" do
    worker = Unicorn::Worker.new

    Appsignal.agent.should_receive(:shutdown).with(true, 'stopping Unicorn worker process')
    worker.should_receive(:original_close)

    worker.close
  end

  context "without unicorn" do
    before(:all) { Object.send(:remove_const, :Unicorn) }

    specify { expect { Unicorn }.to raise_error(NameError) }
    specify { expect { load file }.to_not raise_error }
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
appsignal-0.11.18 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.17 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.16 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.15 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.14 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.14.beta.1 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.13 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.13.beta.4 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.13.beta.3 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.13.beta.2 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.13.beta.1 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.13.beta.0 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.12 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.11 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.10 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.10.beta.2 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.10.beta.1 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.9 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.8.beta.4 spec/lib/appsignal/integrations/unicorn_spec.rb
appsignal-0.11.8.beta.3 spec/lib/appsignal/integrations/unicorn_spec.rb