Sha256: df1fff51112cd3cd848d5ddc1ccbba01bcfeeed6161376802278d3c0a96f1621
Contents?: true
Size: 1009 Bytes
Versions: 13
Compression:
Stored size: 1009 Bytes
Contents
require_relative 'test_helper' require 'adrian/failure_handler' describe Adrian::FailureHandler do before do @handler = Adrian::FailureHandler.new $failure = nil @handler.add_rule(RuntimeError) { :runtime } @handler.add_rule(StandardError) { :standard } end it "should match rules in the order they were added" do block = @handler.handle(RuntimeError.new) assert block block.call.must_equal :runtime block = @handler.handle(StandardError.new) assert block block.call.must_equal :standard end it "should do nothing when no rules match" do @handler.handle(Exception.new).must_be_nil end describe "the success rule" do before do @handler = Adrian::FailureHandler.new @handler.add_rule(nil) { :success } end it "should match when there is no exception" do @handler.handle(RuntimeError.new).must_be_nil block = @handler.handle(nil) assert block block.call.must_equal :success end end end
Version data entries
13 entries across 13 versions & 1 rubygems