Sha256: 5b035d8797d64c56ec8c5e9b2ebc6862a2ffa2c89aeda520f3eb2ab802f049d5

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

require 'spec_helper'

describe 'A status request with a LoadCheck' do
  before do
    Rapporteur::Checker.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["messages"]["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(I18n.t('activemodel.errors.models.rapporteur/checker.attributes.base.excess_load'))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rapporteur-load_check-1.1.0 spec/requests/load_check_spec.rb
rapporteur-load_check-1.0.0 spec/requests/load_check_spec.rb