enriclluelles/route_translator — pull request #79 by tagliala (2014-12-10 21:12:43+00:00)
Title: Improved tests, does not mess up with I18n.locale

According to run order, sometimes tests could fail because of `I18n.locale` not being restored properly

e.g.: (running tests against the gemfile)

```
$ rake TESTOPTS="--seed=63890"
/Users/user/.rvm/rubies/ruby-2.1.4/bin/ruby -I"lib:lib" -I"/Users/user/.rvm/gems/ruby-2.1.4/gems/rake-10.4.2/lib" "/Users/user/.rvm/gems/ruby-2.1.4/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" --seed=63890
MiniTest::Unit::TestCase is now Minitest::Test. From /Users/user/dev/route_translator/test/host_test.rb:4:in `'
Run options: --seed=63890

# Running:

..........................................................F

Finished in 0.555938s, 106.1269 runs/s, 607.9815 assertions/s.

1) Failure:
ThreadSafetyTest#test_i18n_locale_thread_safe [/Users/user/dev/route_translator/test/integration/thread_safety_test.rb:13]:
Expected: :en
Actual: :es

59 runs, 338 assertions, 1 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1): [ruby -I"lib:lib" -I"/Users/user/.rvm/gems/ruby-2.1.4/gems/rake-10.4.2/lib" "/Users/user/.rvm/gems/ruby-2.1.4/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" --seed=63890]
/Users/user/.rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `eval'
/Users/user/.rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `

'
Tasks: TOP => default => test
(See full trace by running task with --trace)
```

This PR uses blocks to ensure that locale is setted back to its original value after the use

```
$ rake TESTOPTS="--seed=63890"
/Users/user/.rvm/rubies/ruby-2.1.4/bin/ruby -I"lib:lib" -I"/Users/user/.rvm/gems/ruby-2.1.4/gems/rake-10.4.2/lib" "/Users/user/.rvm/gems/ruby-2.1.4/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" --seed=63890
MiniTest::Unit::TestCase is now Minitest::Test. From /Users/user/dev/route_translator/test/host_test.rb:4:in `'
Run options: --seed=63890

# Running:

...........................................................

Finished in 0.584454s, 100.9489 runs/s, 578.3175 assertions/s.

59 runs, 338 assertions, 0 failures, 0 errors, 0 skips
```