Sha256: b284322669f8bb3938dd04cbe687a3aadf570f37cdb95da4e5b7611dd7d11af2
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
require "spec_helper" require "cascade/error_handler" describe Cascade::ErrorHandler do def described_class Cascade::ErrorHandler end let(:error_store) do ->(row, reason) do @errors ||= [] @errors << [row, reason] end end let(:row) { Struct.new(:fields) } subject { described_class.new(error_store: error_store) } Cascade::ErrorHandler::HANDLING_EXCEPTIONS.each do |exception| it "catch #{exception} and send info to error store" do subject.with_errors_handling(row) { raise exception } assert_includes @errors, [row, exception.to_s] end it "raises #{exception} if raise_parse_errors setting is true" do described_class.stub(:raise_parse_errors, true) do assert_raises(exception) do subject.with_errors_handling(row) { raise exception } end end end end describe "DEFAULT_ERROR_STORE" do it "create new array and push row with reason" do result = Cascade::ErrorHandler::DEFAULT_ERROR_STORE.call(:row, :reason) assert_includes result, %i(row reason) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cascade-rb-0.1.5 | spec/lib/error_handler_spec.rb |