Sha256: 879a30cf3df2442b1bd83c6f14ef2652e230bc994329ee07d5495226f0eb2273

Contents?: true

Size: 1.28 KB

Versions: 18

Compression:

Stored size: 1.28 KB

Contents

if DependencyHelper.sinatra_present?
  describe "Appsignal::Loaders::SinatraLoader" do
    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(
          :name => :sinatra,
          :root_path => "/some/path",
          :env => :test,
          :options => {}
        )
      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

18 entries across 18 versions & 1 rubygems

Version Path
appsignal-4.0.6-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.6 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.5-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.5 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.4-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.4 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.3-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.3 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.2-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.2 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.1-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.1 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.0-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.0 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.0.beta.2-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.0.beta.2 spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.0.beta.1-java spec/lib/appsignal/loaders/sinatra_spec.rb
appsignal-4.0.0.beta.1 spec/lib/appsignal/loaders/sinatra_spec.rb