guard-puppet/spec/lib/guard/puppet/runner_spec.rb

65 lines
1.6 KiB
Ruby
Raw Normal View History

2011-07-01 02:48:18 +00:00
require 'spec_helper'
require 'guard/puppet/runner'
describe Guard::Puppet::Runner do
let(:options) { {} }
let(:runner) { described_class.new(options) }
describe '#command_line_params' do
subject { runner.command_line_params }
context 'default' do
it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, '-v', 'manifests/site.pp' ] }
2011-07-01 02:48:18 +00:00
end
context 'not verbose' do
let(:options) { { :verbose => false } }
2011-07-01 02:48:18 +00:00
it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, 'manifests/site.pp' ] }
2011-07-01 02:48:18 +00:00
end
context 'manifest' do
let(:options) { { :manifest => '123' } }
it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, '-v', '123' ] }
2011-07-01 02:48:18 +00:00
end
2011-07-05 23:43:36 +00:00
context 'debug' do
let(:options) { { :debug => true} }
it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, '-v', '-d', 'manifests/site.pp' ] }
end
2011-07-01 02:48:18 +00:00
end
describe '#run' do
2011-07-05 23:43:36 +00:00
before do
::Puppet::Util::CommandLine.expects(:new).raises(SystemExit.new(return_value))
end
context 'returns a non-zero value' do
let(:return_value) { 10 }
it 'should return the result of an exit call' do
runner.run.should == return_value
end
end
context 'returns a zero value' do
let(:return_value) { 0 }
let(:messages) do
messages = stub
messages.stubs(:has_failed?).returns(true)
messages
end
before do
Puppet::Util::Log.stubs(:newdestination).returns(messages)
end
2011-07-01 02:48:18 +00:00
2011-07-05 23:43:36 +00:00
it 'should check the status of the messages output' do
runner.run.should == 1
end
2011-07-01 02:48:18 +00:00
end
end
end