~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/actionpack/test/template/template_test.rb

  • Committer: Richard Lee (Canonical)
  • Date: 2010-10-15 15:17:58 UTC
  • mfrom: (190.1.3 use-case-mapper)
  • Revision ID: richard.lee@canonical.com-20101015151758-wcvmfxrexsongf9d
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require 'abstract_unit'
2
 
 
3
 
class TemplateTest < Test::Unit::TestCase
4
 
  def test_template_path_parsing
5
 
    with_options :base_path => nil, :name => 'abc', :locale => nil, :format => 'html', :extension => 'erb' do |t|
6
 
      t.assert_parses_template_path 'abc.en.html.erb',        :locale => 'en'
7
 
      t.assert_parses_template_path 'abc.en.plain.html.erb',  :locale => 'en', :format => 'plain.html'
8
 
      t.assert_parses_template_path 'abc.html.erb'
9
 
      t.assert_parses_template_path 'abc.plain.html.erb',     :format => 'plain.html'
10
 
      t.assert_parses_template_path 'abc.erb',                :format => nil
11
 
      t.assert_parses_template_path 'abc.html',               :extension => nil
12
 
      
13
 
      t.assert_parses_template_path '_abc.html.erb',          :name => '_abc'
14
 
      
15
 
      t.assert_parses_template_path 'test/abc.html.erb',      :base_path => 'test'
16
 
      t.assert_parses_template_path './test/abc.html.erb',    :base_path => './test'
17
 
      t.assert_parses_template_path '../test/abc.html.erb',   :base_path => '../test'
18
 
      
19
 
      t.assert_parses_template_path 'abc',                    :extension => nil, :format => nil, :name => nil
20
 
      t.assert_parses_template_path 'abc.xxx',                :extension => nil, :format => 'xxx', :name => 'abc'
21
 
      t.assert_parses_template_path 'abc.html.xxx',           :extension => nil, :format => 'xxx', :name => 'abc'
22
 
    end
23
 
  end
24
 
 
25
 
  private
26
 
  def assert_parses_template_path(path, parse_results)
27
 
    template = ActionView::Template.new(path, '')
28
 
    parse_results.each_pair do |k, v|
29
 
      assert_block(%Q{Expected template to parse #{k.inspect} from "#{path}" as #{v.inspect}, but got #{template.send(k).inspect}}) { v == template.send(k) }
30
 
    end
31
 
  end
32
 
end