简体   繁体   中英

How to load fixtures in a mock object in rails for tests?

I have a gem that should take its data from the web but when I'm in test, I want to use a mock object. I want to be able to load data in the mock object using rails fixtures. The mock objects are here .

How can I do it?

Fast forward 4 years and there is a gem for this now.

webmock . the gem basically shuts down al outgoing api calls and then plops a bunch of code in the error response for you to paste. From there, you adjust it to whatever the desired code's needs are for that response.

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

It's a commercial site that makes money off subscriptions. They should be more than willing to provide you with the help you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM