api = double "myApi"
api.should_receive(:get_info).and_return({
# a 360 lines hash!
})
I want to provide the response that should return from this double.
But this response is a VERY long hash, and I don’t want to clutter my spec file.
Instead I want to write the hash in separate file, and use it in my spec
So, What is the best practices around ?
The best practise would be to not stub out the whole hash. Surely your tests wont require each and every line. You would be better off stubbing out the few lines that each test will need in each test / context.
If you must stub the whole api, you can create a separate module in
spec/support:Since anything in that folder gets included automatically, you can then use
ApiStub.responsein your stub definition.