Sha256: a96bde686c46b33aae8cbd85de8467b683e2ed7775b736fd414f096a7c5ba3d7

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'
require 'generators/i18n_locale/i18n_locale_generator'

describe I18nLocaleGenerator do
  subject { I18nLocaleGenerator.new(['ja']) }

  describe 'add_locale_config' do
    describe 'when i18n.default_locale is configured in environment.rb' do
      before do
        @config = "
module Tes
  class Application < Rails::Application
    config.i18n.default_locale = :de
  end
end"
      end

      it 'rewrites the existing default_locale to locale_name value' do
        subject.send(:add_locale_config, @config).should == "
module Tes
  class Application < Rails::Application
    config.i18n.default_locale = 'ja'
  end
end"
      end
    end

    describe 'when i18n.default_locale config is commented in environment.rb' do
      before do
        @config = "
module Tes
  class Application < Rails::Application
    # config.i18n.default_locale = :de
  end
end"
      end

      it 'uncomments the existing commented i18n config and sets locale_name value' do
        subject.send(:add_locale_config, @config).should == "
module Tes
  class Application < Rails::Application
    config.i18n.default_locale = 'ja'
  end
end"
      end
    end

    describe 'when i18n.default_locale is not written in environment.rb' do
      before do
        @config = "
module Tes
  class Application < Rails::Application
    something goes here.
    bla bla bla...
  end
end"
      end

      it 'adds the default_locale config inside the config block and sets locale_name value' do
        subject.send(:add_locale_config, @config).should == "
module Tes
  class Application < Rails::Application
    config.i18n.default_locale = 'ja'
    something goes here.
    bla bla bla...
  end
end"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
i18n_generators-1.2.1 spec/i18n_locale_command_spec.rb
i18n_generators-1.2.0 spec/i18n_locale_command_spec.rb