Sha256: 1dacd97d1b8d13428d11eb28d518e236895264ef5ec44509fb009f513eac23e7

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# This source file is distributed as part of the Needle dependency injection
# library for Ruby. This file (and the library as a whole) may be used only as
# allowed by either the BSD license, or the Ruby license (or, by association
# with the Ruby license, the GPL). See the "doc" subdirectory of the Needle
# distribution for the texts of these licenses.
# -----------------------------------------------------------------------------
# needle website : http://needle.rubyforge.org
# project website: http://rubyforge.org/projects/needle
# =============================================================================
#++

$:.unshift "../lib"

require 'needle/models'
require 'test/unit'

class TC_Models < Test::Unit::TestCase

  class Registry < Hash
    def register( name, opts={}, &callback )
      self[name] = callback.call( self )
    end
  end

  def test_register
    registry = Registry.new

    Needle::Models.register( registry )
    assert_equal 1, registry.length
    assert registry.has_key?( :service_models )

    models = registry[:service_models]

    assert_equal 4, models.length
    assert_equal [:prototype, :prototype_deferred, :singleton, :singleton_deferred],
      models.keys.sort {|a,b| a.to_s <=> b.to_s}
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
needle-0.5.0 test/tc_models.rb