# Copyright (C) 2011 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.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) describe RightConf::BundlerConfigurator do def success_result(output=nil) flexmock('res', :success? => true, :output => output) end before(:each) do lang = RightConf::Language.parse('bundler { version "0" }') @configurator = lang.configurators.first [:report_check, :report_result, :report_success].each do |meth| flexmock(@configurator).should_receive(meth) end flexmock(@configurator).should_receive(:report_fatal).and_return { |*args| raise args.join(' ') } RightConf::Command.instance.instance_variable_set(:@rvm_prefix, 'r@g') end after(:each) do RightConf::Command.instance.instance_variable_set(:@rvm_prefix, nil) end it 'should succeed when bundler succeeds' do flexmock(RightConf::Command.instance).should_receive(:execute_in_ruby).once.with( 'bundle', '--version').and_return(success_result('0')) flexmock(RightConf::Command.instance).should_receive(:execute_in_ruby).once.with( 'bundle','_0_', 'install', {:abort_on_failure=>"Failed to install gems"}).and_return(success_result) @configurator.run_linux end it 'should install bunlder if needed' do flexmock(RightConf::Command.instance).should_receive(:execute_in_ruby).twice.with( 'bundle', '--version').and_return(success_result('1')) flexmock(RightConf::Command.instance).should_receive(:execute_in_ruby).once.with( 'bundle','_0_', 'install', {:abort_on_failure=>"Failed to install gems"}).and_return(success_result) flexmock(RightConf::Command.instance).should_receive(:execute_in_ruby).once.with( 'gem', 'uninstall', 'bundler', '-a', '-x').and_return(success_result) flexmock(RightConf::Command.instance).should_receive(:execute_in_ruby).once.with( 'gem', 'install', 'bundler', '-v', '0', '--no-ri', '--no-rdoc', {:abort_on_failure=>"Failed to install bundler"}).once.and_return(success_result) @configurator.run_linux end end