Forum: Ruby on Rails TDD-ing Capistrano tasks

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2006-12-22 21:18
(Received via mailing list)

The time has come for me to learn some Cap. Imagine my surprise when I
discover the Rails test/ folder contains no capistrano/ sub-folder.

How do y'all write tests showing what your cap tasks will do? Or is
Capistrano code fire-and-forget, unlike everything else in Rails?

(Note this is not the question "how to run tests before deploying?"
That's easy, and more Googlable...)

  Phlip  <-- NOT a blog!!
2a3be1d8227283eb4e1613ef631d78b8?d=identicon&s=25 Rob Kaufman (Guest)
on 2006-12-29 23:02
(Received via mailing list)
Since Capistrano tasks are just like every other kind of Rake task, I
test them the same way I test any .rake file.  Here's a generic Rake
require File.dirname(__FILE__) + '/../test_helper'
load RAILS_ROOT + '/Rakefile'
#Ye Olde Rakefile
load RAILS_ROOT + '/lib/tasks/deflector_dish.rake'

class DeflectorDishTest < Test::Unit::TestCase
  fixtures :leads, :tags, :taggings
  include Rake

  def test_dd_import_nslc_exists
    assert get_task_names.include?("deflector_dish:import_nslc_leads")

 #Setting an Enviroment variable.  This would be
 # "rake deflector_dish:import_nslc_leads
INFILE="./test/fixtures/nslc_leads/edloan.csv" at the command line
def test_dd_import_nslc_leads
    ENV['INFILE'] = File.expand_path(RAILS_ROOT +

    assert Task['deflector_dish:import_nslc_leads'].invoke

-------END CODE--------

Rob Kaufman
This topic is locked and can not be replied to.