require File.dirname(__FILE__) + '/test_helper' class ActsAsTextileTest < ActsAsMarkupOnTestCase context 'acts_as_textile_on' do setup do @textile_text = "h2. Textile Test Text" class ::Post < ActiveRecord::Base acts_as_textile_on :body end @post = Post.create!(:title => 'Blah', :body => @textile_text) end should "have a RedCloth object returned for the column value" do assert_kind_of RedCloth::TextileDoc, @post.body end should "return original textile text for a `to_s` method call on the column value" do assert_equal @textile_text, @post.body.to_s end should 'return false for .blank?' do assert !@post.body.blank? end should "return formated html for a `to_html` method call on the column value" do assert_match(/
\@count\s\=\s20<\/code>/, @post.body.to_html)
end
teardown do
@old_body = nil
end
end
teardown do
@textile_text, @post = nil
Post.delete_all
end
end
context 'acts_as_textile with options' do
setup do
class ::Post
acts_as_textile_on :body, :textile_options => [ [ :filter_html ] ]
end
@post = Post.new(:title => 'Blah')
end
should "return escaped html because of :filter_html" do
@post.body = "h2. Textile Test Text"
assert_match(/<i>Test<\/i>/, @post.body.to_html)
end
end
end