Sha256: 19d40cc45286c4e78f882c26a11add9a77c40fe97171c2ca073d5e27fee8fd89

Contents?: true

Size: 754 Bytes

Versions: 15

Compression:

Stored size: 754 Bytes

Contents

require "test_helper"
require "dry/container"
require "trailblazer/operation/auto_inject"

class DryAutoInjectTest < Minitest::Spec
  my_container = Dry::Container.new
  my_container.register(:user_repository, -> { Object })

  AutoInject = Trailblazer::Operation::AutoInject(my_container)

  class Create < Trailblazer::Operation
    include AutoInject[:user_repository]
  end

  it "auto-injects user_repository" do
    res = Create.({})
    res[:user_repository].must_equal Object
  end

  it "allows dependency injection via ::call" do
    Create.({}, user_repository: String)[:user_repository].must_equal String
  end

  describe "inheritance" do
    class Update < Create
    end

    it { Update.()[:user_repository].must_equal Object }
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
trailblazer-2.1.0.beta3 test/docs/auto_inject_test.rb
trailblazer-2.1.0.beta2 test/docs/auto_inject_test.rb
trailblazer-2.1.0.beta1 test/docs/auto_inject_test.rb
trailblazer-2.0.7 test/docs/auto_inject_test.rb
trailblazer-2.0.6 test/docs/auto_inject_test.rb
trailblazer-2.0.5 test/docs/auto_inject_test.rb
trailblazer-2.0.4 test/docs/auto_inject_test.rb
trailblazer-2.0.3 test/docs/auto_inject_test.rb
trailblazer-2.0.2 test/docs/auto_inject_test.rb
trailblazer-2.0.1 test/docs/auto_inject_test.rb
trailblazer-2.0.0 test/docs/auto_inject_test.rb
trailblazer-2.0.0.rc1 test/docs/auto_inject_test.rb
trailblazer-2.0.0.beta3 test/docs/auto_inject_test.rb
trailblazer-2.0.0.beta2 test/docs/auto_inject_test.rb
trailblazer-2.0.0.beta1 test/docs/auto_inject_test.rb