Reputation: 11
How to create rspec factory of activeresource model?
Upvotes: 1
Views: 204
Reputation: 931
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
Upvotes: 1