Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add ActionView::Base#find_template_extension_for tests

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6498 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit cf865196fec17d337640b4bca5cb16ca7c67f62f 1 parent 67d5a1a
@technoweenie technoweenie authored
View
6 actionpack/test/abstract_unit.rb
@@ -18,8 +18,10 @@
# Wrap tests that use Mocha and skip if unavailable.
def uses_mocha(test_name)
- require 'mocha'
- require 'stubba'
+ unless Object.const_defined?(:Mocha)
+ require 'mocha'
+ require 'stubba'
+ end
yield
rescue LoadError
$stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again."
View
38 actionpack/test/template/base_test.rb
@@ -0,0 +1,38 @@
+require "#{File.dirname(__FILE__)}/../abstract_unit"
+require "#{File.dirname(__FILE__)}/../testing_sandbox"
+
+class ActionViewTemplateTest < Test::Unit::TestCase
+ include TestingSandbox
+
+ uses_mocha "Action View Templates" do
+ def setup
+ @template = ActionView::Base.new
+ end
+
+ def test_should_find_delegated_extension
+ @template.expects(:delegate_template_exists?).with('foo').returns(['foo'])
+ assert_equal :foo, @template.send(:find_template_extension_for, 'foo')
+ end
+
+ def test_should_find_erb_extension
+ @template.expects(:delegate_template_exists?).with('foo').returns(nil)
+ @template.expects(:erb_template_exists?).with('foo').returns(:erb)
+ assert_equal :erb, @template.send(:find_template_extension_for, 'foo')
+ end
+
+ def test_should_find_builder_extension
+ @template.expects(:delegate_template_exists?).with('foo').returns(nil)
+ @template.expects(:erb_template_exists?).with('foo').returns(nil)
+ @template.expects(:builder_template_exists?).with('foo').returns(:builder)
+ assert_equal :builder, @template.send(:find_template_extension_for, 'foo')
+ end
+
+ def test_should_find_javascript_extension
+ @template.expects(:delegate_template_exists?).with('foo').returns(nil)
+ @template.expects(:erb_template_exists?).with('foo').returns(nil)
+ @template.expects(:builder_template_exists?).with('foo').returns(nil)
+ @template.expects(:javascript_template_exists?).with('foo').returns(true)
+ assert_equal :rjs, @template.send(:find_template_extension_for, 'foo')
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.