Sha256: cda361d900aecdaa01fce5703e17683a377f43577ab2078542551db5f180233c

Contents?: true

Size: 1.63 KB

Versions: 13

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

module RubySpeech
  module GRXML
    describe Token do
      its(:name) { should == 'token' }

      it 'registers itself' do
        Element.class_from_registration(:token).should == Token
      end

      describe "from a document" do
        let(:document) { '<token>hello</token>' }

        subject { Element.import document }

        it { should be_instance_of Token }

        its(:content) { should == 'hello' }
      end

      describe "#language" do
        before { subject.language = 'jp' }

        its(:language) { should == 'jp' }
      end

      describe "#normalize_whitespace" do
        it "should remove leading & trailing whitespace and collapse multiple spaces down to 1" do
          element = Element.import '<token> Welcome to  San Francisco </token>'

          element.normalize_whitespace

          element.content.should == 'Welcome to San Francisco'
        end
      end

      describe "comparing objects" do
        it "should be equal if the content is the same" do
          Token.new(:content => "hello").should == Token.new(:content => "hello")
        end

        describe "when the content is different" do
          it "should not be equal" do
            Token.new(:content => "Hello").should_not == Token.new(:content => "Hello there")
          end
        end
      end

      describe "<<" do
        it "should accept String" do
          lambda { subject << 'anything' }.should_not raise_error
        end

        it "should allow chaining" do
          subject << 'foo' << 'bar'
          subject.content.should == 'foobar'
        end
      end
    end # Token
  end # GRXML
end # RubySpeech

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ruby_speech-2.1.2-java spec/ruby_speech/grxml/token_spec.rb
ruby_speech-2.1.2 spec/ruby_speech/grxml/token_spec.rb
ruby_speech-2.1.1-java spec/ruby_speech/grxml/token_spec.rb
ruby_speech-2.1.1 spec/ruby_speech/grxml/token_spec.rb
ruby_speech-2.1.0-java spec/ruby_speech/grxml/token_spec.rb
ruby_speech-2.1.0 spec/ruby_speech/grxml/token_spec.rb
ruby_speech-2.0.2 spec/ruby_speech/grxml/token_spec.rb
ruby_speech-2.0.1 spec/ruby_speech/grxml/token_spec.rb
ruby_speech-1.1.0 spec/ruby_speech/grxml/token_spec.rb
ruby_speech-1.0.2 spec/ruby_speech/grxml/token_spec.rb
ruby_speech-1.0.1 spec/ruby_speech/grxml/token_spec.rb
ruby_speech-1.0.0 spec/ruby_speech/grxml/token_spec.rb
ruby_speech-0.5.1 spec/ruby_speech/grxml/token_spec.rb