<commit_before>require 'spec_helper'
require 'active_record'
require 'logger'
require 'i18n'

ActiveRecord::Base.logger = Logger.new(STDERR)

class LocalizerTestModel < ActiveRecord::Base
  include AASM

  attr_accessor :aasm_state

  aasm_initial_state :open
  aasm_state :opened
  aasm_state :closed

  aasm_event :close
  aasm_event :open
end

describe AASM::SupportingClasses::Localizer do
  before(:all) do
    I18n.load_path << 'spec/en.yml'
    I18n.default_locale = :en
  end

  after(:all) { I18n.load_path.clear }

  let (:foo_opened) { LocalizerTestModel.new }
  let (:foo_closed) { LocalizerTestModel.new.tap { |x| x.aasm_state = :closed  } }

  context 'aasm_human_state' do
    it 'should return translated state value' do
      foo_opened.aasm_human_state.should == "It's opened now!"
    end

    it 'should return humanized value if not localized' do<commit_msg>make localizer specs independent from others<commit_after>require 'spec_helper'
require 'active_record'
require 'logger'
require 'i18n'

ActiveRecord::Base.logger = Logger.new(STDERR)

class LocalizerTestModel < ActiveRecord::Base
  include AASM

  attr_accessor :aasm_state

  aasm_initial_state :open
  aasm_state :opened
  aasm_state :closed

  aasm_event :close
  aasm_event :open
end

describe AASM::SupportingClasses::Localizer do
  before(:all) do
    I18n.load_path << 'spec/en.yml'
    I18n.default_locale = :en
    I18n.reload!
  end

  after(:all) do
    I18n.load_path.clear
  end

  let (:foo_opened) { LocalizerTestModel.new }
  let (:foo_closed) { LocalizerTestModel.new.tap { |x| x.aasm_state = :closed  } }

  context 'aasm_human_state' do
    it 'should return translated state value' do
      foo_opened.aasm_human_state.should == "It's opened now!"
    end

    it 'should return humanized value if not localized' do
{'fraction_non_alphanumeric': 0.09366391184573003, 'fraction_numerical': 0.009917355371900827, 'mean_word_length': 4.27906976744186, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5909220', 'n_tokens_mistral': 669, 'n_tokens_neox': 616, 'n_words': 153}