Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Andy Holland
@AMHOL
I just think it's better to require everything eagerly during setup
Piotr Solnica
@solnic
worth to experiment with this
when booting, YES OF COURSE
when loading a test, NO OF COURSE NOT
ie rspec spec/unit/foo_spec.rb should run in complete isolation
wrt deps
atm I require spec-helper which loads the app, this is nonsense
when I see “123421.214412341 seconds to load files” in the rspec output, I cry
Andy Holland
@AMHOL
lmao
Fair point
If you load in isolation, how do you know the method under test hasn't been monkey wrenched though?
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