@@ -39,13 +39,38 @@ module Opera
3939 it { expect ( subject . output! ) . to eq ( :example ) }
4040 end
4141
42- context 'with Failure ' do
43- before { subject . add_error ( :example , 'Example' ) }
42+ context 'with a single error ' do
43+ before { subject . add_error ( :example , 'Example error ' ) }
4444
4545 it 'raises exception' do
4646 expect { subject . output! } . to raise_error ( Opera ::Operation ::Result ::OutputError ) do |error |
47- expect ( error . message ) . to eq ( 'Cannot retrieve output from a Failure.' )
48- expect ( error . errors ) . to eq ( example : [ 'Example' ] )
47+ expect ( error . message ) . to eq (
48+ "Operation failed — output cannot be retrieved.\n - example: Example error"
49+ )
50+ expect ( error . errors ) . to eq ( example : [ 'Example error' ] )
51+ end
52+ end
53+ end
54+
55+ context 'with multiple errors' do
56+ before do
57+ subject . add_errors (
58+ example : [ 'Example error' , 'Unexpected behavior' ] ,
59+ other_example : [ 'Hello darkness, my old friend' ]
60+ )
61+ end
62+
63+ it 'raises exception' do
64+ expect { subject . output! } . to raise_error ( Opera ::Operation ::Result ::OutputError ) do |error |
65+ expect ( error . message ) . to eq (
66+ "Operation failed — output cannot be retrieved.\n " \
67+ "- example: Example error; Unexpected behavior\n " \
68+ "- other_example: Hello darkness, my old friend"
69+ )
70+ expect ( error . errors ) . to eq (
71+ example : [ 'Example error' , 'Unexpected behavior' ] ,
72+ other_example : [ 'Hello darkness, my old friend' ]
73+ )
4974 end
5075 end
5176 end
0 commit comments