Alex Young
6/15/2007 7:21:00 AM
David Moody wrote:
> David Moody wrote:
>> Hello all,
>>
>> This is my first post to this forum and I am a ruby nood who usually
>> does C# development.
>>
>> I am working on a little app and have seperated my classes into
>> different files. I put all of those file into a directory called lib.
>> like this
>>
>> trunk
>> -----lib
>> -------JobList.rb
>> -----tests
>> -------JobListTest.rb
>> -----testfiles
>>
>> In the test dir I have a file that does some unit testing. If I put
>>
>> load '../lib/JobList'
I usually handle this by having a file 'test/boottest.rb' that looks
like this (along with whatever other project-specific bits and pieces I
might need across all test files):
$app_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
$:.unshift($app_dir)
That means that I can handle all the requires as though from the project
root, so the top of a test file might look like this:
require 'boottest'
require 'test/TestModules'
require 'lib/JobList'
It simplifies things a little, because then there's less confusion as to
which files are being required.
--
Alex