From 4c44f0468a0b6d2dd9b67d801da4336ad9a169a0 Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Thu, 30 Dec 2010 14:11:14 +0100 Subject: [PATCH] added tests for the MissingTemplate exception message. --- .../test/template/lookup_context_test.rb | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/actionpack/test/template/lookup_context_test.rb b/actionpack/test/template/lookup_context_test.rb index a629b3c046..4258f88071 100644 --- a/actionpack/test/template/lookup_context_test.rb +++ b/actionpack/test/template/lookup_context_test.rb @@ -251,3 +251,24 @@ class LookupContextWithFalseCaching < ActiveSupport::TestCase assert_equal "Foo", template.source end end + +class TestMissingTemplate < ActiveSupport::TestCase + def setup + @lookup_context = ActionView::LookupContext.new("/Path/to/views", {}) + @details = "{:handlers=>[:erb, :rjs, :builder], :formats=>[:html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:en, :en]}" + end + + test "if no template was found we get a helpful error message including the inheritance chain" do + e = assert_raise ActionView::MissingTemplate do + @lookup_context.find("foo", %w(parent child)) + end + assert_equal "Missing template parent/foo, child/foo with #{@details}. Searched in:\n * \"/Path/to/views\"\n", e.message + end + + test "if no partial was found we get a helpful error message including the inheritance chain" do + e = assert_raise ActionView::MissingTemplate do + @lookup_context.find("foo", %w(parent child), true) + end + assert_equal "Missing partial parent/foo, child/foo with #{@details}. Searched in:\n * \"/Path/to/views\"\n", e.message + end +end