Rename get method in spec web helper

This commit is contained in:
cyrillefr
2025-04-23 16:31:22 +02:00
parent 8d5292c4ed
commit 6fb1737672
4 changed files with 7 additions and 12 deletions

View File

@@ -221,11 +221,6 @@ Metrics/PerceivedComplexity:
- 'app/models/spree/ability.rb'
- 'app/models/spree/order/checkout.rb'
# Offense count: 1
Naming/AccessorMethodName:
Exclude:
- 'spec/support/request/web_helper.rb'
# Offense count: 1
# Configuration parameters: ForbiddenDelimiters.
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))

View File

@@ -33,7 +33,7 @@ module WebHelper
page.execute_script("I18n.locale = '#{locale}'")
end
def get_i18n_locale
def pick_i18n_locale
page.evaluate_script("I18n.locale;")
end

View File

@@ -19,13 +19,13 @@ RSpec.describe 'Multilingual' do
end
it 'can switch language by params' do
expect(get_i18n_locale).to eq 'en'
expect(pick_i18n_locale).to eq 'en'
expect(get_i18n_translation('spree_admin_overview_enterprises_header')).to eq 'My Enterprises'
expect(page).to have_content 'My Enterprises'
expect(admin_user.locale).to be_nil
visit spree.admin_dashboard_path(locale: 'es')
expect(get_i18n_locale).to eq 'es'
expect(pick_i18n_locale).to eq 'es'
expect(get_i18n_translation('spree_admin_overview_enterprises_header'))
.to eq 'Mis Organizaciones'
expect(page).to have_content 'Mis Organizaciones'
@@ -35,7 +35,7 @@ RSpec.describe 'Multilingual' do
it 'fallbacks to default_locale' do
visit spree.admin_dashboard_path(locale: 'it')
expect(get_i18n_locale).to eq 'en'
expect(pick_i18n_locale).to eq 'en'
expect(get_i18n_translation('spree_admin_overview_enterprises_header')).to eq 'My Enterprises'
expect(page).to have_content 'My Enterprises'
expect(admin_user.locale).to be_nil

View File

@@ -25,19 +25,19 @@ RSpec.describe 'Multilingual' do
context 'can switch language by params' do
it 'in root path' do
visit root_path
expect(get_i18n_locale).to eq 'en'
expect(pick_i18n_locale).to eq 'en'
expect(get_i18n_translation('label_shops')).to eq 'Shops'
expect(cookies_name).not_to include('locale')
expect(page).to have_content 'SHOPS'
visit root_path(locale: 'es')
expect(get_i18n_locale).to eq 'es'
expect(pick_i18n_locale).to eq 'es'
expect(get_i18n_translation('label_shops')).to eq 'Tiendas'
expect_menu_and_cookie_in_es
# it is not in the list of available of available_locales
visit root_path(locale: 'it')
expect(get_i18n_locale).to eq 'es'
expect(pick_i18n_locale).to eq 'es'
expect(get_i18n_translation('label_shops')).to eq 'Tiendas'
expect_menu_and_cookie_in_es
end