require File.join(File.dirname(__FILE__), '..', 'spec_helper') describe TruncateHtml::HtmlString do def html_string(original_string) TruncateHtml::HtmlString.new(original_string) end describe '#html_tokens' do it 'returns each token in the string as an array element removing any consecutive whitespace from the string' do html = '

Hi there

This is sweet!

' html_string(html).html_tokens.should == ['

', 'Hi', ' ', 'there', '

', ' ', '

', 'This', ' ', 'is', ' ', 'sweet!', '

'] end end describe '#html_tag?' do it 'returns false when the string parameter is not an html tag' do html_string('no tags').should_not be_html_tag end it 'returns true when the string parameter is an html tag' do html_string('').should be_html_tag html_string('').should be_html_tag end end describe '#open_tag?' do it 'returns true if the tag is an open tag' do html_string('').should be_open_tag end context 'the tag is an open tag, and has whitespace and html properties' do it 'returns true if it has single quotes' do html_string(" ").should be_open_tag end it 'returns true if it has double quotes' do html_string(' ').should be_open_tag end end it 'returns false if the tag is a close tag' do html_string('').should_not be_open_tag end it 'returns false if the string is not an html tag' do html_string('foo bar').should_not be_open_tag end it 'returns false if it is a