Sha256: a529e5e17cb8a6c541265f9a907e6038f09d0c875de826d98e3d56dc7d3917f3

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

require 'test_helper'
require 'generators/i18n_locale/i18n_locale_generator'

class I18nLocaleGeneratorTest < Test::Unit::TestCase
  setup do
    @generator = I18nLocaleGenerator.new(['ja'])
  end

  sub_test_case 'add_locale_config' do
    test 'when i18n.default_locale is configured in environment.rb' do
      config = <<-CONFIG
module Tes
  class Application < Rails::Application
    config.i18n.default_locale = :de
  end
end
CONFIG

      assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
module Tes
  class Application < Rails::Application
    config.i18n.default_locale = :ja
  end
end
RESULT
    end

    test 'when i18n.default_locale config is commented in environment.rb' do
      config = <<-CONFIG
module Tes
  class Application < Rails::Application
    # config.i18n.default_locale = :de
  end
end
CONFIG

      assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
module Tes
  class Application < Rails::Application
    config.i18n.default_locale = :ja
  end
end
RESULT
    end

    test 'when i18n.default_locale is not written in environment.rb' do
      config = <<-CONFIG
module Tes
  class Application < Rails::Application
    something goes here.
    bla bla bla...
  end
end
CONFIG

      assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
module Tes
  class Application < Rails::Application
    config.i18n.default_locale = :ja
    something goes here.
    bla bla bla...
  end
end
RESULT
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
i18n_generators-2.2.0 test/i18n_locale_command_test.rb
i18n_generators-2.1.1 test/i18n_locale_command_test.rb
i18n_generators-2.1.0 test/i18n_locale_command_test.rb
i18n_generators-2.0.0 test/i18n_locale_command_test.rb