I'm creating a gem which has
- several scripts in the bin directory
- the utility classes in the lib directory
- and several tests in the test directory
supertool bin toolA toolB lib supertool supertool.rb helper.rb test tc_main.rb tc_etc.rb
Now, to run the tests before I even install the gem, I have the following snippet at the top of my tests:
base = File.basename(Dir.pwd) if base == 'test' || base =~ /supertool/ Dir.chdir('..') if base == 'test' $LOAD_PATH.unshift(Dir.pwd + '/lib') Dir.chdir('test') if base =~ /supertool/ end
This seems tedious though, especially if I have to put these in the scripts in the bin directory too. Is there a better way of setting up the environment so we can test gems before they are installed? I'm sure it's something simple that I just can't find. A simple link to the right place would help a lot :)
Selenium Ruby Reporting
Nicely formatting output to console, specifying number of tabs
Running Ruby scripts under JRuby/Rack as if they were CGIs
It doesn't seem to have anything to do with gems....
running ruby as a windows exe program
Is it so that you can run
ruby tc_main.rbfrom within the test directory (or
ruby test/tc_main.rbfrom the base dir), and have it set the load path appropriately? If so, here's a much nicer way:.
Reuse Cucumber steps
In your test directory, create a
How can I handle large files in Ruby?
In that file, put this.
How to look up elevation data by lat/lng
And in all your test files, set the first line to.
$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' )
Rewrite a ruby class on the fly
If you have subdirectories inside your test dir, then files in those subdirs can just do.