Skip to content

Commit

Permalink
Improve specificity of test
Browse files Browse the repository at this point in the history
This test is to check that the contents method returns the memoised
@contents when repeatedly called, rather than running line 10
https://github.com/alphagov/government-frontend/blob/6dbefab2ed477a6328f57227494b4561f811f239/app/presenters/content_item/contents_list.rb#L10

The original test checked if the code on line 11 was run, ie the contents_items method.
But the content_items method is called in two places in this module, within both the contents method (which
this test is testing) but also within the show_contents_items? method.This means changes
to the show_contents_items? code unexpectedly breaks this test. This commit reduces the scope
of the test so that unexpected test failures no longer occur.
  • Loading branch information
hannako committed Oct 15, 2024
1 parent 6dbefab commit da0f7c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/presenters/content_item/contents_list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def body
end
end

@contents_list.expects(:contents_items).returns([{ text: "A heading", id: "custom" }]).once
@contents_list.expects(:show_contents_list?).returns(true).once
@contents_list.contents
@contents_list.contents
end
Expand Down

0 comments on commit da0f7c1

Please sign in to comment.