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.
This commit is contained in:
Javi Martín
2021-03-26 23:29:31 +01:00
parent f3595833fd
commit 71053fd334

View File

@@ -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