<commit_before>require 'spec_helper'

describe 'YAML adapter' do
  describe 'options' do
    let!(:data) { I18n::Tasks::Data::Yaml.new }
    after { TestCodebase.teardown }

    it 'reads' do
      data.config = {read: ['a.yml', '{b,c}.yml']}
      TestCodebase.setup(
          'a.yml' => {en: {a: 1}}.stringify_keys.to_yaml,
          'b.yml' => {en: {b: 1}}.stringify_keys.to_yaml,
          'c.yml' => {en: {c: 1}}.stringify_keys.to_yaml
      )
      TestCodebase.in_test_app_dir {
        data[:en].should == {a: 1, b: 1, c: 1}
      }
    end

    it 'writes' do
      data.config = {read: 'a.yml', write: [['{:}.*', '\1.%{locale}.yml']]}
      keys        = {'a' => <KEY>'}, 'x' => 'y'}
      locale_data = {'pizza' => keys, 'sushi' => keys}
      TestCodebase.setup
      TestCodebase.in_test_app_dir {
        data[:en] = locale_data
        files     = %w(pizza.en.yml sushi.en.yml)
        Dir['*.yml'].should == files.sort
        files.each { |f| YAML.load_file(f)['en'].should == {File.basename(f, '.en.yml') => keys} }
      }
    end<commit_msg>fix spec<commit_after>require 'spec_helper'

describe 'YAML adapter' do
  describe 'options' do
    let!(:data) { I18n::Tasks::Data::Yaml.new }
    after { TestCodebase.teardown }

    it 'reads' do
      data.config = {read: ['a.yml', '{b,c}.yml']}
      TestCodebase.setup(
          'a.yml' => {en: {a: 1}}.stringify_keys.to_yaml,
          'b.yml' => {en: {b: 1}}.stringify_keys.to_yaml,
          'c.yml' => {en: {c: 1}}.stringify_keys.to_yaml
      )
      TestCodebase.in_test_app_dir {
        data[:en].should == {a: 1, b: 1, c: 1}
      }
    end

    it 'writes' do
      data.config = {read: 'a.yml', write: [['{:}.*', '\1.%{locale}.yml']]}
      keys        = {'a' => <KEY>'}
      locale_data = {'pizza' => keys, 'sushi' => keys}
      TestCodebase.setup
      TestCodebase.in_test_app_dir {
        data[:en] = locale_data
        files     = %w(pizza.en.yml sushi.en.yml)
        Dir['*.yml'].sort.should == files.sort
        files.each { |f| YAML.load_file(f)['en'].should == {File.basename(f, '.en.yml') => keys} }
      }
    end
{'fraction_non_alphanumeric': 0.20416864045476077, 'fraction_numerical': 0.008526764566556135, 'mean_word_length': 2.3207547169811322, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '7455109', 'n_tokens_mistral': 867, 'n_tokens_neox': 806, 'n_words': 150}