Sha256: 7c49e6035f43a57b88226d2139850d6b45a07b1c31ab7887456e26a88da0d431

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Object do
  describe '::inject' do
    before :all do
      class TestClass
        include SmartIoC::Iocify

        bean :test_class, package: :test, context: :test

        inject :config
        inject :logger, ref: :test_logger
      end

      @test_class = TestClass.allocate
    end

    it {expect(@test_class.private_methods.include?(:config)).to eq(true) }
    it {expect(@test_class.private_methods.include?(:logger)).to eq(true) }
  end

  describe '::bean' do
    before :all do
      class BeanClass
        include SmartIoC::Iocify

        bean :my_bean, scope: :request, package: :my_package, instance: false,
                       factory_method: :my_method, context: :test
      end
    end

    it {
      bean_definition = SmartIoC::Container.get_instance.get_bean_definition_by_class(BeanClass)

      expect(bean_definition.name).to eq(:my_bean)
      expect(bean_definition.package).to eq(:my_package)
      expect(bean_definition.path).to match(/object_spec.rb/)
      expect(bean_definition.klass).to eq(BeanClass)
      expect(bean_definition.scope).to eq(:request)
      expect(bean_definition.instance).to eq(false)
      expect(bean_definition.factory_method).to eq(:my_method)
      expect(bean_definition.context).to eq(:test)
    }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smart_ioc-0.1.17 spec/smart_ioc/object_spec.rb
smart_ioc-0.1.16 spec/smart_ioc/object_spec.rb
smart_ioc-0.1.14 spec/smart_ioc/object_spec.rb
smart_ioc-0.1.13 spec/smart_ioc/object_spec.rb