Sha256: 303e1a323914fa4a47ea3623098505b490f49dc9b1a9c67d40e54f3d0294fe0b

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

require File.expand_path('../helper.rb', __FILE__)

class Foo < Document
  key :bar
end

class TestCollection < Test::Unit::TestCase
  def setup
    Structure::Collection.new(Foo)
  end

  def test_subclassing
    assert       FooCollection < Structure::Collection
    assert_equal Foo, FooCollection.type
  end

  def test_conversion
    item = Foo.new

    assert_equal   item, FooCollection([item]).first
    assert_kind_of FooCollection, FooCollection([item])

    assert_equal   item, FooCollection(item).first
    assert_kind_of FooCollection, FooCollection(item)

    assert_raise(TypeError) { FooCollection('foo') }
  end

  def test_enumeration
    assert_respond_to FooCollection.new, :map
    assert_kind_of    FooCollection, FooCollection.new.map! { |e| e }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
structure-0.16.0 test/collection_test.rb