Sha256: e48709366f7d4f02e02798e15e6a8d8d2b0db5376315b7cb59d331d682b40a71

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

describe Pliny::Middleware::Instruments do
  def app
    Rack::Builder.new do
      run Sinatra.new {
        use Pliny::Middleware::Instruments

        error Pliny::Errors::Error do
          Pliny::Errors::Error.render(env["sinatra.error"])
        end

        get "/apps/:id" do
          status 201
          "hi"
        end

        get "/error" do
          raise Pliny::Errors::NotFound
        end
      }
    end
  end

  it "performs logging" do
    mock(Pliny).log(hash_including(
      instrumentation: true,
      at:              "start",
      method:          "GET",
      path:            "/apps/123",
    ))
    mock(Pliny).log(hash_including(
      instrumentation: true,
      at:              "finish",
      method:          "GET",
      path:            "/apps/123",
      route_signature: "/apps/:id",
      status:          201
    ))
    get "/apps/123"
  end

  it "respects Pliny error status codes" do
    mock(Pliny).log.with_any_args
    mock(Pliny).log(hash_including(
      status: 404
    ))
    get "/error"
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pliny-0.17.0 spec/middleware/instruments_spec.rb
pliny-0.16.3 spec/middleware/instruments_spec.rb
pliny-0.16.2 spec/middleware/instruments_spec.rb
pliny-0.16.1 spec/middleware/instruments_spec.rb
pliny-0.16.0 spec/middleware/instruments_spec.rb
pliny-0.15.1 spec/middleware/instruments_spec.rb
pliny-0.15.0 spec/middleware/instruments_spec.rb
pliny-0.14.2 spec/middleware/instruments_spec.rb
pliny-0.14.1 spec/middleware/instruments_spec.rb
pliny-0.14.0 spec/middleware/instruments_spec.rb
pliny-0.13.1 spec/middleware/instruments_spec.rb
pliny-0.13.0 spec/middleware/instruments_spec.rb
pliny-0.12.0 spec/middleware/instruments_spec.rb