Ruby gem testing before deployment

Ruby gem testing before deployment

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
I'm not sure what you're trying to achieve with that script.

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.rb from within the test directory (or ruby test/tc_main.rb from 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 test_helper.rb file.

How can I handle large files in Ruby?
In that file, put this.
How to look up elevation data by lat/lng
$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' ) 
And in all your test files, set the first line to.
Rewrite a ruby class on the fly
require 'test_helper' 
If you have subdirectories inside your test dir, then files in those subdirs can just do.
require '../test_helper' 


Take a look at hoe gem, it is a helper for other gems..

80 out of 100 based on 50 user ratings 950 reviews