Sha256: d83c1d5cb88cd4aa378ac2acb27bdb8460dbebd7bf09ba6183b350225af34204

Contents?: true

Size: 1.31 KB

Versions: 20

Compression:

Stored size: 1.31 KB

Contents

if DependencyHelper.sinatra_present?
  describe "Appsignal::Loaders::SinatraLoader" do
    before { Appsignal.config = nil }

    describe "#on_load" do
      it "registers Sinatra default config" do
        ::Sinatra::Application.settings.root = "/some/path"
        load_loader(:sinatra)

        expect(Appsignal::Config.loader_defaults).to include([
          :sinatra,
          {
            :env => :test,
            :root_path => "/some/path"
          }
        ])
      end
    end

    describe "#on_start" do
      after { uninstall_sinatra_integration }

      def uninstall_sinatra_integration
        expected_middleware = [
          Rack::Events,
          Appsignal::Rack::SinatraBaseInstrumentation
        ]
        Sinatra::Base.instance_variable_get(:@middleware).delete_if do |middleware|
          expected_middleware.include?(middleware.first)
        end
      end

      it "adds the instrumentation middleware to Sinatra::Base" do
        load_loader(:sinatra)
        start_loader(:sinatra)

        middlewares = Sinatra::Base.middleware.to_a
        expect(middlewares).to include(
          [Rack::Events, [[instance_of(Appsignal::Rack::EventHandler)]], nil]
        )
        expect(middlewares).to include(
          [Appsignal::Rack::SinatraBaseInstrumentation, [], nil]
        )
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
appsignal-3.13.1-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.13.1 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.13.1.alpha.1-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.13.1.alpha.1 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.13.0-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.13.0 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.6-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.6 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.5-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.5 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.4-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.4 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.3-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.3 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.2-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.2 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.1-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.1 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.0-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-3.12.0 spec/lib/appsignal/loaders/sinatra_spec.rb