Sha256: 51d4f413497e3c17d646ffa4e9e97a86b2f7f5a8031d8619878bee8239d0435d
Contents?: true
Size: 1.62 KB
Versions: 17
Compression:
Stored size: 1.62 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Actions::HandleError do context '#initialize' do it 'requires an exception' do expect { Actions::HandleError.new(Exceptions::DefaultError.new('message')) }.not_to raise_error end end context '#run' do it 'handles errors' do action = Actions::HandleError.new(RuntimeError.new) silence(:stderr) do begin action.run rescue SystemExit => e @err = e end end expect(@err).to be_kind_of(SystemExit) expect(@err.status).to be(99) end it 'parses original message with json' do action = Actions::HandleError.new(RuntimeError.new(JSON.dump(name: 'asdf'))) silence(:stderr) do begin action.run rescue SystemExit => e @err = e end end expect(@err).to be_kind_of(SystemExit) expect(@err.status).to be(99) end it 'returns an empty hash on parse error' do action = Actions::HandleError.new(RuntimeError.new('asdf')) silence(:stderr) do begin action.run rescue SystemExit => e @err = e end end expect(@err).to be_kind_of(SystemExit) expect(@err.status).to be(99) end it 'returns an empty hash if result is not a hash' do action = Actions::HandleError.new(RuntimeError.new(JSON.dump(['asdf']))) silence(:stderr) do begin action.run rescue SystemExit => e @err = e end end expect(@err).to be_kind_of(SystemExit) expect(@err.status).to be(99) end end end
Version data entries
17 entries across 17 versions & 1 rubygems