dry-rb / dry-auto_inject

Container-agnostic constructor injection mixin

Home Page:https://dry-rb.org/gems/dry-auto_inject/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v0.5.0 breaks isolation tests with minitest mocks

TiteiKo opened this issue · comments

class Foobar
  include Inject[foo: 'bar']

  def do_something
    foo.do_something
    # ....
  end
end

# would be tested like this

class FoobarTest < Minitest::Test
  def test_it_calls_do_something_of_foo
    mock = Minitest::Mock.new
    mock.expect :do_something
    Foobar.new(foo: mock).do_something
    assert_mocked mock
  end
end

This was working fine before 0.5.0. Now, it gets the error unmocked method :nil?, expected one of [:do_something] due to 193ed48#diff-f6dd1c9acc3de0d2ccbed1741aa38257, thus rendering mocking non straightforward

Thanks for raising this, @TiteiKo. I've adjusted some code in a currently-open PR (#48) to fix this issue.