Sha256: be4d169e0893bb7383cec4de716381f972b29438bc998ca90848f576a5293b16
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
# encoding: utf-8 require 'spec_helper' describe ErrorHandler do let(:exception) { StandardError.new } context '.create' do it 'requires an exception class, a message and a exit code' do expect { ErrorHandler.create( exception: StandardError, message: 'This is a standard error', exit_code: 1, ) }.not_to raise_error end end context '.find' do it 'finds a suitable error handler' do ErrorHandler.create( exception: StandardError, message: 'This is a standard error', exit_code: 1, ) expect(ErrorHandler.find(exception)).not_to be_nil end it 'returns a default exception if the requested one cannote be found' do expect(ErrorHandler.find(RuntimeError.new).exception).to be(StandardError) end end context '#exception' do it 'returns the exception' do handler = ErrorHandler.create( exception: StandardError, message: 'This is a standard error', exit_code: 1, ) expect(handler.exception).to eq(StandardError) end end context '#run' do it 'runs the error handler' do handler = ErrorHandler.new( exception: StandardError, message: 'This is a standard error', exit_code: 1, ) handler.original_message = 'blub' LocalPac.ui_logger.level = :debug result = capture(:stderr) do begin handler.run rescue SystemExit => e expect(e.status).to eq(1) end end expect(result).to include('standard error') expect(result).to include('blub') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
local_pac-0.6.3 | spec/error_handler_spec.rb |
local_pac-0.6.2 | spec/error_handler_spec.rb |
local_pac-0.6.1 | spec/error_handler_spec.rb |