Sha256: 55d60abe04a6ea29af039f83c6cbed4f73d939e63e8ea7bbfae617cab810c77d

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 KB

Contents

require_relative 'helper'

describe 'CfnFlow::Template' do

  let(:template) {
    CfnFlow::Template.new(from: 'spec/data/sqs.template', prefix: 'p', bucket: 'b')
  }

  let(:yml_template) {
    CfnFlow::Template.new(from: 'spec/data/sqs.yml', prefix: 'p', bucket: 'b')
  }

  let(:not_a_template) {
    CfnFlow::Template.new(from: 'spec/data/cfn-flow.yml', prefix: 'p', bucket: 'b')
  }

  describe '#initialize' do
    subject { CfnFlow::Template }

    it('succeeds') do
      subject.new(from: 'f', prefix: 'p', bucket: 'b').must_be_kind_of CfnFlow::Template
    end

    it('requires args') do
      -> { subject.new }.must_raise(ArgumentError)
    end
  end

  describe '#yaml?' do
    it 'works' do
      yml_template.yaml?.must_equal true
      yml_template.json?.must_equal false
      template.yaml?.must_equal false
      template.json?.must_equal true
    end
  end

  describe '#is_cfn_template?' do
    it 'works' do
      yml_template.is_cfn_template?.must_equal true
      template.is_cfn_template?.must_equal true
      not_a_template.is_cfn_template?.must_equal false
    end
  end

  describe '#validate!' do
    it 'can succeed' do
      template.send(:cfn).stub_responses(:validate_template)
      template.validate!
    end
    it 'can raise an error' do
      template.send(:cfn).stub_responses(:validate_template, 'ValidationError')
      -> { template.validate! }.must_raise Aws::CloudFormation::Errors::ValidationError
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cfn-flow-0.2.1 spec/cfn-flow_template_spec.rb
cfn-flow-0.2.0 spec/cfn-flow_template_spec.rb
cfn-flow-0.1.2 spec/cfn-flow_template_spec.rb
cfn-flow-0.1.1 spec/cfn-flow_template_spec.rb
cfn-flow-0.1.0 spec/cfn-flow_template_spec.rb