Sha256: 949428af453ded60fc4fee9d2974f624a3adc3af2f989e712c23f26ff5b937aa

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe Appsignal::Hooks::RedisHook do
  before :all do
    start_agent
  end

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

      context "and redis instrumentation enabled" do
        before :all do
          Appsignal.config.config_hash[:instrument_redis] = true
          Appsignal::Hooks::RedisHook.new.install
        end
        after(:all) { Object.send(:remove_const, :Redis) }

        its(:dependencies_present?) { should be_true }

        it "should instrument a redis call" do
          Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
          expect( Appsignal::Transaction.current ).to receive(:start_event)
            .at_least(:once)
          expect( Appsignal::Transaction.current ).to receive(:finish_event)
            .at_least(:once)
            .with('query.redis', nil, nil, 0)

          client = Redis::Client.new

          client.process([]).should eq 1
        end
      end
    end

    context "and redis instrumentation disabled" do
      before :all do
        Appsignal.config.config_hash[:instrument_net_http] = false
      end

      its(:dependencies_present?) { should be_false }
    end
  end

  context "without redis" do
    its(:dependencies_present?) { should be_false }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appsignal-1.4.0.alpha.2 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.4.0.alpha.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.2 spec/lib/appsignal/hooks/redis_spec.rb