No commit activity in last 3 years
No release in over 3 years
Ruby gem to help testing i18n with Beaker
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 3.0.0
>= 0
~> 10.0
~> 3.0
 Project Readme

Beaker::I18nHelper

This gem provides some helper methods for testing i18n and l10n with Beaker.

Installation

Add this line to your application's Gemfile:

gem 'beaker-i18n_helper'

Or install it yourself as:

$ gem install beaker-i18n_helper

Usage

In your spec_helper_acceptance, you may use it like:

c.before :suite do
  hosts.each do |host|
    # Required for binding tests.
    if fact('osfamily') == 'Debian'
      #install language pack on debian systems
      install_language_on(host, "ja_JP.utf-8")
    end
    if fact('osfamily') == 'RedHat'
      if fact('operatingsystemmajrelease') =~ /7/ || fact('operatingsystem') =~ /Fedora/
        shell("yum install -y bzip2")
      end
    end
    #set language
    change_locale_on(host, "ja_JP.utf-8")
    on host, puppet('module', 'install', 'stahnma/epel')
  end
end

Reference

install_language_on(hosts, lang)

Uses Beaker's install_package to install a language pack for the desired language. Takes a hosts array and lang, a POSIX locale identifier ([lang]_[region].[charset])

install_language_on(hosts, 'ja_JP.utf-8')

Usually only needed for Debian systems, RHEL installs all language packs by default.

change_locale_on(hosts, lang)

Takes in a POSIX locale identifier, lang, and sets $LANG, $LANGUAGE, and on the target hosts to #{lang}.

change_locale_on(hosts, "de_DE.utf-8")

Limitations

So far, this helper has only been tested for use with Debian and RedHat hosts.

Development

PRs welcome!

Testing

Unit tests

You can run unit tests with rspec

$ rspec spec/beaker/i18n_helper_spec.rb

Acceptance tests

You can run acceptance tests with rspec, too, plus a little Beaker sugar:

$ BEAKER_provision=yes BEAKER_set=default rspec spec/acceptance

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/puppetlabs/beaker-i18n_helper.

License

The gem is available as open source under the terms of the Apache 2.0 License.