Sha256: abd8e29fd2c5f054976286f0b9621b9d5bfec682c4f503e291693faaef15909d

Contents?: true

Size: 984 Bytes

Versions: 3

Compression:

Stored size: 984 Bytes

Contents

require 'spec_helper'

describe "Net::HTTP instrumentation" do
  let(:file) { File.expand_path('lib/appsignal/instrumentations/redis.rb') }

  let(:events) { [] }
  before do
    ActiveSupport::Notifications.subscribe(/^[^!]/) do |*args|
      events << ActiveSupport::Notifications::Event.new(*args)
    end
  end

  context "with redis" do
    before :all do
      module Redis
        class Client
          def process(commands, &block)
            1
          end
        end
        VERSION = '1.0'
      end
    end

    before do
      load file
    end

    it "should generate an event for a redis call" do
      client = Redis::Client.new

      client.process([]).should == 1

      event = events.last
      event.name.should == 'query.redis'
    end
  end

  context "without redis" do
    before(:all) { Object.send(:remove_const, :Redis) }

    specify { expect { ::Redis }.to raise_error(NameError) }
    specify { expect { load file }.to_not raise_error }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appsignal-0.12.rc.7 spec/lib/appsignal/instrumentations/redis_spec.rb
appsignal-0.12.rc.6 spec/lib/appsignal/instrumentations/redis_spec.rb
appsignal-0.12.rc.5 spec/lib/appsignal/instrumentations/redis_spec.rb