From 71053fd33445b206bd6a8616600014799c7baee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 26 Mar 2021 23:29:31 +0100 Subject: [PATCH] Don't use localization methods in system specs The method `formatted_heading_price` depends on the current locale. When we make a request to `visit budgets_path locale: :es`, the request modifies `I18n.locale` as well. However, if we use JavaScript tests, the process running the test is different than the process handling the request, and so the change in `I18n.locale` does not affect the test. Checking against the actual value we expect makes the test work with and without JavaScript. --- spec/system/budgets/budgets_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/system/budgets/budgets_spec.rb b/spec/system/budgets/budgets_spec.rb index b4a513b67..818b65064 100644 --- a/spec/system/budgets/budgets_spec.rb +++ b/spec/system/budgets/budgets_spec.rb @@ -84,8 +84,8 @@ describe "Budgets" do group1 = create(:budget_group, budget: budget) group2 = create(:budget_group, budget: budget) - heading1 = create(:budget_heading, group: group1) - heading2 = create(:budget_heading, group: group2) + heading1 = create(:budget_heading, group: group1, price: 1_000_000) + heading2 = create(:budget_heading, group: group2, price: 2_000_000) visit budgets_path locale: :es @@ -93,9 +93,9 @@ describe "Budgets" do expect(page).to have_content group1.name expect(page).to have_content group2.name expect(page).to have_content heading1.name - expect(page).to have_content budget.formatted_heading_price(heading1) + expect(page).to have_content "1.000.000 €" expect(page).to have_content heading2.name - expect(page).to have_content budget.formatted_heading_price(heading2) + expect(page).to have_content "2.000.000 €" end end