grosser/fast_gettext — Issue #32: po_spec.rb fails with LANG=C
Author: angdraug
Created: 2012-01-08 15:06:46+00:00
State: open

When running po_spec.rb with a non-UTF locale, internal encoding defaults to US-ASCII and the test fails like this:

```
$ LANG=C ruby spec/fast_gettext/translation_repository/po_spec.rb
FFFFFFFF

Failures:

1) FastGettext::TranslationRepository::Po can be built
Failure/Error: Unable to find matching line from backtrace
ArgumentError:
invalid byte sequence in US-ASCII
# src/poparser.ry:127:in `==='
# src/poparser.ry:127:in `parse'
# ./lib/fast_gettext/po_file.rb:10:in `to_mo_file'
# ./lib/fast_gettext/translation_repository/po.rb:13:in `block in find_and_store_files'
# ./lib/fast_gettext/translation_repository/base.rb:44:in `block in find_files_in_locale_folders'
# ./lib/fast_gettext/translation_repository/base.rb:39:in `each'
# ./lib/fast_gettext/translation_repository/base.rb:39:in `find_files_in_locale_folders'
# ./lib/fast_gettext/translation_repository/po.rb:12:in `find_and_store_files'
# ./lib/fast_gettext/translation_repository/mo.rb:9:in `initialize'
# ./lib/fast_gettext/translation_repository.rb:14:in `new'
# ./lib/fast_gettext/translation_repository.rb:14:in `build'
# spec/fast_gettext/translation_repository/po_spec.rb:5:in `block (2 levels) in

'
```

I worked around this by adding the following line to spec_helper.rb:

```ruby
Encoding.default_external='UTF-8' if RUBY_VERSION >= '1.9'
```

but I suspect it's more of a sweeping the problem under the rug rather than fixing it.