Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Commit

Permalink
Tests for awesome_truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorrison committed Feb 22, 2010
1 parent 755fd92 commit 26b1bb0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/text_helper_test.rb
@@ -0,0 +1,30 @@
require 'test/unit'
require 'rubygems'
require 'action_view'
require File.join(File.dirname(__FILE__), '..', 'lib', 'awesomeness', 'text_helper')


class TextHelperTest < Test::Unit::TestCase
include ActionView::Helpers::TextHelper

def test_awesome_truncate_with_nil
assert_nil awesome_truncate(nil)
end

def test_awesome_truncate_with_blank
assert_equal '', awesome_truncate('')
end

def test_awesome_truncate
assert_equal 'foo...', awesome_truncate('foo bar baz', 5, '...')
end

def test_awesome_truncate_with_sentence
assert_equal 'foo bar...', awesome_truncate('foo bar. baz', 8, '...')
end

# TODO: this would be sweet
# def test_awesome_truncate_with_html
# assert_equal 'foo...', awesome_truncate('foo <img src="bar.png">', 8, '...')
# end
end

0 comments on commit 26b1bb0

Please sign in to comment.