Sha256: 49721fae446d48ce286ba499129ebc45fd5857fab9e7798d2778a44538b4017e

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe Object do
  before :all do
    SmartIoC.clear
  end

  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

      @bean_definition = SmartIoC.get_bean_definition(:my_bean, :my_package, :test)
    end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smart_ioc-0.5.0 spec/smart_ioc/object_spec.rb
smart_ioc-0.3.9 spec/smart_ioc/object_spec.rb
smart_ioc-0.3.8 spec/smart_ioc/object_spec.rb
smart_ioc-0.3.7 spec/smart_ioc/object_spec.rb
smart_ioc-0.3.6 spec/smart_ioc/object_spec.rb
smart_ioc-0.3.5 spec/smart_ioc/object_spec.rb