spec/lita/handlers/metrics_spec.rb in lita-metrics-0.1.0 vs spec/lita/handlers/metrics_spec.rb in lita-metrics-0.1.1

- old
+ new

@@ -9,34 +9,31 @@ 'Lita::Handlers::Test' end route(/message/, :test_message) route(/command/, :test_command, command: true) + route(/ignore/, :test_ignore) - def test_message(response) - response.reply('message') + def test_message(_response) end - def test_command(response) - response.reply('command') + def test_command(_response) end - route(/block/) do |response| - response.reply('block') + def test_ignore(_response) end + + route(/block/) do |_response| + end end end - let(:john) do - Lita::User.create('U1234ABCD', name: 'John', mention_name: 'john') - end + let(:john) { Lita::User.create('U1234ABCD', name: 'John', mention_name: 'john') } - let(:general) do - Lita::Room.create_or_update('C1234567890', name: 'general') - end + let(:general) { Lita::Room.create_or_update('C1234567890', name: 'general') } - before do + before(:each) do robot.trigger(:loaded) registry.register_handler(test_handler) end it { is_expected.to route_event(:message_dispatched).to(:valid_command) } @@ -79,9 +76,15 @@ expect(described_class.statsd).to receive(:increment).with( 'lita.messages.all', tags: anything ) send_command('command', as: john, from: general) + end + + it 'ignores methods specified in the configuration' do + registry.config.handlers.metrics.ignored_methods = %w(Test#test_ignore) + expect(described_class.statsd).not_to receive(:increment) + send_message('ignore') end end describe 'logger' do it 'logs messages that match a route' do