Closed ehannes closed 5 years ago
Use block with stub
, rspec example:
around do |ex|
Fortnox::API::Registry.stub(:test, Model::Test, &ex)
end
In future, use our forum and chat for asking questions (see CONTRIBUTING.md), this way you'd get the answer a lot faster.
Hi! Thanks for a great gem!
I have a question regarding testing. Is it possible to somehow unregister objects from the registry? I have a problem with leaking test object added to the registry.
Before I had this code:
Now I get an error:
cannot stub "test" - no such key in container
. When I try adding thetest
object to the registry before stubbing, as you suggest in the documentation, the first test passes but the second fails with:Also, I found below code in your own test suite. Unfortunately, I cannot do the same in my test since my registry includes other objects that I do not want to throw away :)