spec/sprinkle/actors/capistrano_spec.rb in crafterm-sprinkle-0.1.5 vs spec/sprinkle/actors/capistrano_spec.rb in crafterm-sprinkle-0.1.6
- old
+ new
@@ -97,21 +97,41 @@
@roles = %w( app )
@name = 'name'
@cap = create_cap do; recipes 'deploy'; end
@cap.stub!(:run).and_return
+
+ @testing_errors = false
end
it 'should dynamically create a capistrano task containing the commands' do
@cap.config.should_receive(:task).and_return
end
it 'should invoke capistrano task after creation' do
@cap.should_receive(:run).with(@name).and_return
end
+
+ it 'should raise capistrano errors when suppressing parameter is not set' do
+ @testing_errors = true
+
+ @cap.should_receive(:run).and_raise(::Capistrano::CommandError)
+ lambda { @cap.process @name, @commands, @roles }.should raise_error(::Capistrano::CommandError)
+ end
+
+ it 'should not raise errors and instead return false when suppressing parameter is set' do
+ @testing_errors = true
+
+ @cap.should_receive(:run).and_raise(::Capistrano::CommandError)
+
+ value = nil
+ lambda { value = @cap.process(@name, @commands, @roles, true) }.should_not raise_error(::Capistrano::CommandError)
+
+ value.should_not be
+ end
after do
- @cap.process @name, @commands, @roles
+ @cap.process @name, @commands, @roles unless @testing_errors
end
end
describe 'generated task' do