'create activeresource model factory using Factory Bot in rails
How to create rspec factory of activeresource model?
Solution 1:[1]
You can create factories for activeresource models just like activerecord models. For example, here is a model and corresponding factory
class Person < ActiveResource::Base
self.site = "http://api.people.com:3000"
end
FactoryBot.define do
factory :person do
name { "test" }
end
end
Note: every time you create a factory (e.g. FactoryBot.create(:person)
), you will make an API request. You may want to mock out API requests when testing. Here is an example of how to use activeresource's http mocking
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Cameron |