Sha256: 9fd0e2ddf0969fd2e4868680214d3f3a6c5ceec8b178532130d4f1b8e5194efb

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require 'test_helper'

class Hypertemplate::Builder::BaseTest < Test::Unit::TestCase

  class SomeBuilder < Hypertemplate::Builder::Base
    def self.media_types
      ["valid/media_type"]
    end
  end

  class AnotherBuilder < Hypertemplate::Builder::Base
    def self.media_types
      ["valid/media_type", "another_valid/media_type"]
    end
  end

  class YetAnotherBuilder < Hypertemplate::Builder::Base
    def self.media_types
      ["yet_another_valid/media_type"]
    end
  end

  def setup
    @registry = Hypertemplate::Registry.new
    @registry << SomeBuilder
    @registry << AnotherBuilder
    @registry << YetAnotherBuilder
  end

  def test_should_support_media_type_registering
    @registry["runtime/media_type"] = AnotherBuilder
    assert_equal AnotherBuilder   , @registry["runtime/media_type"]
  end
  
  def test_should_lookup_valid_media_types
    assert_equal AnotherBuilder   , @registry["valid/media_type"]
    assert_equal AnotherBuilder   , @registry["another_valid/media_type"]
    assert_equal YetAnotherBuilder, @registry["yet_another_valid/media_type"]
  end
  
  def test_should_lookup_invalid_media_types
    assert_equal nil   , @registry["invalid/media_type"]
  end
    
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hypertemplate-1.2.2 test/hypertemplate/builder/base_test.rb
hypertemplate-1.2.1 test/hypertemplate/builder/base_test.rb
hypertemplate-1.2.0 test/hypertemplate/builder/base_test.rb