Stubbing the request object with RSpec
I have some decorator logic that needs to generate a url using the request object. However, when running specs a request object isn’t created, so you have to stub one out.
The key was to use any_instance on the decorator to ensure all instances received the stub. Here’s the code I came up with: