Sha256: fb9161244cc8a86b7562bd4bda22b74d6752babbac1e8ece86318aa717f72790

Contents?: true

Size: 934 Bytes

Versions: 4

Compression:

Stored size: 934 Bytes

Contents

describe StatusCat::Checkers::GoogleCivic do

  let(:checker) { StatusCat::Checkers::GoogleCivic.new.freeze }
  let(:response) { double('response', code: 200) }
  let(:key) { 'env_google_civics_key' }

  before(:each) do
    allow(HTTParty).to receive(:get).and_return(response)
    StatusCat::Checkers::GoogleCivic.api_key = key
  end

  it_should_behave_like 'a status checker'

  it 'sets the value' do
    expect(checker.value).to eql(key)
  end

  context 'pass' do

    it 'passes on connection to Google Civics API' do
      expect(checker.status).to be_nil
    end

  end

  context 'fail' do

    it 'fails if it receives a non 200 code' do
      expect(response).to receive(:code).and_return(404)
      expect(checker.status).to_not be_nil
    end

    it 'fails if there is an exception' do
      expect(response).to receive(:code).and_raise('No code for you!')
      expect(checker.status).to_not be_nil
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
status_cat-5.2.1 spec/lib/status_cat/checkers/google_civic_spec.rb
status_cat-5.2.0 spec/lib/status_cat/checkers/google_civic_spec.rb
status_cat-5.0.2 spec/lib/status_cat/checkers/google_civic_spec.rb
status_cat-5.0.1 spec/lib/status_cat/checkers/google_civic_spec.rb