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