Life In The Stack Trace...

TODO: <Insert clever marketing phrase here>

Duck Test On The Mac

Overview

This is basically the same as my original blog post Duck Test Quick Start. The only difference is that I am running it on a Mac. I love the Mac. I wish I could afford one.

Quick start

Create a new rails app named test.com

rails new test.com --skip-bundle

Edit test.com/Gemfile and add the following to your test group

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

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
  end
end

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: http://www.youtube.com/watch?v=J6HOIxvhZh4