Sha256: 93580441cc52bbff54a5dc4c7a34555255c64d689b924d6cb4385776c4acd18a

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

# encoding: UTF-8

require File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec_helper")
include TwitterCldr::Tokenizers

describe DateTokenizer do
  describe "#tokens" do
    it "should tokenize plaintext segments correctly (i.e. Spanish)" do
      tokenizer = DateTokenizer.new(:locale => :es)
      got = tokenizer.tokens(:type => :full)
      expected = [{ :value => "EEEE", :type => :pattern },
                  { :value => " ", :type => :plaintext },
                  { :value => "d", :type => :pattern },
                  { :value => " ", :type => :plaintext },
                  { :value => "'de'", :type => :plaintext },
                  { :value => " ", :type => :plaintext },
                  { :value => "MMMM", :type => :pattern },
                  { :value => " ", :type => :plaintext },
                  { :value => "'de'", :type => :plaintext },
                  { :value => " ", :type => :plaintext },
                  { :value => "y", :type => :pattern }]
      check_token_list(got, expected)
    end

    it "should tokenize patterns with non-latin characters correctly (i.e. Japanese)" do
      tokenizer = DateTokenizer.new(:locale => :ja)
      got = tokenizer.tokens(:type => :full)
      expected  = [{ :value => "y", :type => :pattern },
                   { :value => "年", :type => :plaintext },
                   { :value => "M", :type => :pattern },
                   { :value => "月", :type => :plaintext },
                   { :value => "d", :type => :pattern },
                   { :value => "日", :type => :plaintext },
                   { :value => "EEEE", :type => :pattern }]
      check_token_list(got, expected)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitter_cldr-1.0.1 spec/tokenizers/calendars/date_tokenizer_spec.rb