Sha256: 2be5ca35af9acf11dcf413fe78aa68396a5b5c73ab00cc6aa250239787ddb48b

Contents?: true

Size: 1.68 KB

Versions: 66

Compression:

Stored size: 1.68 KB

Contents

require 'abstract_unit'

class TemplateTest < Test::Unit::TestCase
  def test_template_path_parsing
    with_options :base_path => nil, :name => 'abc', :locale => nil, :format => 'html', :extension => 'erb' do |t|
      t.assert_parses_template_path 'abc.en.html.erb',        :locale => 'en'
      t.assert_parses_template_path 'abc.en.plain.html.erb',  :locale => 'en', :format => 'plain.html'
      t.assert_parses_template_path 'abc.html.erb'
      t.assert_parses_template_path 'abc.plain.html.erb',     :format => 'plain.html'
      t.assert_parses_template_path 'abc.erb',                :format => nil
      t.assert_parses_template_path 'abc.html',               :extension => nil
      
      t.assert_parses_template_path '_abc.html.erb',          :name => '_abc'
      
      t.assert_parses_template_path 'test/abc.html.erb',      :base_path => 'test'
      t.assert_parses_template_path './test/abc.html.erb',    :base_path => './test'
      t.assert_parses_template_path '../test/abc.html.erb',   :base_path => '../test'
      
      t.assert_parses_template_path 'abc',                    :extension => nil, :format => nil, :name => nil
      t.assert_parses_template_path 'abc.xxx',                :extension => nil, :format => 'xxx', :name => 'abc'
      t.assert_parses_template_path 'abc.html.xxx',           :extension => nil, :format => 'xxx', :name => 'abc'
    end
  end

  private
  def assert_parses_template_path(path, parse_results)
    template = ActionView::Template.new(path, '')
    parse_results.each_pair do |k, v|
      assert_block(%Q{Expected template to parse #{k.inspect} from "#{path}" as #{v.inspect}, but got #{template.send(k).inspect}}) { v == template.send(k) }
    end
  end
end

Version data entries

66 entries across 65 versions & 14 rubygems

Version Path
actionpack-2.3.18 test/template/template_test.rb
actionpack_csi-2.3.5.p8 test/template/template_test.rb
actionpack-2.3.17-rack-upgrade-2.3.17 test/template/template_test.rb
actionpack-2.3.17 test/template/template_test.rb
actionpack_csi-2.3.5.p7 test/template/template_test.rb
actionpack_csi-2.3.5.p6 test/template/template_test.rb
actionpack-2.3.16 test/template/template_test.rb
actionpack-rack-upgrade-2-2.3.16 test/template/template_test.rb
actionpack-rack-upgrade-2-2.3.15 test/template/template_test.rb
actionpack-2.3.15 test/template/template_test.rb
actionpack-rack-upgrade-2.3.16 test/template/template_test.rb
actionpack-rack-upgrade-2.3.15 test/template/template_test.rb
actionpack-rack-upgrade-2.3.14 test/template/template_test.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/actionpack-2.3.14/test/template/template_test.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/actionpack-2.3.12/test/template/template_test.rb
actionpack-2.3.14 test/template/template_test.rb
kajam-1.0.3.rc2 vendor/rails/actionpack/test/template/template_test.rb
actionpack-2.3.12 test/template/template_test.rb
radiant-1.0.0.rc2 vendor/rails/actionpack/test/template/template_test.rb
radiant-1.0.0.rc1 vendor/rails/actionpack/test/template/template_test.rb