Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Piotr Solnica
@solnic
wdym?
Andy Holland
@AMHOL
Forgot the :trollface:
lol
Monkey patched
Piotr Solnica
@solnic
sorry, didn’t get the joke, FUNNY :D
or scary, not sure
Andy Holland
@AMHOL
Yeah
It's funny because it's true
Piotr Solnica
@solnic
right :)
I can now see what changes are needed to achieve isolation
I need to separate container configuration from finalization
it was collapsed into one thing, it is a mistake
Andy Holland
@AMHOL
Makes sense, better to be explicit too
Piotr Solnica
@solnic
then, I need to make a smarter import function, that would require missing deps
which should be trivial
pretty much looping through names, asking container if it exists, if not, gsubbing dots with slashes, asking container to require missing stuff
I want to require the container in the spec helper and it should have the config in place, bkz config is a dependency too for stuff like db url etc
then the import stuff should be able to take care of everything
ultimate goal is to be able to run tests in complete isolation
so you don’t load tons of files w/o any good reason
I will call this feature “Summer"
becauase summer comes after spring
Andy Holland
@AMHOL
:joy:
Andy Holland
@AMHOL
Piotr Solnica
@solnic
sweet
can we have include Dry::Constructor(:foo, :bar, kwargs: true) too? :D
although I gotta say my use-case is pretty test-specific
so ie I want to do Something.new(foo: double) and don’t care about the rest
with positioned args it is weird, I gotta pass nils
nils are replaced by auto-inject
this needs some thinking
Andy Holland
@AMHOL
Ahh OK
Piotr Solnica
@solnic
I still don’t have a way of using container to provide mocked deps
Andy Holland
@AMHOL
Well to provide mocked deps, skip the container registration step, in test env and register your mocks instead
Piotr Solnica
@solnic
that’s not that simple
Andy Holland
@AMHOL
How come?
Piotr Solnica
@solnic
when running all tests I don’t want to have mocked deps globally
I only want mocked deps for specific tests
we gotta solve this part in some smart way
Andy Holland
@AMHOL
Could add a test mode
Piotr Solnica
@solnic
how would that work?
Andy Holland
@AMHOL
Was thinking rather than https://github.com/dryrb/dry-container/blob/master/lib/dry/container/registry.rb it would not raise on registration of a duplicate key
Piotr Solnica
@solnic
a simple way would be sth like container.stub(‘persistence.foo’ => double())
Andy Holland
@AMHOL
But that would overwrite the existing value
Piotr Solnica
@solnic
of course only in test mode
Andy Holland
@AMHOL
Yeah, but it could be done via configuration
Piotr Solnica
@solnic
it would have to remember original value and restore it on teardown
this would be super useful
Andy Holland
@AMHOL
Yeah, still not sure of the best way to go about it
Piotr Solnica
@solnic
we won’t know until we try