Please read for an updated status on RailsCasts:
Learn more or hide this
GitHub User: wojtha
You can use build_stubbed, that will build object with stubbed associations.
For Better Errors, Sublime Text 2 and Ubuntu see https://gist.github.com/wojtha/4749450
Thank you for the link to ActiveModel::Serializers! It is awesome. I've built the needed JSON outputs in 5 mins for our all entities.
Use poltergeist headless browser driver. It is similar to webkit-capybara, but it is built on top of PhantomJS and easier to setup (no need of Xvfb virtual frame buffer) and place this code to your spec_helper.rb to speed up the tests and to fix the multiple threads issue:
# Small hack to force Selenium/Webkit tests to use single DB thread
# and speed optimization
# See http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
# and https://groups.google.com/forum/#!msg/ruby-capybara/JI6JrirL9gM/R6YiXj4gi_UJ
@@shared_connection = nil
@@shared_connection || retrieve_connection
# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
Devise.stretches = 1
Rails.logger.level = 4
Note: If you are using Spork, place the code to "Spork.each_run" block.
Edit: Ooops. Ryan created an episode about PhantomJS 3 weeks ago. And he encourages to use this hack too ;-)