Reputation: 24088
I want to run most my RSpec-s agains blazing fast SQLite, but be able to "tag" particular specs to use PostgreSQL (due to the heavy use of features of PG).
this is approx what I need:
describe "something" do
it "runs against SQLite by default" do
# etc
end
it "but this against PG", :pg do
# etc
end
end
I can probably hack in the establish_connection
but want to do it "right" so the models don't share any of the stuff between the two.
Another issue is how to run rake tasks against those 2 DBs.
Please NOTE, I'm not asking about using multiple databases from the app. I want to switch DB between the specs.
There gotta be a gem for that :)
Upvotes: 3
Views: 703
Reputation: 2321
One way would be to use this solution:
Rails RSpec with Multiple Databases
Basically in your before(:each / :all) connect to the other database and in your after(:each / :all) restore the default connection.
Upvotes: 1