Sha256: 91b99a0b54e8e6d352d38fb21b1b59f1b11b349ea5172a62bca0575e0dfe9352

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

if DependencyHelper.sinatra_present?
  ENV["APPSIGNAL_PUSH_API_KEY"] = "key"
  require "appsignal/integrations/sinatra"

  describe "Sinatra integration" do
    context "Appsignal.logger" do
      subject { Appsignal.logger }

      it { is_expected.to be_a Logger }
    end

    describe "middleware" do
      it "adds the instrumentation middleware to Sinatra::Base" do
        expect(Sinatra::Base.middleware.to_a).to include(
          [Appsignal::Rack::SinatraBaseInstrumentation, [], nil]
        )
      end
    end

    describe "environment" do
      subject { Appsignal.config.env }

      context "without APPSIGNAL_APP_ENV" do
        before do
          load File.expand_path("lib/appsignal/integrations/sinatra.rb", project_dir)
        end

        it "uses the app environment" do
          expect(subject).to eq("test")
        end
      end

      context "with APPSIGNAL_APP_ENV" do
        before do
          ENV["APPSIGNAL_APP_ENV"] = "env-staging"
          load File.expand_path("lib/appsignal/integrations/sinatra.rb", project_dir)
        end

        it "uses the environment variable" do
          expect(subject).to eq("env-staging")
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appsignal-2.1.2 spec/lib/appsignal/integrations/sinatra_spec.rb
appsignal-2.1.1 spec/lib/appsignal/integrations/sinatra_spec.rb
appsignal-2.1.1.beta.1 spec/lib/appsignal/integrations/sinatra_spec.rb
appsignal-2.1.0 spec/lib/appsignal/integrations/sinatra_spec.rb