Sha256: 673189983322a098c2a2dea35bd4cf69e92e17fcba5f1b76b0c50fa66dd4d756

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'
require 'action_controller/railtie'
require 'appsignal/railtie'

describe Appsignal::Railtie do

  before(:all) { MyApp::Application.initialize! }

  it "should have set the appsignal subscriber" do
    Appsignal.subscriber.
      should be_a ActiveSupport::Notifications::Fanout::Subscriber
  end

  it "should have added the middleware for exceptions" do
    MyApp::Application.middleware.to_a.should include Appsignal::Middleware
  end

  context "non action_controller event" do
    it "should call add_event for non action_controller event" do
      current = stub
      current.should_receive(:add_event)
      Appsignal::Transaction.should_receive(:current).twice.
        and_return(current)
    end

    after { ActiveSupport::Notifications.instrument 'query.mongoid' }
  end

  context "action_controller event" do
    it "should call set_process_action_event for action_controller event" do
      current = stub
      current.should_receive(:set_process_action_event)
      current.should_receive(:add_event)
      Appsignal::Transaction.should_receive(:current).exactly(3).times.
        and_return(current)
    end

    after do
      ActiveSupport::Notifications.
        instrument 'process_action.action_controller'
    end
  end

  context "event that starts with a bang" do
    it "should not be processed" do
      Appsignal::Transaction.should_not_receive(:current)
    end

    after do
      ActiveSupport::Notifications.
        instrument '!render_template'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
appsignal-0.4.7 spec/appsignal/railtie_spec.rb
appsignal-0.4.6 spec/appsignal/railtie_spec.rb
appsignal-0.4.5 spec/appsignal/railtie_spec.rb
appsignal-0.4.4 spec/appsignal/railtie_spec.rb
appsignal-0.4.3 spec/appsignal/railtie_spec.rb
appsignal-0.4.0 spec/appsignal/railtie_spec.rb