diff --git a/heroesofddd_rails_application/test/lib/heroes/creature_recruitment/read/dwelling_read_model_application_test.rb b/heroesofddd_rails_application/test/lib/heroes/creature_recruitment/read/dwelling_read_model_application_test.rb index 222faaa..96fb5a4 100644 --- a/heroesofddd_rails_application/test/lib/heroes/creature_recruitment/read/dwelling_read_model_application_test.rb +++ b/heroesofddd_rails_application/test/lib/heroes/creature_recruitment/read/dwelling_read_model_application_test.rb @@ -29,7 +29,7 @@ def test_create_on_dwelling_built creature_id: @creature_id, available_creatures: 0, cost_per_troop: @cost_per_troop) - assert_equal expected_state, state + assert_read_models_equal expected_state, state end def test_update_on_available_creatures_changed @@ -46,7 +46,7 @@ def test_update_on_available_creatures_changed creature_id: @creature_id, available_creatures: 99, cost_per_troop: @cost_per_troop) - assert_equal expected_state, state + assert_read_models_equal expected_state, state end def test_update_on_creature_recruited @@ -64,7 +64,7 @@ def test_update_on_creature_recruited creature_id: @creature_id, available_creatures: 98, cost_per_troop: @cost_per_troop) - assert_equal expected_state, state + assert_read_models_equal expected_state, state end def default_app_context diff --git a/heroesofddd_rails_application/test/test_helper.rb b/heroesofddd_rails_application/test/test_helper.rb index 6951018..459a08d 100644 --- a/heroesofddd_rails_application/test/test_helper.rb +++ b/heroesofddd_rails_application/test/test_helper.rb @@ -64,4 +64,10 @@ def assert_event_with_data(stream_stored_events, stored_event, data) end assert matching_event, "Expected to find a #{stored_event} event with data #{data}, but none was found." end + + def assert_read_models_equal(expected_state, current_state) + excluded_attributes = %w[id created_at updated_at lock_version] + assert_equal expected_state.attributes.except(*excluded_attributes), + current_state.attributes.except(*excluded_attributes) + end end