-
Notifications
You must be signed in to change notification settings - Fork 27
Home
dhedlund edited this page Mar 17, 2013
·
6 revisions
Welcome to the spork-testunit wiki!
gem install spork-testunit
- Don't bootstrap the test helper file for testunit. You don't need to, and it doesn't work with test unit.
- In one console, run:
spork testunit
- ignore the bootstrap and other warnings
- In another console, run the list of tests:
testdrb test/unit/my_test_one.rb test/unit/my_test_two.rb
- You can use:
require 'test_helper' unless Spork.using_spork?
to use Spork and no Spork.
- You can use:
- In test helper:
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
# more requires....
end
To correctly load the environment while running testdrb
on your Rails tests make sure to add the test directory to the include path. A couple solutions:
- Use the -I switch on the command line. Running a unit test from the Rails root we'd run
testdrb -I test test/unit/mymodel_test.rb
- Add the test/ directory to the $LOAD_PATH in your Spork.prefork block:
Spork.prefork do ENV["RAILS_ENV"] = "test" $LOAD_PATH << File.expand_path('..', __FILE__) # add test/ to include path # ... end