Sha256: d69664dbaa13cc65b86a41f9790c32b02b3e8e5b4c6453b8ae17a415bc000d80

Contents?: true

Size: 794 Bytes

Versions: 4

Compression:

Stored size: 794 Bytes

Contents

require 'spec_helper'
require 'napa/middleware/request_stats'

describe Napa::Middleware::RequestStats do
  before do
    # Delete any prevous instantiations of the emitter and set valid statsd env vars
    Napa::Stats.emitter = nil
    ENV['STATSD_HOST'] = 'localhost'
    ENV['STATSD_PORT'] = '8125'
  end

  it 'should send the api_response_time' do
    expect(Napa::Stats.emitter).to receive(:timing).with('response_time', an_instance_of(Float))
    expect(Napa::Stats.emitter).to receive(:timing).with('path.get.test.path.response_time', an_instance_of(Float))
    app = lambda { |env| [200, { 'Content-Type' => 'application/json'}, Array.new] }
    middleware = Napa::Middleware::RequestStats.new(app)
    env = Rack::MockRequest.env_for('/test/path')
    middleware.call(env)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
napa-0.5.0 spec/middleware/request_stats_spec.rb
napa-0.4.3 spec/middleware/request_stats_spec.rb
napa-0.4.1 spec/middleware/request_stats_spec.rb
napa-0.4.0 spec/middleware/request_stats_spec.rb