Sha256: 801d5c03f08f824ad7fcc114f897f059e5e0d641366e82ccf7d866dbf3e16153

Contents?: true

Size: 712 Bytes

Versions: 3

Compression:

Stored size: 712 Bytes

Contents

require 'test_helper'

class TypedDoc < Dolly::Document
  typed_model
end

class UntypedDoc < Dolly::Document
end

class DocumentTypeTest < Test::Unit::TestCase
  test 'absolute id' do
    assert_equal(TypedDoc.absolute_id("typed_doc/a"), "a")
  end

  test 'typed?' do
    assert_equal(TypedDoc.new.typed?, true)
    assert_equal(UntypedDoc.new.typed?, false)
  end

  test 'typed_model' do
    assert_equal(TypedDoc.new.type, nil)
    assert_equal(UntypedDoc.new.respond_to?(:type), false)
    assert_raise NoMethodError do
      UntypedDoc.new.type
    end
  end

  test 'set_type' do
    assert_equal(TypedDoc.new.set_type, TypedDoc.name_paramitized)
    assert_equal(UntypedDoc.new.set_type, nil)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dolly-3.1.5 test/document_type_test.rb
dolly-3.1.4 test/document_type_test.rb
dolly-3.1.3 test/document_type_test.rb