Sha256: 1862b25bc401fc21e2986ae5c8c9f84dcda971414a197b8bdc83f005da3e09a0

Contents?: true

Size: 1.44 KB

Versions: 19

Compression:

Stored size: 1.44 KB

Contents

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

19 entries across 19 versions & 1 rubygems

Version Path
appsignal-2.0.6 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.0.5 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.0.5.beta.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.1.0.alpha.3 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.1.0.alpha.2 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.1.0.alpha.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.0.4 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.0.3 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.0.2 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.0.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.0.0 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-2.0.0.beta.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.4.0.beta.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.6 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.6.beta.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.5 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.5.beta.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.4 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.3.3 spec/lib/appsignal/hooks/redis_spec.rb