Sha256: 1e41c69ab7ab208339a70e6249d5f7824a35aed70bf733238c43f02d48fff43d

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'
require 'aws-sdk'

describe StatusCat::Checkers::S3 do

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

  before( :each ) do
    AWS::S3.stub( :new ).and_return( @s3 = double( AWS::S3 ) )
  end

  it_should_behave_like 'a status checker'

  it 'tolerates AWS being undefined' do
    aws = Object.send(:remove_const, :AWS)
    expect( checker.status ).to_not be_nil
    Object.const_set( :AWS, aws )
  end

  it 'uses the aws access key as the value' do
    expect( checker.value ).to eql( AWS.config.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

2 entries across 2 versions & 1 rubygems

Version Path
status_cat-0.1.0 spec/lib/status_cat/checkers/s3_spec.rb
status_cat-0.0.9 spec/lib/status_cat/checkers/s3_spec.rb