Sha256: 5d7c1dd1071e1b1cb0939faecbcf9dab20739c1f11800f7b423184ef786c873b

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'test/unit'

module TestViews; end

class AutoloadingTest < Test::Unit::TestCase
  def setup
    Mustache.view_path = File.dirname(__FILE__) + '/../examples'
  end

  def test_autoload
    klass = Mustache.view_class(:Comments)
    assert_equal Comments, klass
  end

  def test_autoload_lowercase
    klass = Mustache.view_class(:comments)
    assert_equal Comments, klass
  end

  def test_autoload_nil
    klass = Mustache.view_class(nil)
    assert_equal Mustache, klass
  end

  def test_autoload_empty_string
    klass = Mustache.view_class('')
    assert_equal Mustache, klass
  end

  def test_namespaced_autoload
    Mustache.view_namespace = TestViews
    klass = Mustache.view_class('Namespaced')
    assert_equal TestViews::Namespaced, klass
    assert_equal <<-end_render.strip, klass.render
<h1>Dragon &lt; Tiger</h1>
end_render
  end

  def test_namespaced_partial_autoload
    Mustache.view_namespace = TestViews
    klass = Mustache.view_class(:namespaced_with_partial)
    assert_equal TestViews::NamespacedWithPartial, klass
    assert_equal <<-end_render.strip, klass.render
My opinion: Victory!
end_render
  end

  def test_bad_constant_name
    assert_equal Mustache, Mustache.view_class(404)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mustache-0.4.2 test/autoloading_test.rb