1 require File.dirname(__FILE__) + '/../../test_helper'
3 require 'radiant/taggable'
4 class Radiant::TaggableTest < Test::Unit::TestCase
7 include Radiant::Taggable
9 desc %{This tag renders the text "just a test".}
14 desc %{This tag implements "Hello, world!".}
16 "Hello, #{ tag.attr['name'] || 'world' }!"
21 include Radiant::Taggable
23 desc %{This tag renders the text "another tag".}
30 class AnotherObject < TestObject
31 include AdditionalTags
35 @object = TestObject.new
38 def test_tag_class_method
39 assert_equal "just a test", @object.send("tag:test")
42 def test_tags_class_method
43 assert_equal ["hello", "test"], TestObject.tags
47 @object.extend AdditionalTags
48 assert_equal ["another", "hello", "test"], @object.tags
52 binding = OpenStruct.new( :attr => { 'name' => 'John' } )
53 assert_equal "Hello, John!", @object.render_tag(:hello, binding)
57 assert @object.respond_to?(:tag_descriptions)
58 assert_equal "<p>This tag renders the text “just a test”.</p>", @object.tag_descriptions["test"]
59 assert_equal "<p>This tag implements “Hello, world!”.</p>", @object.tag_descriptions["hello"]
62 def test_description_inclusion_and_inheritance
63 @object = AnotherObject.new
64 assert_not_nil @object.tag_descriptions["another"]
65 assert_equal "<p>This tag renders the text “another tag”.</p>", @object.tag_descriptions["another"]
66 assert_equal "<p>This tag renders the text “just a test”.</p>", @object.tag_descriptions["test"]
67 assert_equal "<p>This tag implements “Hello, world!”.</p>", @object.tag_descriptions["hello"]
70 def test_strip_leading_whitespace
73 I'm a really small paragraph that
74 happens to span two lines.
80 Let's try a small code example:
84 Nice job! It really, really, really
90 I'm a really small paragraph that
91 happens to span two lines.
97 Let's try a small code example:
101 Nice job! It really, really, really
103 assert_equal result, Radiant::Taggable::Util.strip_leading_whitespace(markup)