Skip to content

Commit

Permalink
fix read model tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszNaKodach committed Sep 27, 2024
1 parent cb860a6 commit e6a59c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions heroesofddd_rails_application/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e6a59c3

Please sign in to comment.