Permalink
Browse files

feat(assertions): updating wait_for_event predicate_fn arity

Adding second optional parameter to the predicate_fn.
Predicate_fn now receive the recorded_event as second param.
Containing all the informations about the event.

Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
  • Loading branch information...
Freyskeyd committed Oct 25, 2018
1 parent 50cd809 commit f6155efe3d8953e21aca29a60bd2aa5017325f31
Showing with 3 additions and 2 deletions.
  1. +2 −1 lib/commanded/assertions/event_assertions.ex
  2. +1 −1 test/event/handle_event_test.exs
@@ -162,7 +162,8 @@ defmodule Commanded.Assertions.EventAssertions do
expected_event =
Enum.find(received_events, fn received_event ->
case received_event.event_type do
^expected_type -> apply(predicate_fn, [received_event.data])
^expected_type when is_function(predicate_fn, 2) -> apply(predicate_fn, [received_event.data, received_event])
^expected_type when is_function(predicate_fn, 1) -> apply(predicate_fn, [received_event.data])
_ -> false
end
end)
@@ -93,7 +93,7 @@ defmodule Commanded.Event.HandleEventTest do
:ok = EventStore.append_to_stream(stream_uuid, 1, to_event_data(new_events))
wait_for_event(MoneyDeposited)
wait_for_event(MoneyDeposited, fn event, recorded_event -> event.amount == 50 and recorded_event.event_number == 2 end)
Wait.until(fn ->
assert AppendingEventHandler.received_events() == new_events

0 comments on commit f6155ef

Please sign in to comment.