Sha256: b32bd229880983008525d44b0da1b182ca44fd73b718bacc992994d8cd54e8b0

Contents?: true

Size: 964 Bytes

Versions: 3

Compression:

Stored size: 964 Bytes

Contents

require 'spec_helper'

describe 'Factory Method' do
  before :all do
    class TestService
      include SmartIoC::Iocify

      bean :test_service, package: :test

      inject :test_config

      attr_reader :test_config
    end

    class OtherService
      include SmartIoC::Iocify

      bean :other_service, package: :test

      inject :test_config

      attr_reader :test_config
    end

    class TestConfig
      include SmartIoC::Iocify

      bean :test_config, package: :test, factory_method: :build_config

      class Config
      end

      def build_config
        Config.new
      end
    end

    @test_service = SmartIoC.get_bean(:test_service)
    @other_service = SmartIoC.get_bean(:other_service)
  end

  it 'assigns bean with factory method' do
    expect(@test_service.test_config).to be_a(TestConfig::Config)
  end

  it 'assigns bean with factory method' do
    expect(@other_service.test_config).to be_a(TestConfig::Config)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smart_ioc-0.1.27 spec/smart_ioc/factory_method_spec.rb
smart_ioc-0.1.26 spec/smart_ioc/factory_method_spec.rb
smart_ioc-0.1.25 spec/smart_ioc/factory_method_spec.rb