Sha256: 208721fcb9e3addc55ed2ef6fd27cc606660133cc0eb9e8a2ec96cf0e749de00

Contents?: true

Size: 1.44 KB

Versions: 82

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Appsignal::Hooks::RedisHook do
  before :all do
    Appsignal.config = project_fixture_config
  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
        let(:events) { [] }
        before :all do
          Appsignal.config.config_hash[:instrument_redis] = true
          Appsignal::Hooks::RedisHook.new.install
        end
        before do
          ActiveSupport::Notifications.subscribe(/^[^!]/) do |*args|
            events << ActiveSupport::Notifications::Event.new(*args)
          end
        end
        after(:all) { Object.send(:remove_const, :Redis) }

        its(:dependencies_present?) { should be_true }

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

82 entries across 82 versions & 1 rubygems

Version Path
appsignal-1.1.9 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.9.beta.2 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.9.beta.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.8 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.2.0.alpha.3 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.7 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.2.0.alpha.2 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.7.beta.2 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.2.0.alpha.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.7.beta.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.6 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.6.beta.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.5 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.5.beta.4 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.5.beta.3 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.5.beta.2 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.5.beta.1 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.4 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.4.beta.3 spec/lib/appsignal/hooks/redis_spec.rb
appsignal-1.1.4.beta.2 spec/lib/appsignal/hooks/redis_spec.rb