TDD-ing Capistrano tasks


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...)

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 example: ---------BEGIN CODE FILE test/tasks/deflector_dish_test.rb------------------- 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")   end

#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 + "/test/fixtures/nslc_leads/edloan.csv")

    assert Task['deflector_dish:import_nslc_leads'].invoke   end end

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

Rob Kaufman