Sha256: 49a423e39267021847a4cfbe83bb4dd40c144d7629692547741049ebeeceeef3

Contents?: true

Size: 1.93 KB

Versions: 5

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

describe Cloudster::S3 do
  describe 'initialize' do
    it "should raise argument error if no argument is provided" do
      expect { Cloudster::S3.new() }.to raise_error(ArgumentError, 'Missing required argument: name')
    end
    it "should not raise argument error if all arguments are provided" do
      expect { Cloudster::S3.new(:name => 'mybucket') }.to_not raise_error
    end
  end

  describe '#template' do
    it "should return a ruby hash for the resource cloudformation template with only mandatory fields" do
      s3 = Cloudster::S3.new(:name => 'bucket_name')
      s3.template.should == {'Resources' => {'bucket_name' => {'Type' => 'AWS::S3::Bucket', 'Properties' => {}}}}
    end
    it "should return a ruby hash for the resource cloudformation template" do
      s3 = Cloudster::S3.new(:name => 'bucket_name', :access_control => "PublicRead", :website_configuration => {"index_document" => "index.html", "error_document" => "error.html"} )
      s3.template.should == {'Resources' => {'bucket_name' => {'Type' => 'AWS::S3::Bucket', 'Properties' => {"AccessControl" => "PublicRead", "WebsiteConfiguration" => { "IndexDocument" => "index.html", "ErrorDocument" => "error.html" } }}}}
    end
  end

  describe '.template' do
    it "should raise argument error if no argument is provided" do
      expect { Cloudster::S3.template() }.to raise_error(ArgumentError, 'Missing required argument: name')
    end
    it "should return a ruby hash for the resource cloudformation template" do
      hash = Cloudster::S3.template(:name => 'bucket_name', :access_control => "PublicRead", :website_configuration => {"index_document" => "index.html", "error_document" => "error.html"} )
      hash.should == {'Resources' => {'bucket_name' => {'Type' => 'AWS::S3::Bucket', 'Properties' => {"AccessControl" => "PublicRead", "WebsiteConfiguration" => { "IndexDocument" => "index.html", "ErrorDocument" => "error.html" } }}}}
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cloudster-2.17.0 spec/s3_spec.rb
cloudster-2.16.0 spec/s3_spec.rb
cloudster-2.15.0 spec/s3_spec.rb
cloudster-2.14.1 spec/s3_spec.rb
cloudster-2.14.0 spec/s3_spec.rb