spec/locale/http_spec.rb in locale_setter-0.1.1 vs spec/locale/http_spec.rb in locale_setter-0.3.0

- old
+ new

@@ -1,43 +1,39 @@ require 'spec_helper' describe "LocaleSetter::HTTP" do describe ".for" do + let(:available){ ['en', 'es'] } + context "when the first choice is supported" do - before(:each){ I18n.available_locales = [:en, :es] } - context "given 'en'" do it "returns :en" do - LocaleSetter::HTTP.for("en").should == :en + LocaleSetter::HTTP.for("en", available).should == :en end end context "given two acceptable locales" do it "returns :en" do - LocaleSetter::HTTP.for("en,es").should == :en + LocaleSetter::HTTP.for("en,es", available).should == :en end end end context "when the first choice is not supported" do - before(:each){ I18n.available_locales = [:es] } - context "given 'en,es'" do it "returns :es" do - LocaleSetter::HTTP.for("en,es").should == :es + LocaleSetter::HTTP.for("de,es", available).should == :es end end end context "when using preference weightings" do - before(:each){ I18n.available_locales = [:en, :es] } - it "returns :en" do - LocaleSetter::HTTP.for("en;1,es;0.8").should == :en + LocaleSetter::HTTP.for("en;1,es;0.8", available).should == :en end it "handles misordered preferences" do - LocaleSetter::HTTP.for("es;0.8,en;1").should == :en + LocaleSetter::HTTP.for("es;0.8,en;1", available).should == :en end end end end \ No newline at end of file