Sha256: 5216c6f72a08b625d76a04951402a7a236fa42894ea06159f0b48db49464ec1f

Contents?: true

Size: 1011 Bytes

Versions: 1

Compression:

Stored size: 1011 Bytes

Contents

describe StatusCat::Checkers::S3 do

  let(:checker) { StatusCat::Checkers::S3.new.freeze }

  before(:each) do

    allow(Aws::S3::Resource).to receive(:new).and_return(@s3 = double(Aws::S3::Resource))
  end

  it_should_behave_like 'a status checker'

  it 'tolerates the gem misssing' do
    gem = Object.send(:remove_const, :Aws)
    expect(checker.status).to eql('aws-sdk-s3 gem is not installed')
    Object.const_set(:Aws, gem)
  end

  it 'uses the aws access key as the value' do
    expect(checker.value).to eql(Aws.config[:credentials].access_key_id)
  end

  it 'fails if there is an exception talking to S3' do
    expect(@s3).to receive(:buckets).and_raise('error')
    expect(checker.status).to_not be_nil
  end

  it 'fails if there are no S3 buckets' do
    expect(@s3).to receive(:buckets).and_return([])
    expect(checker.status).to_not be_nil
  end

  it 'passes if it finds S3 buckets' do
    expect(@s3).to receive(:buckets).and_return([1])
    expect(checker.status).to be_nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
status_cat-5.2.1 spec/lib/status_cat/checkers/s3_spec.rb