Sha256: ef537360f5068292d3a5cb2bcf68171a054ce67d0cfbf288193b6c8ab8d4318e
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
require 'spec_helper' describe TagAlong do it 'should have version' do TagAlong.version.should =~ /^[\d]+\.[\d]+.[\d]+$/ end it 'should initialize' do tg = TagAlong.new(TEXT, OFFSETS_ARY) tg.is_a?(TagAlong).should be_true tg.text.should == TEXT tg.tagged_text.should be_nil end it 'should tag' do tg = TagAlong.new(TEXT, OFFSETS_ARY) tagged_text = tg.tag('<my_tag>', '</my_tag>') tg.tagged_text.should == tagged_text tg.tagged_text.should include('<my_tag>Lebistes reticulatus</my_tag>') tagged_text = tg.tag('<another_tag>', '</another_tag>') tg.tagged_text.should == tagged_text tg.tagged_text.should include('<another_tag>Lebistes reticulatus</another_tag>') end it 'should tag' do text = 'There\'s Sunday and there\'s Monday' offsets = [[8,13], [27,32]] tg = TagAlong.new(text, offsets) tg.tag('<em>', '</em>').should == %q{There's <em>Sunday</em> and there's <em>Monday</em>} end it 'should tag dynamicly' do tg = TagAlong.new(TEXT, OFFSETS_ARY) tagged_text = tg.tag("<my_tag name=\"%s\">", '</my_tag>') tg.tagged_text.should == tagged_text tg.tagged_text.should include('<my_tag name="Lebistes reticulatus">' + 'Lebistes reticulatus</my_tag>') end it 'should tag dynamicly end tag' do offsets = OFFSETS_ARY.each {|i| i.insert(-2, nil)} tg = TagAlong.new(TEXT, OFFSETS_ARY) tagged_text = tg.tag('<my_tag>', "</my_tag name=\"%s\">") tg.tagged_text.should == tagged_text tg.tagged_text.should include("</my_tag name=\"Pundulus\">") end it 'should break dynamic taging if there is problem with data' do offsets = OFFSETS_ARY.each {|i| i.insert(-2, nil)} tg = TagAlong.new(TEXT, OFFSETS_ARY) -> { tg.tag('<my_tag>', "</my_tag val=\"%s\" name=\"%s\">") }. should raise_error end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tag_along-0.7.0 | spec/tag_along_spec.rb |