Sha256: f211c78daeeb66a8ee79b453bad15edabdfefd284d8ce95db1b8b9ad29a1f273

Contents?: true

Size: 861 Bytes

Versions: 3

Compression:

Stored size: 861 Bytes

Contents

require 'spec_helper'
require 'service_template/middleware/request_stats'

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

  it 'should send the api_response_time' do
    expect(ServiceTemplate::Stats.emitter).to receive(:timing).with('response_time', an_instance_of(Float))
    expect(ServiceTemplate::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 = ServiceTemplate::Middleware::RequestStats.new(app)
    env = Rack::MockRequest.env_for('/test/path')
    middleware.call(env)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
service_template-0.5.2 spec/middleware/request_stats_spec.rb
service_template-0.5.1 spec/middleware/request_stats_spec.rb
service_template-0.5.0 spec/middleware/request_stats_spec.rb