Move tests from action_view_test.rb to template_finder_test.rb so that they get run by default take task. [Pratik]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9021 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Pratik Naik 2008-03-13 11:52:53 +00:00
parent 1e0ac3a673
commit 58c30f6135
2 changed files with 33 additions and 44 deletions

@ -1,43 +0,0 @@
require 'abstract_unit'
class ActionViewTests < Test::Unit::TestCase
def test_find_template_extension_from_first_render
base = ActionView::Base.new
assert_nil base.send(:find_template_extension_from_first_render)
{
nil => nil,
'' => nil,
'foo' => nil,
'/foo' => nil,
'foo.rb' => 'rb',
'foo.bar.rb' => 'bar.rb',
'baz/foo.rb' => 'rb',
'baz/foo.bar.rb' => 'bar.rb',
'baz/foo.o/foo.rb' => 'rb',
'baz/foo.o/foo.bar.rb' => 'bar.rb',
}.each do |input,expectation|
base.instance_variable_set('@first_render', input)
assert_equal expectation, base.send(:find_template_extension_from_first_render)
end
end
def test_should_report_file_exists_correctly
base = ActionView::Base.new
assert_nil base.send(:find_template_extension_from_first_render)
assert_equal false, base.send(:file_exists?, 'test.rhtml')
assert_equal false, base.send(:file_exists?, 'test.rb')
base.instance_variable_set('@first_render', 'foo.rb')
assert_equal 'rb', base.send(:find_template_extension_from_first_render)
assert_equal false, base.send(:file_exists?, 'baz')
assert_equal false, base.send(:file_exists?, 'baz.rb')
end
end

@ -30,7 +30,39 @@ def test_should_cache_dir_content_properly
assert_equal Dir.glob("#{LOAD_PATH_ROOT}/**/*").find_all {|f| !File.directory?(f) }.size,
ActionView::TemplateFinder.processed_view_paths[LOAD_PATH_ROOT].size
end
def test_find_template_extension_from_first_render
assert_nil @finder.send(:find_template_extension_from_first_render)
{
nil => nil,
'' => nil,
'foo' => nil,
'/foo' => nil,
'foo.rb' => 'rb',
'foo.bar.rb' => 'bar.rb',
'baz/foo.rb' => 'rb',
'baz/foo.bar.rb' => 'bar.rb',
'baz/foo.o/foo.rb' => 'rb',
'baz/foo.o/foo.bar.rb' => 'bar.rb',
}.each do |input,expectation|
@template.instance_variable_set('@first_render', input)
assert_equal expectation, @finder.send(:find_template_extension_from_first_render)
end
end
def test_should_report_file_exists_correctly
assert_nil @finder.send(:find_template_extension_from_first_render)
assert_equal false, @finder.send(:file_exists?, 'test.rhtml')
assert_equal false, @finder.send(:file_exists?, 'test.rb')
@template.instance_variable_set('@first_render', 'foo.rb')
assert_equal 'rb', @finder.send(:find_template_extension_from_first_render)
assert_equal false, @finder.send(:file_exists?, 'baz')
assert_equal false, @finder.send(:file_exists?, 'baz.rb')
end
uses_mocha 'Template finder tests' do
def test_should_update_extension_cache_when_template_handler_is_registered
@ -39,5 +71,5 @@ def test_should_update_extension_cache_when_template_handler_is_registered
end
end
end