Sha256: ab35e0e7436c75886fd460484c76a80a388eaeb1e4f88efc989bef54383a479d

Contents?: true

Size: 831 Bytes

Versions: 5

Compression:

Stored size: 831 Bytes

Contents

require File.dirname(__FILE__) + '/../abstract_unit'

class CustomHandler
  def initialize( view )
    @view = view
  end

  def render( template, local_assigns )
    [ template,
      local_assigns,
      @view ]
  end
end

class CustomHandlerTest < Test::Unit::TestCase
  def setup
    ActionView::Base.register_template_handler "foo", CustomHandler
    @view = ActionView::Base.new
  end

  def test_custom_render
    result = @view.render_template( "foo", "hello <%= one %>", nil, :one => "two" )
    assert_equal(
      [ "hello <%= one %>", { :one => "two" }, @view ],
      result )
  end

  def test_unhandled_extension
    # uses the ERb handler by default if the extension isn't recognized
    result = @view.render_template( "bar", "hello <%= one %>", nil, :one => "two" )
    assert_equal "hello two", result
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
actionpack-1.11.2 test/controller/custom_handler_test.rb
actionpack-1.10.2 test/controller/custom_handler_test.rb
actionpack-1.10.1 test/controller/custom_handler_test.rb
actionpack-1.11.0 test/controller/custom_handler_test.rb
actionpack-1.11.1 test/controller/custom_handler_test.rb