Sha256: 26ec74a74b593e27eeab51f30ccde867be2c51bbea3a7cde0a9f5760895e6c50

Contents?: true

Size: 1.62 KB

Versions: 12

Compression:

Stored size: 1.62 KB

Contents

# Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
#
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
# reproduction, modification, or disclosure of this program is
# strictly prohibited. Any use of this program by an authorized
# licensee is strictly subject to the terms and conditions,
# including confidentiality obligations, set forth in the applicable
# License Agreement between RightScale.com, Inc. and
# the licensee

require File.join(File.dirname(__FILE__), 'spec_helper')

describe RightConf::Command do

  def success_result
    RightConf::CommandResult.new(0, '')
  end

  def failed_result
    RightConf::CommandResult.new(1, '')
  end

  it 'should execute' do
    flexmock(RightConf::Platform.instance).should_receive(:dispatch).with('test', nil, '42', Proc).once.and_return(success_result)
    RightConf::Command.execute('test', '42')
  end

  it 'should report fatal errors when required to' do
    flexmock(RightConf::Platform.instance).should_receive(:dispatch).with('test', nil, '42', 
       Proc).once.and_return(failed_result)
    flexmock(RightConf::Command.instance).should_receive(:report_fatal).once.with("FAILED: 'test 42' returned\n1")
    RightConf::Command.execute('test', '42', :abort_on_failure => 'FAILED')
  end
  
  it 'should setup environment variables' do
    ENV['THIS_IS_A_TEST_ENV_VALUE'].should be_nil
    res = RightConf::Command.execute('env', :env => { 'THIS_IS_A_TEST_ENV_VALUE' => '42' })
    ENV['THIS_IS_A_TEST_ENV_VALUE'].should be_nil
    res.output.should =~ /^THIS_IS_A_TEST_ENV_VALUE=42$/
  end

end


Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rconf-0.9.18 spec/command_spec.rb
rconf-0.9.17 spec/command_spec.rb
rconf-0.9.12 spec/command_spec.rb
rconf-0.9.11 spec/command_spec.rb
rconf-0.9.10 spec/command_spec.rb
rconf-0.9.9 spec/command_spec.rb
rconf-0.9.8 spec/command_spec.rb
rconf-0.9.7 spec/command_spec.rb
rconf-0.9.6 spec/command_spec.rb
rconf-0.9.4 spec/command_spec.rb
rconf-0.8.30 spec/command_spec.rb
rconf-0.8.29 spec/command_spec.rb