Sha256: 28ff5c948fafd6eb8734097ffc4bbe4c720a01711538be3bf872729975dcbab4

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'
require 'json'

describe Stackster do

  before do
    @attributes = { "param1" => "value1", "param3" => "value3" }
    @template_json = '{ "Parameters": 
                        { 
                          "param1" : 
                            {
                              "Description" : "param-1"
                            },
                          "param2" : 
                            {
                              "Description" : "param-2"
                            }
                        }
                      }'
  end

  it "should map the attributes to a template's parameters and create a stack " do
    config_mock = mock 'config mock'
    entry_mock = mock 'entry mock'
    file_mock = mock 'file mock'
    cloud_formation_mock = mock 'cloud formation mock'
    Stackster::AWS::CloudFormation.should_receive(:new).
                                   with(:config => config_mock).
                                   and_return cloud_formation_mock
    File.should_receive(:open).with('path_to_file').
                               and_return file_mock
    file_mock.should_receive(:read).and_return @template_json
    entry_mock.should_receive(:attributes).and_return @attributes
    cloud_formation_mock.should_receive(:create).
                         with(:name      => 'test-stack', 
                              :parameters => { 'param1' => 'value1' },
                              :template   => @template_json)
    stack_creater = Stackster::StackCreater.new :name          => 'test-stack',
                                                :template_file => 'path_to_file',
                                                :entry         => entry_mock,
                                                :config        => config_mock

    stack_creater.create
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stackster-0.2.2 spec/stack/stack_creater_spec.rb
stackster-0.2.1 spec/stack/stack_creater_spec.rb
stackster-0.2.0 spec/stack/stack_creater_spec.rb