Life In The Stack Trace...

TODO: <Insert clever marketing phrase here>

Duck Test Quick Start


Duck Test facilitates running tests within the Rails IRB console. Running tests are essential to solid application development and the standard Rails mechanism for running tests does a fine job. However, as the Rails framework has matured coupled with the plethora of gems available to developers the start up of the Rails environment can increase to a point that can make TDD a bit painful. Ducktest runs within the Rails console allowing the developer to run the Rails environment in the console and develop tests rapidly. Ducktest recognizes when test files have changed and runs them automagically within a second. Included is a command set that allows you to interrogate the environment and trigger tests manually if needed. The power of running tests within the rails console allows you to do things like instantiate a model and trigger a method or manipulate attributes. You can even run the debugger!!

Important Note

It is very important to note that Ducktest is intended for rapid development of Rails tests by editing runnable test and having them run immediately. You should continue to run the entire test suite in the normal fashion.


DuckTest was developed on a 64-bit Ubuntu Linux box using Ruby 1.9.3p0, Rails 3.2.1, and rubygems 1.8.11 The codebase uses the 1.9 Hash syntax

 # 1.9 style
 x = {autorun: true, basedir: "/tmp"}

 # prior 1.9
 x = {:autorun => true, :basedir => "/tmp"}

Therefore, you need 1.9 or greater to use this gem. Also, I haven't done ANY testing on earlier versions of Rails, so, I have no idea what will work. Use at your own risk.

Quick start

Create a new rails app named

rails new --skip-bundle

Edit and add the following to your test group

group :test do
  # ... existing gems
  gem 'turn', :require => false
  gem 'duck_test'

Run bundle

bundle install

Generate a scaffold with some tests, then, migrate and prepare the test environment

rails g scaffold book author:string title:string
rake db:migrate
rake test:prepare

Run the Rails console

rails c test

Edit one of the test files: test/unit/book_test.rb

require 'test_helper'
class BookTest < ActiveSupport::TestCase
  test "the truth" do
    assert false

Look at the Rails console and you should see that the test automagically ran and failed. Go back and change the assert from false to true and save. The test should run again and pass.

To see it in action, have a look at the following video: