# encoding: utf-8
require File.join(File.dirname(__FILE__), 'test_helper')
class ErectorTest < ActionController::TestCase
context "#render with :erector" do
setup do
@cell = cell_mock
end
should "render the erector widget when called with block" do
@cell.instance_eval do
def jam
@key = "A"
render :erector => true do
h1 do
text "Rock it in "
b @key
end
end
end
end
assert_equal "
Rock it in A
", @cell.render_state(:jam)
end
should "have access to cell helpers" do
@cell.instance_eval do
#self.class.helper ActionView::Helpers::UrlHelper
def jam
@key = "A"
render :erector => true do
#url_for("Rock it", "/rock/it")
h1 do link_to("Rock it in #{@key}", :url => "/rock/it") end
#text raw link_to("Rock it")
#h "test"
end
end
end
#erector_in_cell = Erector::Widget.new
class Erector::InlineWidget
def link_to(*args)
text! "what-ever!"
end
end
assert_equal "", @cell.render_state(:jam)
end
should "cry for beer!" do
require 'erector'
obj = Object.new
obj.instance_eval do
def beer; "beer!"; end
end
assert_equal "Cry for beer!
", Erector.inline() { p "Cry for #{text beer} #{b 'yo'}" }.to_s(:parent => obj)
end
end
end