Sha256: 5a328f71e875dd0f1b48eb047fb6f061b767477e4bf0560d54efdc3c24ba2188

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

require 'spec_helper'

include TwitterCldr::Formatters

describe ListFormatter do
  describe '#initialize' do
    it 'fetches locale from options hash' do
      expect(ListFormatter.new(:pt).locale).to eq(:pt)
    end

    it "uses default locale if it's not passed in options hash" do
      expect(ListFormatter.new.locale).to eq(TwitterCldr.locale)
    end
  end

  describe "#format" do
    let(:list) { ["larry", "curly", "moe"] }

    context "with an English list formatter" do
      before(:each) do
        @formatter = ListFormatter.new(:en)
      end

      it "formats English lists correctly using various types" do
        expect(@formatter.format(list)).to eq("larry, curly, and moe")
        expect(@formatter.format(list, :unit)).to eq("larry, curly, moe")
        expect(@formatter.format(list, :"unit-narrow")).to eq("larry curly moe")
      end
    end

    context "with a Spanish list formatter" do
      before(:each) do
        @formatter = ListFormatter.new(:es)
      end

      it "formats Spanish lists correctly using various types" do
        expect(@formatter.format(list)).to eq("larry, curly y moe")
        expect(@formatter.format(list, :unit)).to eq("larry, curly y moe")
        expect(@formatter.format(list, :"unit-narrow")).to eq("larry curly moe")
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
twitter_cldr-3.0.10 spec/formatters/list_formatter_spec.rb
twitter_cldr-3.0.9 spec/formatters/list_formatter_spec.rb
twitter_cldr-3.0.8 spec/formatters/list_formatter_spec.rb
twitter_cldr-3.0.7 spec/formatters/list_formatter_spec.rb
twitter_cldr-3.0.6 spec/formatters/list_formatter_spec.rb
twitter_cldr-3.0.5 spec/formatters/list_formatter_spec.rb
twitter_cldr-3.0.4 spec/formatters/list_formatter_spec.rb
twitter_cldr-3.0.3 spec/formatters/list_formatter_spec.rb
twitter_cldr-3.0.2 spec/formatters/list_formatter_spec.rb