Sha256: 816f494077575fd8950084c60ac76a5f95443caeb644f171b1d66ff7ad16dac8

Contents?: true

Size: 1.98 KB

Versions: 12

Compression:

Stored size: 1.98 KB

Contents

require 'spec_helper'
require 'simple_deploy/cli'

describe SimpleDeploy::CLI::Attributes do

  describe 'show' do
    before do
      @config  = mock 'config'
      @logger  = stub 'logger'
      @options = { :environment => 'my_env',
                   :log_level   => 'debug',
                   :name        => 'my_stack' }
      @stack   = stub :attributes => { 'foo' => 'bar', 'baz' => 'blah' }

      SimpleDeploy::Config.stub(:new).and_return(@config)
      @config.should_receive(:environment).with('my_env').and_return(@config)
      SimpleDeploy::SimpleDeployLogger.should_receive(:new).
                                       with(:log_level => 'debug').
                                       and_return(@logger)
      SimpleDeploy::Stack.should_receive(:new).
                          with(:config      => @config,
                               :environment => 'my_env',
                               :logger      => @logger,
                               :name        => 'my_stack').
                          and_return(@stack)
    end

    it 'should output the attributes' do
      SimpleDeploy::CLI::Shared.should_receive(:valid_options?).
                                with(:provided => @options,
                                     :required => [:environment, :name])
      Trollop.stub(:options).and_return(@options)
      subject.should_receive(:puts).with("foo=bar")
      subject.should_receive(:puts).with("baz=blah")
      subject.show
    end

    context 'with --as-command-args' do
      before do
        @options[:as_command_args] = true
        Trollop.stub(:options).and_return(@options)
        SimpleDeploy::CLI::Shared.should_receive(:valid_options?).
                                  with(:provided => @options,
                                       :required => [:environment, :name])
      end

      it 'should output the attributes as command arguments' do
        subject.should_receive(:puts).with("-a baz=blah -a foo=bar")
        subject.show
      end
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
simple_deploy-0.6.4 spec/cli/attributes_spec.rb
simple_deploy-0.6.3 spec/cli/attributes_spec.rb
simple_deploy-0.6.2 spec/cli/attributes_spec.rb
simple_deploy-0.6.1 spec/cli/attributes_spec.rb
simple_deploy-0.6.0 spec/cli/attributes_spec.rb
simple_deploy-0.5.6 spec/cli/attributes_spec.rb
simple_deploy-0.5.5 spec/cli/attributes_spec.rb
simple_deploy-0.5.4 spec/cli/attributes_spec.rb
simple_deploy-0.5.3 spec/cli/attributes_spec.rb
simple_deploy-0.5.2 spec/cli/attributes_spec.rb
simple_deploy-0.5.1 spec/cli/attributes_spec.rb
simple_deploy-0.5.0 spec/cli/attributes_spec.rb