Sha256: 69aaa5c7dc4a2a697085bb74cb50ad75bc0946bccc24de9ff3ab0141e0c621af

Contents?: true

Size: 1.16 KB

Versions: 57

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe Appsignal::Rack::Instrumentation do
  before :all do
    start_agent
    @events = []
    @subscriber = ActiveSupport::Notifications.subscribe do |*args|
      @events << ActiveSupport::Notifications::Event.new(*args)
    end
  end
  after :all do
    ActiveSupport::Notifications.unsubscribe(@subscriber)
  end

  let(:app) { double(:call => true) }
  let(:env) { {} }
  let(:middleware) { Appsignal::Rack::Instrumentation.new(app, {}) }

  describe "#call" do
    it "should instrument the call" do
      app.should_receive(:call).with(env)
      middleware.stub(:raw_payload => {})

      middleware.call(env)

      @events.last.name.should == 'process_action.rack'
    end
  end

  describe "raw_payload" do
    let(:env) do
      {
        'rack.input' => StringIO.new,
        'REQUEST_METHOD' => 'GET',
        'PATH_INFO' => '/homepage',
        'REQUEST_METHOD' => 'GET',
        'QUERY_STRING' => 'param=something'
      }
    end
    subject { middleware.raw_payload(env) }

    it { should == {
      :action => 'GET:/homepage',
      :params => {'param' => 'something'},
      :method => 'GET',
      :path => '/homepage'
    } }
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
appsignal-0.11.0 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.11.0.beta.2 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.11.0.beta.1 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.10.6 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.10.5 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.10.4 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.10.3 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.10.2 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.10.1 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.10.0 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.9.6 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.9.5 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.10.0.beta.0 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.9.4 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.9.3 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.9.2 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.9.1 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.9.0 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.8.15 spec/lib/appsignal/rack/instrumentation_spec.rb
appsignal-0.9.0.beta.1 spec/lib/appsignal/rack/instrumentation_spec.rb