Sha256: 18b156ace23aa7b6ab1ab053be62bc35b43ed6b9d222050940cec5ea899a0c55

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'rails_helper'
require 'net/http'

RSpec.describe HeyDoctor::CheckApplicationHealthService do
  describe '.call' do
    let(:http) { double }

    before do
      allow(Net::HTTP).to receive(:start).and_yield(http)

      allow(http).to receive(:head).and_return(response_double)
    end

    context 'When app is running' do
      let(:expected_response) do
        {
          message: 'Application is running',
          success: true
        }
      end

      let(:response_double) { double(Net::HTTP, code: '200') }

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

    context 'When app is down' do
      let(:expected_response) do
        {
          message: 'Application down, call the firefighters',
          success: false
        }
      end

      let(:response_double) { double(Net::HTTP, code: '500') }

      it 'respond with success' do
        expect(described_class.call).to eq(expected_response)
      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_application_health_service_spec.rb
hey_doctor-1.1.3.pre.rc2 spec/services/hey_doctor/check_application_health_service_spec.rb
hey_doctor-1.1.2 spec/services/hey_doctor/check_application_health_service_spec.rb
hey_doctor-1.1.1 spec/services/hey_doctor/check_application_health_service_spec.rb
hey_doctor-1.1.0 spec/services/hey_doctor/check_application_health_service_spec.rb
hey_doctor-1.0.0 spec/services/hey_doctor/check_application_health_service_spec.rb