Testing Models with Multiple Database Connections in Rails Using ActiveRecord

What is the best way to test a model using a different database connection in Rails. For example, I have a FooBar model that is only readable:

class FooBar < ActiveRecord::Base
  establish_connection configurations['foo_bars']
  # ...
end

Are there any good deals, hacks, or plugins?

+3
source share
1 answer

In my experience, once the connection is established, you can view the model just like any other model. Because you are simply consuming data that will simplify some of the tests, since you do not need to verify the validity of the data.

, Rails , , .

, : , ? , , , .

, , , , "Rails-y" has_one belongs_to . , .

, .

+1

Source: https://habr.com/ru/post/1706424/


All Articles