Translation(s): none


ruby tests

Note: temporary content, copied from piratepad (to have the page here and make sure it won't be overlooked) If it is good it will stay.

Note: Probably a better place for this is Ruby/Packaging/Tests as it is common for any ruby gem.

= Introduction to software testing = Most of the ruby libraries contain test code which uses the functionanlity provided by the library and compare results with known inputs. Commonly used testing framework is rspec. Look in your gem to see if there is a 'spec' directory. Other test frameworks may use a 'test' directory.

Running tests

If the gem has tests defined (see if it has 'test or 'spec' directories), make sure you run them successfully. By default gem2deb creates 'debian/ruby-tests.yaml', but it may not work always. If your test or spec directory contains files with extentions other than .rb, this is most certainly going to fail. You can try removing non-ruby files from ruby-test-files.yaml and rebuild it. If it still does not work, try the other two methods described below.

Note: If you don't find ruby-tests.rb in debian directory, you have to create it from the sample file given above. You have to remove ruby-test-files.yaml too.

Uncomment this line in ruby-tests.rb to add custom library paths.

$: << 'lib' << '.'

If it could be done with not much effort, consider instead patching the tests not to override default $LOADPATH (aka $:) variable.

fixing errors

Tips to fixing test errors:

Case one: a required library is missing

no such file to load -- shoulda (LoadError), 

search for shoulda ie, apt-cache search shoulda. If you find it is already packaged, install it with apt-get install ruby-shoulda.

Note: Remember to add the build dependency you just found to Build-Depends: in debian/control

case two: lib/test/spec is not in library load path

  in `require': no such file to load -- test_helper (LoadError)

$: << 'lib' << '.' (something like $: << 'test' )