Skip to content
Browse files

Ensuring that with_locale changes locale back even on error, using Ar…

…ray#reverse_each for fallback iteration instead of complicated down_to logic
  • Loading branch information...
1 parent 1cd47ea commit 4bc27dd407a1575a8cfc00cf713231298986fd80 Cameron Dutro committed with camertron
Showing with 15 additions and 0 deletions.
  1. +15 −0 spec/twitter_cldr_spec.rb
View
15 spec/twitter_cldr_spec.rb
@@ -277,6 +277,21 @@
TwitterCldr.with_locale(:es) { TwitterCldr::Shared::Languages.from_code(:es) }.should match_normalized("español")
TwitterCldr::Shared::Languages.from_code(:es).should == "Spanish"
end
+
+ it "switches the locale back to the original if the block raises an error" do
+ TwitterCldr.locale.should == :en
+ locale_inside_block = nil
+
+ lambda do
+ TwitterCldr.with_locale(:es) do
+ locale_inside_block = TwitterCldr.locale
+ raise "Error!"
+ end
+ end.should raise_error
+
+ locale_inside_block.should == :es
+ TwitterCldr.locale.should == :en
+ end
end
describe '#resources' do

0 comments on commit 4bc27dd

Please sign in to comment.
Something went wrong with that request. Please try again.