Sha256: 65eb07eabb544eabf70855c8f72662940012f322841ae0a56d5db673577e0d1a

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require "appsignal/rack/hanami_middleware"

if DependencyHelper.hanami2_present?
  describe Appsignal::Rack::HanamiMiddleware do
    let(:app) { double(:call => true) }
    let(:router_params) { { "param1" => "value1", "param2" => "value2" } }
    let(:env) do
      Rack::MockRequest.env_for(
        "/some/path",
        "router.params" => router_params
      )
    end
    let(:middleware) { Appsignal::Rack::HanamiMiddleware.new(app, {}) }

    before(:context) { start_agent }
    around { |example| keep_transactions { example.run } }

    def make_request(env)
      middleware.call(env)
    end

    context "with params" do
      it "sets request parameters on the transaction" do
        make_request(env)

        expect(last_transaction.to_h).to include(
          "sample_data" => hash_including(
            "params" => { "param1" => "value1", "param2" => "value2" }
          )
        )
      end
    end

    it "reports a process_action.hanami event" do
      make_request(env)

      expect(last_transaction.to_h).to include(
        "events" => [
          hash_including(
            "body" => "",
            "body_format" => Appsignal::EventFormatter::DEFAULT,
            "count" => 1,
            "name" => "process_action.hanami",
            "title" => ""
          )
        ]
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
appsignal-3.9.2-java spec/lib/appsignal/rack/hanami_middleware_spec.rb
appsignal-3.9.2 spec/lib/appsignal/rack/hanami_middleware_spec.rb