# 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::PackageInstaller do def success_result(output=nil) flexmock('res', :success? => true, :output => output) end before(:each) do [:report_check, :report_result, :report_fatal, :report_success].each do |meth| flexmock(RightConf::PackageInstaller.instance).should_receive(meth) end end it 'should install packages on Ubuntu' do flexmock(RightConf::Platform.instance).should_receive(:family).and_return(:linux) flexmock(RightConf::Platform.instance).should_receive(:flavor).and_return('ubuntu') should_sudo('apt-get', 'install', '-y', 'deb1', 'deb2').once.and_return(success_result) RightConf::PackageInstaller.install(['deb1', 'deb2']) end it 'should install packages on Centos' do flexmock(RightConf::Platform.instance).should_receive(:family).and_return(:linux) flexmock(RightConf::Platform.instance).should_receive(:flavor).and_return('centos') should_sudo('yum', 'install', '-y', 'cent1', 'cent2').once.and_return(success_result) RightConf::PackageInstaller.install(['cent1', 'cent2']) end it 'should install packages on Darwin' do flexmock(RightConf::Platform.instance).should_receive(:family).and_return(:darwin) flexmock(RightConf::BrewInstaller).should_receive(:check_and_install).once should_execute('brew', 'install', 'mac1').once.and_return(success_result) should_sudo('brew', 'link', 'mac1').once.and_return(success_result) should_execute('brew', 'install', 'mac2').once.and_return(success_result) should_sudo('brew', 'link', 'mac2').once.and_return(success_result) RightConf::PackageInstaller.install(['mac1', 'mac2']) end end