diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-06-25 05:47:01 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-06-25 05:49:38 -0500 |
commit | 6f5327013d6353c50cadfe2160d1b526ad687633 (patch) | |
tree | 61e61cd49bbad6e43ca98995884a2fc329c33d8e /actionpack/test/template/template_object_test.rb | |
parent | 670e22e3724791f51d639f409930fba5af920081 (diff) | |
download | rails-6f5327013d6353c50cadfe2160d1b526ad687633.tar.gz rails-6f5327013d6353c50cadfe2160d1b526ad687633.tar.bz2 rails-6f5327013d6353c50cadfe2160d1b526ad687633.zip |
Consolidate CustomHandlerTest, TemplateFileTest, and TemplateObjectTest and test them at a higher level of abstraction in ViewRenderTest.
Diffstat (limited to 'actionpack/test/template/template_object_test.rb')
-rw-r--r-- | actionpack/test/template/template_object_test.rb | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/actionpack/test/template/template_object_test.rb b/actionpack/test/template/template_object_test.rb deleted file mode 100644 index 2cfc4523c6..0000000000 --- a/actionpack/test/template/template_object_test.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'abstract_unit' - -class TemplateObjectTest < Test::Unit::TestCase - LOAD_PATH_ROOT = File.join(File.dirname(__FILE__), '..', 'fixtures') - - class TemplateTest < Test::Unit::TestCase - def setup - @view = ActionView::Base.new(LOAD_PATH_ROOT) - @path = "test/hello_world.erb" - end - - def test_should_create_valid_template - template = ActionView::Template.new(@view, @path, true) - - assert_kind_of ActionView::TemplateHandlers::ERB, template.handler - assert_equal "test/hello_world.erb", template.path.to_s - assert_nil template.instance_variable_get(:"@source") - assert_equal "erb", template.extension - end - - uses_mocha 'Template preparation tests' do - def test_should_prepare_template_properly - template = ActionView::Template.new(@view, @path, true) - view = template.instance_variable_get(:"@view") - - view.expects(:evaluate_assigns) - template.handler.expects(:compile_template).with(template) - view.expects(:method_names).returns({}) - - template.prepare! - end - end - end - - class PartialTemplateTest < Test::Unit::TestCase - def setup - @view = ActionView::Base.new(LOAD_PATH_ROOT) - @path = "test/partial_only" - end - - def test_should_create_valid_partial_template - template = ActionView::PartialTemplate.new(@view, @path, nil) - - assert_equal "test/_partial_only", template.path.path_without_format_and_extension - assert_equal :partial_only, template.variable_name - - assert template.locals.has_key?(:object) - assert template.locals.has_key?(:partial_only) - end - - def test_partial_with_errors - template = ActionView::PartialTemplate.new(@view, 'test/raise', nil) - assert_raise(ActionView::TemplateError) { template.render_template } - end - - uses_mocha 'Partial template preparation tests' do - def test_should_prepare_on_initialization - ActionView::PartialTemplate.any_instance.expects(:prepare!) - template = ActionView::PartialTemplate.new(@view, @path, 1) - end - end - end - - class PartialTemplateFallbackTest < Test::Unit::TestCase - def setup - @view = ActionView::Base.new(LOAD_PATH_ROOT) - @path = 'test/layout_for_partial' - end - - def test_default - template = ActionView::PartialTemplate.new(@view, @path, nil) - assert_equal 'test/_layout_for_partial', template.path.path_without_format_and_extension - assert_equal 'erb', template.extension - assert_equal :html, @view.template_format - end - - def test_js - @view.template_format = :js - template = ActionView::PartialTemplate.new(@view, @path, nil) - assert_equal 'test/_layout_for_partial', template.path.path_without_format_and_extension - assert_equal 'erb', template.extension - assert_equal :html, @view.template_format - end - - def test_xml - @view.template_format = :xml - assert_raise ActionView::MissingTemplate do - ActionView::PartialTemplate.new(@view, @path, nil) - end - end - end -end |