Sha256: 83ee08349710c364a3a6a8c86f78a3e79ae944eab919aa760de52b470c9d5999
Contents?: true
Size: 1.31 KB
Versions: 6
Compression:
Stored size: 1.31 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper' describe SystemMetrics::Middleware do before(:each) do @store = TestStore.new @collector = SystemMetrics::Collector.new(@store) end it 'should invoke the collector for non-excluded paths' do event = Object.new blk = Proc.new { @collector.collect_event(event) } middleware = SystemMetrics::Middleware.new(blk, @collector, []) env = { "PATH_INFO" => '/collect' } middleware.call(env) @store.should have(1).events end it 'should not invoke the collector for excluded paths' do event = Object.new blk = Proc.new { @collector.collect_event(event) } middleware = SystemMetrics::Middleware.new(blk, @collector, [/^\/collect/]) env = { "PATH_INFO" => '/collect' } middleware.call(env) @store.should have(0).events end it 'should wrap everything with an instrumentation for rack requests' do ActiveSupport::Notifications.subscribe(/\.rack$/) do |*args| @collector.collect_event(ActiveSupport::Notifications::Event.new(*args)) end event = Object.new blk = Proc.new {} middleware = SystemMetrics::Middleware.new(blk, @collector, []) env = { "PATH_INFO" => '/collect' } middleware.call(env) @store.should have(1).events @store.events.first.name.should == 'request.rack' end end
Version data entries
6 entries across 6 versions & 1 rubygems