How do I load fixtures into a mock object in rails for tests?

I have a gem that needs to take data from the internet, but when I am in a test, I want to use a mock. I want to be able to load data into a mock object using rails. Mock objects here .

How can i do this?

+1


a source to share


2 answers


Fast forward 4 years and now there's a gem for that.



webmock . gem basically disables all outgoing api calls and then populates a bunch of code in the error response to insert. From there, you will adjust it to whatever code you want for this answer.

+2


a source


If you have any questions or requests, please email us at support@spreedly.com.



This is a commercial site that makes money from subscriptions. They should be more than willing to provide you with the help you need.

-1


a source







All Articles