<commit_before>require 'rails_helper'

describe ApplicationHelper do
  describe 'active_nav_class' do
    it 'returns active when on the current page' do
      allow(helper).to receive(:current_page?).and_return(true)

      result = helper.active_nav_class("/test")
      expect(result).to eq "active"
    end

    it 'returns empty string when not on current page' do
      allow(helper).to receive(:current_page?).and_return(false)

      result = helper.active_nav_class("/test")
      expect(result).to eq ""
    end
  end

  describe 'add_rtl_body_class' do
    it 'adds rtl body class if locale is Arabic' do
      I18n.locale = :ar
      expect(helper.add_rtl_body_class('other classes')).to eq 'other classes rtl'
    end

    it 'adds rtl body class if locale is Farsi' do
      I18n.locale = :fa
      expect(helper.add_rtl_body_class('other classes')).to eq 'other classes rtl'
    end<commit_msg>Hold value of I18n.locale with ApplicationHelperSpec (#3474)<commit_after>require 'rails_helper'

describe ApplicationHelper do
  describe 'active_nav_class' do
    it 'returns active when on the current page' do
      allow(helper).to receive(:current_page?).and_return(true)

      result = helper.active_nav_class("/test")
      expect(result).to eq "active"
    end

    it 'returns empty string when not on current page' do
      allow(helper).to receive(:current_page?).and_return(false)

      result = helper.active_nav_class("/test")
      expect(result).to eq ""
    end
  end

  describe 'add_rtl_body_class' do
    around do |example|
      current_locale = I18n.locale
      example.run
      I18n.locale = current_locale
    end

    it 'adds rtl body class if locale is Arabic' do
      I18n.locale = :ar
      expect(helper.add_rtl_body_class('other classes')).to eq 'other classes rtl'
    end

    it 'adds rtl body class if locale is Farsi' do
      I18n.locale = :fa
      expect(helper.add_rtl_body_class('other classes')).to eq 'other classes rtl'
    end
{'fraction_non_alphanumeric': 0.0931520644511581, 'fraction_numerical': 0.00906344410876133, 'mean_word_length': 3.2731182795698923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7136278', 'n_tokens_mistral': 641, 'n_tokens_neox': 607, 'n_words': 182}