Sha256: 493e447b22c98a29c10bb052ba19b8e2f7760ac3b56622434b606c463c6e99d5

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe RedisWebManager do
  describe 'Test default configuration' do
    it 'returns a Redis class' do
      expect(RedisWebManager.redis).to be_a_kind_of(Redis)
    end

    it 'returns a nil class' do
      expect(RedisWebManager.authenticate).to eql(nil)
    end

    it 'returns a ActiveSupport::Duration class' do
      expect(RedisWebManager.lifespan).to be_a_kind_of(ActiveSupport::Duration)
    end
  end

  describe 'Test configuration' do
    it 'returns a raise error' do
      expect do
        RedisWebManager.configure do |c|
          c.redis = 1
          c.lifespan = 1
        end
      end.to raise_error(ArgumentError, 'Invalid Redis instance, use like that Redis.new')
    end

    it 'returns a raise error (redis)' do
      expect do
        RedisWebManager.configure do |c|
          c.redis = 1
        end
      end.to raise_error(ArgumentError, 'Invalid Redis instance, use like that Redis.new')
    end

    it 'returns a raise error (lifespan)' do
      expect do
        RedisWebManager.configure do |c|
          c.redis = ::Redis.new
          c.lifespan = 1
        end
      end.to raise_error(ArgumentError, 'Invalid lifespan, use like that 15.days, 15.minutes etc')
    end

    it 'returns a raise error (lifespan)' do
      expect do
        RedisWebManager.configure do |c|
          c.redis = ::Redis.new
          c.lifespan = -1.days
        end
      end.to raise_error(ArgumentError, 'Invalid lifespan, value must be greater than 0')
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redis_web_manager-0.2.1 spec/redis_web_manager_spec.rb
redis_web_manager-0.2.0 spec/redis_web_manager_spec.rb
redis_web_manager-0.1.8 spec/redis_web_manager_spec.rb
redis_web_manager-0.1.6 spec/redis_web_manager_spec.rb