Sha256: 01e15391073e5408eee19b46460a53a5c350a9162bb903c76f3fab14c794a322

Contents?: true

Size: 1.44 KB

Versions: 18

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe S3Website::Cloudfront::Invalidator do
  describe 'default behaviour' do
    let(:config) {{
      's3_id' => 'aws id',
      's3_secret' => 'aws secret',
      'cloudfront_distribution_id' => 'EFXX'
    }}

    it 'invalidates the root resource' do
      invalidator = create_simple_cloudfront_invalidator(config)
      invalidator.
        should_receive(:invalidate).
        with(['index.html', '']).
        and_return(:text_report => 'report txt')

      S3Website::Cloudfront::Invalidator.invalidate(config, ['index.html'])
    end
  end

  describe 'option cloudfront_invalidate_root = true' do
    let(:config) {{
      's3_id' => 'aws id',
      's3_secret' => 'aws secret',
      'cloudfront_distribution_id' => 'EFXX',
      'cloudfront_invalidate_root' => true
    }}

    it 'invalidates all root resources' do
      invalidator = create_simple_cloudfront_invalidator(config)
      invalidator.
        should_receive(:invalidate).
        with(['article/', '']).
        and_return(:text_report => 'report txt')

      S3Website::Cloudfront::Invalidator.invalidate(config, ['article/index.html'])
    end
  end

  def create_simple_cloudfront_invalidator(config)
    invalidator = double('invalidator')
    SimpleCloudfrontInvalidator::CloudfrontClient.
      should_receive(:new).
      with(config['s3_id'], config['s3_secret'], config['cloudfront_distribution_id']).
      and_return(invalidator)
    invalidator
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
s3_website-1.6.11 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.10 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.9 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.8 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.7 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.6 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.5 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.4 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.3 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.2 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.1 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.6.0 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.5.0 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.4.5 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.4.4 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.4.3 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.4.2 spec/lib/cloudfront/invalidator_spec.rb
s3_website-1.4.1 spec/lib/cloudfront/invalidator_spec.rb