Sha256: 8e93a5dbd2611a5590a585360c886ef2d738eb927e5f147aa7e77b8c718c143a

Contents?: true

Size: 1008 Bytes

Versions: 4

Compression:

Stored size: 1008 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 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

4 entries across 4 versions & 1 rubygems

Version Path
status_cat-5.2.0 spec/lib/status_cat/checkers/s3_spec.rb
status_cat-5.0.2 spec/lib/status_cat/checkers/s3_spec.rb
status_cat-5.0.1 spec/lib/status_cat/checkers/s3_spec.rb
status_cat-5.0.0 spec/lib/status_cat/checkers/s3_spec.rb