Sha256: e4110bca6fe10a55f1d5351a16aa0df3e7c97f9daca537095d09c076ca453b79

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

dir = File.expand_path(File.dirname(__FILE__))
require "#{dir}/helper"

describe "Micon Managed" do
  before :all do
    Micon.clear_registry
    
    class ManagedObject
      inherit Micon::Managed
      scope :application
      inject :object => :object_key

      class << self
        inherit Micon::Managed
        inject :object => :object_key
      end
    end
  end
  
  before :each do
    Micon.clear
  end

  it "scope" do
    scope, initializer = Micon.registry_get(ManagedObject)
    scope.should == :application
    initializer.call.should be_a(ManagedObject)
  end

  it "injection" do
    the_object = "The Object"
    Micon.register(:object_key, :application){the_object}

    ManagedObject.object.should == the_object
    o = ManagedObject.new
    o.object.should == the_object
  end
  
  it "outjection" do
    the_object = "The Object"
    Micon.register(:object_key, :application)

    ManagedObject.object.should be_nil    
    ManagedObject.object = the_object
    ManagedObject.object.should == the_object
  end
  
  it "empty?" do
    Micon.should be_empty
    Micon[ManagedObject]
    Micon.should_not be_empty
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-ext-0.4.2 spec/micon/managed_spec.rb