Skip to content

Commit

Permalink
Fix flaky translation test
Browse files Browse the repository at this point in the history
This replaces the call to a stubbed method with a call to the original
method. This should be more reliable and less likely to break during
CI runs.
  • Loading branch information
BlakeWilliams committed Sep 12, 2023
1 parent d1b3707 commit 4c6588e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/sandbox/test/translatable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ def test_translate_uses_the_helper_when_no_sidecar_file_is_provided
# The cache needs to be kept clean for TranslatableComponent, otherwise it will rely on the
# already created i18n_backend.
ViewComponent::CompileCache.invalidate_class!(TranslatableComponent)
original_method = TranslatableComponent.method(:sidecar_files)

ViewComponent::Base.stub(
:sidecar_files,
->(exts) { exts.include?("yml") ? [] : TranslatableComponent.__minitest_stub___sidecar_files(exts) }
->(exts) { exts.include?("yml") ? [] : original_method.call(exts) }
) do
assert_equal "MISSING", translate(".hello", default: "MISSING")
assert_equal "Hello from Rails translations!", translate("hello")
Expand Down

0 comments on commit 4c6588e

Please sign in to comment.