Sha256: 2e0c34f1429f55c285b6c3cdc898e32d50d1c47237fde4c0f6e5bc8ffa922973

Contents?: true

Size: 760 Bytes

Versions: 7

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true

RSpec.configure do |config|
  config.before(:each, :cache => lambda { |v| !!v }) do |example|
    config.rspeckled_logger.debug("Before Each  - Start - #{__FILE__}")

    cache_metadata = example.metadata[:cache]

    # rubocop:disable Metrics/BlockNesting
    if cache_metadata[:reset]
      client         = ::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 2) # rubocop:disable Style/IpAddresses
      reset_patterns = Array(cache_metadata[:reset])

      client.keys.each do |key|
        next unless reset_patterns.any? { |regex| key.match?(regex) }

        client.del(key)
      end
    end
    # rubocop:enable Metrics/BlockNesting

    config.rspeckled_logger.debug("Before Each  - End   - #{__FILE__}")
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rspeckled-2.0.1 lib/rspeckled/plugins/hooks/redis.rb
rspeckled-2.0.0 lib/rspeckled/plugins/hooks/redis.rb
rspeckled-1.4.0 lib/rspeckled/plugins/hooks/redis.rb
rspeckled-1.3.1 lib/rspeckled/plugins/hooks/redis.rb
rspeckled-1.3.0 lib/rspeckled/plugins/hooks/redis.rb
rspeckled-1.2.1 lib/rspeckled/plugins/hooks/redis.rb
rspeckled-1.2.0 lib/rspeckled/plugins/hooks/redis.rb