Sha256: a998214225b3a0898b153db0f26dbd80713d3e8e72ed72f2ee6ca42cca11225d

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require 'assert'
require 'deas-nm'

require 'nm/source'
require 'deas/template_engine'

class Deas::Nm::TemplateEngine

  class UnitTests < Assert::Context
    desc "Deas::Nm::TemplateEngine"
    setup do
      @engine = Deas::Nm::TemplateEngine.new({
        'source_path' => TEST_SUPPORT_PATH
      })
    end
    subject{ @engine }

    should have_imeths :nm_source, :nm_handler_local, :nm_logger_local
    should have_imeths :nm_serializer
    should have_imeths :render, :partial, :compile

    should "be a Deas template engine" do
      assert_kind_of Deas::TemplateEngine, subject
    end

    should "memoize its Nm source" do
      assert_kind_of Nm::Source, subject.nm_source
      assert_equal subject.source_path, subject.nm_source.root
      assert_same subject.nm_source, subject.nm_source
    end

    should "use 'view' as the handler local name by default" do
      assert_equal 'view', subject.nm_handler_local
    end

    should "allow custom handler local names" do
      handler_local = Factory.string
      engine = Deas::Nm::TemplateEngine.new('handler_local' => handler_local)
      assert_equal handler_local, engine.nm_handler_local
    end

    should "use 'logger' as the logger local name by default" do
      assert_equal 'logger', subject.nm_logger_local
    end

    should "allow custom logger local names" do
      logger_local = Factory.string
      engine = Deas::Nm::TemplateEngine.new('logger_local' => logger_local)
      assert_equal logger_local, engine.nm_logger_local
    end

    should "use a no-op serializer by default" do
      obj = Factory.integer
      assert_equal obj, subject.nm_serializer.call(obj, Factory.string)
    end

    should "not implement the engine compile method" do
      assert_raises NotImplementedError do
        subject.compile('_partial.json', Factory.text)
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deas-nm-0.3.0 test/unit/template_engine_tests.rb