Sha256: f1795a0723dd975fa93067932f8caa5e717eb689a3b916e8870ba058be3397d6

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe "LocaleSetter::HTTP" do
  describe ".for" do
    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
        end
      end

      context "given two acceptable locales" do
        it "returns :en" do
          LocaleSetter::HTTP.for("en,es").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
        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
      end

      it "handles misordered preferences" do
        LocaleSetter::HTTP.for("es;0.8,en;1").should == :en
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locale_setter-0.1.1 spec/locale/http_spec.rb
locale_setter-0.1.0 spec/locale/http_spec.rb