Sha256: 675e516f59bfd7bd42e946674ecde4d8449aaaa201406e33e0607d1ebda7a36c

Contents?: true

Size: 716 Bytes

Versions: 5

Compression:

Stored size: 716 Bytes

Contents

require 'invokr/dependency_injection'

class DependencyInjectionExampleTest < Minitest::Test
  def setup
    @injector = TestInjector.new(
      :album => 'farmhouse',
      :guitarist => 'trey',
      :drummer => 'fishman',
    )
  end

  def test_dependency_injection
    @injector.inject TestObject
  end

  class TestInjector
    def initialize hsh
      @hsh = hsh
    end

    def inject klass
      Invokr::DependencyInjection.inject(
        :klass => klass,
        :using => self,
      )
    end

    def resolve val
      @hsh.fetch val
    end
  end

  class TestObject
    attr :album, :guitarist

    def initialize album, guitarist
      @album = album
      @guitarist = guitarist
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
invokr-0.0.6 test/dependency_injection_example_test.rb
invokr-0.0.5 test/dependency_injection_example_test.rb
invokr-0.0.4 test/dependency_injection_example_test.rb
invokr-0.0.2 test/dependency_injection_example_test.rb
invokr-0.0.1 test/dependency_injection_example_test.rb