Sha256: def855ba28d86c7873a5a5dd692a083e2f1970b9d48b7bdd8aa7e0705455e75c

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe Aigu::RailsImporter do
  describe :build_blob do
    let(:importer) { Aigu::RailsImporter.new }
    let(:expanded_content) { importer.send(:expand_content_values, content) }

    let(:content) do
      {
        'users.fr|fr.users.index.title' => 'Foo',
        'users.fr|fr.users.index.actions___KEY___0' => 'Bar',
        'users.fr|fr.users.index.actions___KEY___2' => '___TRUE___',
        'users.fr|fr.users.index.actions___KEY___1' => 'Baz',
        'users.fr|fr.users.index.footer' => 'Bla',
        'users.fr|fr.users.index.shown' => '___FALSE___',
        'users.fr|fr.users.index.hidden' => '___TRUE___',
        'users.fr|fr.users.index.what' => '___NULL___'
      }
    end

    let(:expected_content) do
      {
        'users.fr|fr.users.index.title' => 'Foo',
        'users.fr|fr.users.index.actions' => [
          'Bar',
          'Baz',
          true
        ],
        'users.fr|fr.users.index.footer' => 'Bla',
        'users.fr|fr.users.index.shown' => false,
        'users.fr|fr.users.index.hidden' => true,
        'users.fr|fr.users.index.what' => nil
      }
    end

    it { expect(expanded_content).to eql expected_content }
  end

  describe :localize_content_keys do
    let(:exporter) { Aigu::RailsImporter.new }
    let(:localized_keys) { exporter.send(:localize_content_keys, content).keys }
    before { exporter.instance_variable_set(:@locale, 'fr') }

    let(:content) do
      {
        'users|users.index.title' => 'Foo',
        'users|users.index.footer' => 'Bla',
        'users|users.index.fr.shown' => false,
        'users|users.index.hidden' => true,
        'foo/users|users.index.what' => nil
      }
    end

    let(:expected_keys) do
      [
        'users.fr|fr.users.index.title',
        'users.fr|fr.users.index.footer',
        'users.fr|fr.users.index.fr.shown',
        'users.fr|fr.users.index.hidden',
        'foo/users.fr|fr.users.index.what'
      ]
    end

    it { expect(localized_keys).to eql expected_keys }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aigu-0.5.1 spec/aigu/rails_importer_spec.rb
aigu-0.5 spec/aigu/rails_importer_spec.rb