Sha256: d6aca87bbff66d7e8858519fe42ab1b797d350e3eb6efe88492a531cda852738

Contents?: true

Size: 945 Bytes

Versions: 7

Compression:

Stored size: 945 Bytes

Contents

require File.expand_path('../spec_helper', File.dirname(__FILE__))

describe Tr8n::Tokens::DataToken do
  describe '#register_data_tokens' do

    context "registering correct data tokens" do
      it "should register all tokens" do
        tokens = Tr8n::Tokens::DataToken.parse("Hello {user}")
        tokens.count.should == 1
        tokens.first.class.name.should == "Tr8n::Tokens::DataToken"
        
        tokens = Tr8n::Tokens::DataToken.parse("{user} has {count} messages")
        tokens.count.should == 2
        tokens.first.class.name.should == "Tr8n::Tokens::DataToken"
      end
    end

    context "registering incorrect data tokens" do
      it "should not register any tokens" do
        Tr8n::Tokens::DataToken.parse("Hello {user:}").count.should == 0
        Tr8n::Tokens::DataToken.parse("Hello {}").count.should == 0
        Tr8n::Tokens::DataToken.parse("Hello {user::}").count.should == 0
      end
    end
  end  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tr8n-3.1.8 spec/lib/data_token_spec.rb
tr8n-3.1.7 spec/lib/data_token_spec.rb
tr8n-3.1.6 spec/lib/data_token_spec.rb
tr8n-3.1.5 spec/lib/data_token_spec.rb
tr8n-3.1.4 spec/lib/data_token_spec.rb
tr8n-3.1.3 spec/lib/data_token_spec.rb
tr8n-3.1.2 spec/lib/data_token_spec.rb