Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/branches/2-1-caching/actionpack/test/action_view_test.rb

Revision 8391, 1.3 kB (checked in by david, 1 year ago)

Work branch

Line 
1 require File.dirname(__FILE__) + '/abstract_unit'
2 require 'test/unit'
3
4 class ActionViewTests < Test::Unit::TestCase
5   def test_find_template_extension_from_first_render
6     base = ActionView::Base.new
7
8     assert_nil base.send(:find_template_extension_from_first_render)
9
10     {
11       nil => nil,
12       '' => nil,
13       'foo' => nil,
14       '/foo' => nil,
15       'foo.rb' => 'rb',
16       'foo.bar.rb' => 'bar.rb',
17       'baz/foo.rb' => 'rb',
18       'baz/foo.bar.rb' => 'bar.rb',
19       'baz/foo.o/foo.rb' => 'rb',
20       'baz/foo.o/foo.bar.rb' => 'bar.rb',
21     }.each do |input,expectation|
22       base.instance_variable_set('@first_render', input)
23       assert_equal expectation, base.send(:find_template_extension_from_first_render)
24     end
25   end
26  
27   def test_should_report_file_exists_correctly
28     base = ActionView::Base.new
29
30     assert_nil base.send(:find_template_extension_from_first_render)
31    
32     assert_equal false, base.send(:file_exists?, 'test.rhtml')
33     assert_equal false, base.send(:file_exists?, 'test.rb')
34
35     base.instance_variable_set('@first_render', 'foo.rb')
36    
37     assert_equal 'rb', base.send(:find_template_extension_from_first_render)
38    
39     assert_equal false, base.send(:file_exists?, 'baz')
40     assert_equal false, base.send(:file_exists?, 'baz.rb')
41
42   end
43  
44 end
Note: See TracBrowser for help on using the browser.