spacemonkey
spacemonkey

Reputation: 20014

Non-rails application with RSpec, ActiveRecord and Factory Girl

How to properly implement RSpec, ActiveRecord and Factory Girl in non-rails application. I also need that every test case would run on a clean database.

Thanks!

Upvotes: 3

Views: 1681

Answers (1)

Robert Speicher
Robert Speicher

Reputation: 15562

ActiveRecord outside of Rails is a pretty common request, so there's plenty of blog posts and tutorials on getting it done, just Google it. Using it outside of Rails isn't very different from using it within Rails. The major difference is that you'll have to handle the things that Rails usually does for you, like creating the connection, and handling migrations.

RSpec was not designed specifically for Rails, so using that outside of Rails is a non-issue. Just follow the standard tutorial.

Same thing for factory_girl. Rails support was separated from factory_girl proper and moved into a separate gem, so using it without Rails is also simple. Its standard README should be sufficient.

For cleaning the database, use the database_cleaner gem.

Upvotes: 8

Related Questions