Sha256: d6666f1b567d30d33229114149cd75d297d77b422f424ee674fbd0a6292226db

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 Bytes

Contents

require 'spec_helper'

describe 'A status request with a LoadCheck' do
  before do
    Rapporteur.add_check(Rapporteur::Checks::LoadCheck)
    Rapporteur::Checks::LoadCheck.stub(:current_load).and_return(current_load)
  end

  subject { get(status_path) ; response }

  context 'with a load below the threshold' do
    let(:current_load) { 1.0 }

    it_behaves_like 'a successful status response'

    it 'contains the load value in the messages' do
      json = JSON.parse(subject.body)
      expect(json.fetch("load")).to eq(1.0)
    end
  end

  context 'with a load above the threshold' do
    let(:current_load) { 9.0 }

    it_behaves_like 'an erred status response'

    it 'contains a message regarding the excess load' do
      expect(subject).to include_status_error_message(:load, I18n.t('rapporteur.errors.load.excessive', value: current_load, tolerance: 8.0))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rapporteur-load_check-2.1.0 spec/requests/load_check_spec.rb
rapporteur-load_check-2.0.0 spec/requests/load_check_spec.rb