Sha256: c8e4e1a956d99b62837a3fc8b9b00ead7268ca0de9743e797d7d8a91298da2f8
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
require File.expand_path('../spec_helper', File.dirname(__FILE__)) describe Tr8n::TokenizedLabel do describe 'registering tokens' do context "registering correct tokens" do it "should register all tokens" do str = 'Dear {user:gender}, you have [bold: {count:number|| new message}] in your mailbox!' label = Tr8n::TokenizedLabel.new(str) label.label.should eq(str) label.tokens?.should be_true label.data_tokens?.should be_true label.decoration_tokens?.should be_true label.data_tokens.count.should eq(2) label.decoration_tokens.count.should eq(1) label.tokens.count.should eq(3) label.sanitized_tokens_hash.keys.should eq(["{user}", "{count}", "[bold: ]"]) label.translation_tokens?.should be_true label.translation_tokens.count.should eq(3) san_str = "Dear {user}, you have [bold: {count} new messages] in your mailbox!" label.sanitized_label.should eq(san_str) label.suggestion_tokens.should eq(["{user}", "{count}", "bold"]) label.words.should eq(["Dear", "User", "Have", "Bold", "Count", "Messages", "Your", "Mailbox"]) label.tokens.each do |token| label.allowed_token?(token).should be_true end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
tr8n-3.2.3 | spec/lib/tokenized_label_spec.rb |
tr8n-3.2.2 | spec/lib/tokenized_label_spec.rb |
tr8n-3.2.1 | spec/lib/tokenized_label_spec.rb |
tr8n-3.2.0 | spec/lib/tokenized_label_spec.rb |