Sha256: 213bdb4b275a22ed763f5cd692c1fe92879abc5e02043f764bac96c2b4614b1e

Contents?: true

Size: 1.46 KB

Versions: 5

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 == 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

5 entries across 5 versions & 1 rubygems

Version Path
appsignal-1.3.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.0 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.0.beta.3 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.0.beta.2 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.0.beta.1 spec/lib/appsignal/hooks/redis_spec.rb