4 CodedExceptionMatcher.new(args)
7 class CodedExceptionMatcher
11 raise "Need at least an exception to match" if args.size == 0
13 @expected_code = @args.shift
14 @expected_data = @args.shift
17 @failure_expected = nil
25 unless e.is_a?(MCollective::CodedError)
27 @failure_expected = "MCollective::CodedError"
28 @failure_got = e.class
32 unless [e.code, e.default].include?(@expected_code)
34 @failure_expected = @expected_code
40 unless e.args == @expected_data
41 @failure_type = :arguments
42 @failure_expected = @expected_data.inspect
43 @failure_got = e.args.inspect
55 "Expected an exception of type %s but got %s" % [@failure_expected, @failure_got]
57 "Expected a message code %s but got %s" % [@failure_expected, @failure_got]
59 "Expected arguments %s but got %s" % [@failure_expected, @failure_got]
63 def negative_failure_message
66 "Expected an exception of type %s but got %s" % [@failure_got, @failure_expected]
68 "Expected a message code %s but got %s" % [@failure_got, @failure_expected]
70 "Expected arguments %s but got %s" % [@failure_got, @failure_expected]