12
Root
4y

It’s late, and stupid RSpec has decided to only mock calls to a particular method in some specs but not in others.

`allow(object).to receive(:method).with(resource_arg).and_return(“some\ntext”)`

Works in a few specs, but not the rest. Why? Who the fuck knows. Probably some shared state between specs that isn’t supposed to happen.

HAHA JUST KIDDING

After refactoring my specs to use unique ‘resource’ names for each call because I’ve had shared state issues before.

and after refactoring my model code to remove a lot of now-unused dependency injection (because maybe it was mocking a different object than got passed in?)

Guess what?
When creating my mock objects, I forgot to link them together. That’s it. A 14-character change. And suddenly they all pass.

Asdjklfajg.
Time for bed.

Comments
  • 3
    sleep well 😭 happens to the best of us
  • 3
    /me puts some breakfast next to the bed

    Don't be grumpy, it can happen to all of us
  • 2
    I feel you.

    I thought I found a bug in UIKit (Apple’s main UI library) because my issue was so unknown but it was just me. A day later I saw a glowing issue and I made a special demo for that feature, and now I might be able to finally implement it in the real deal, but still. REALLY annoying
Add Comment