# 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::GitRepoConfigurator do before(:each) do lang = RightConf::Language.parse('git_repo { repo "git"; install_path "./git" }') @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(' ') } @abf = { :abort_on_failure => 'Failed to clone git into ./git' } end it 'should clone' do flexmock(RightConf::Command.instance).should_receive(:execute).with('git', 'clone', 'git', './git', @abf).once @configurator.run end it 'run the build commands' do @configurator.instance_eval { build_commands('do one, do two') } flexmock(RightConf::Command.instance).should_receive(:execute).with('git', 'clone', 'git', './git', @abf).once flexmock(Dir).should_receive(:chdir).with('./git', Proc).once.and_yield flexmock(RightConf::Command.instance).should_receive(:execute).with('do', 'one', :abort_on_failure => 'do one failed').once flexmock(RightConf::Command.instance).should_receive(:execute).with('do', 'two', :abort_on_failure => 'do two failed').once @configurator.run end it 'should honor only_if' do @configurator.instance_eval { only_if(lambda { false }) } flexmock(RightConf::Command.instance).should_receive(:execute).and_return { raise "Command should not execute" } @configurator.run end end