Sha256: 3277203515f08733dd684dc647501909d1aeaa0ef197687b8ee345c562d36663

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe HeyDoctor::CheckRedisHealthService do
  describe '.call' do
    context 'when it is connected' do
      let(:expected_response) do
        {
          message: 'Redis is connected',
          success: true
        }
      end

      it 'respond with success' do
        expect(described_class.call).to eq(expected_response)
      end
    end

    context 'when it is not connected' do
      let(:expected_response) do
        {
          message: 'Error connecting to redis',
          success: false
        }
      end

      before do
        allow(Redis.current).to receive(:get).and_raise(NameError)
      end

      it 'respond with success' do
        expect(described_class.call).to eq(expected_response)
      end
    end
  end

  describe '.connected?' do
    context 'when it is connected' do
      it 'respond with success' do
        expect(described_class.send(:connected?)).to eq(true)
      end
    end

    context 'when it is not connected' do
      before do
        allow(Redis.current).to receive(:get)
          .and_raise(Redis::CannotConnectError)
      end

      it 'respond with success' do
        expect(described_class.send(:connected?)).to eq(false)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hey_doctor-1.2.0 spec/services/hey_doctor/check_redis_health_service_spec.rb
hey_doctor-1.1.3.pre.rc2 spec/services/hey_doctor/check_redis_health_service_spec.rb
hey_doctor-1.1.2 spec/services/hey_doctor/check_redis_health_service_spec.rb
hey_doctor-1.1.1 spec/services/hey_doctor/check_redis_health_service_spec.rb
hey_doctor-1.1.0 spec/services/hey_doctor/check_redis_health_service_spec.rb
hey_doctor-1.0.0 spec/services/hey_doctor/check_redis_health_service_spec.rb