@@ -6,9 +6,9 @@ class ReservationProcessTest < Test
66
77 def test_happy_path
88 process = ReservationProcess . new ( event_store , command_bus )
9- assert_success_event do
10- given ( [ offer_accepted ] ) . each { |event | process . call ( event ) }
11- end
9+
10+ given ( [ offer_accepted ] ) . each { |event | process . call ( event ) }
11+
1212 assert_all_commands (
1313 Inventory ::Reserve . new ( product_id : product_id , quantity : 1 ) ,
1414 Inventory ::Reserve . new ( product_id : another_product_id , quantity : 2 ) ,
@@ -33,14 +33,13 @@ def test_rejects_order_and_compensates_stock_when_sth_is_unavailable
3333 enhanced_command_bus = EnhancedFakeCommandBus . new ( command_bus , failing_command => Inventory ::InventoryEntry ::InventoryNotAvailable )
3434 process = ReservationProcess . new ( event_store , enhanced_command_bus )
3535
36- assert_failure_event do
37- given ( [ offer_accepted ] ) . each { |event | process . call ( event ) }
38- end
36+ given ( [ offer_accepted ] ) . each { |event | process . call ( event ) }
37+
3938 assert_all_commands (
4039 failing_command ,
4140 Inventory ::Reserve . new ( product_id : another_product_id , quantity : 2 ) ,
4241 Inventory ::Release . new ( product_id : another_product_id , quantity : 2 ) ,
43- Pricing ::RejectOffer . new ( order_id : order_id ) ,
42+ Pricing ::RejectOffer . new ( order_id : order_id , reason : "Some products were unavailable" , unavailable_products : [ product_id ] ) ,
4443 )
4544 end
4645
@@ -97,21 +96,5 @@ def order_cancelled
9796 }
9897 )
9998 end
100-
101- def assert_success_event ( &block )
102- assert_events_contain (
103- "ReservationProcess$#{ order_id } " ,
104- ReservationProcessSuceeded . new ( data : { order_id : order_id } ) ,
105- &block
106- )
107- end
108-
109- def assert_failure_event ( &block )
110- assert_events_contain (
111- "ReservationProcess$#{ order_id } " ,
112- ReservationProcessFailed . new ( data : { order_id : order_id , unavailable_products : [ product_id ] } ) ,
113- &block
114- )
115- end
11699 end
117100end
0 commit comments