Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2012-11-05 13:40:36
Size: 5
Editor: ?markus tornow
Comment: initial setup
Revision 3 as of 2012-11-05 19:10:35
Size: 3426
Editor: ?markus tornow
Comment: "to got the page" changed to "to have the page"; overseen to overlooked, both proposals by fsmithred
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
tmp #language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: none-~
----
||<tablestyle="float:right; margin: 0px;" style="padding:0.5em; border: 0px;font-size: 80%;"><<TableOfContents>>||

= 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.

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.

    You can try ruby-tests.rb, see ruby-warden for a sample file http://ur1.ca/ao6o8 It allows you to add custom directories to ruby library load path and you may need it if your tests fail to find files already present in 'lib' or 'test' directories.


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.

    You may also try ruby-tests.rake if the gem uses rspec to run the tests (in this case you have a spec/ directory with *_spec.rb files). See ruby-dataobjects-sqlite3 for an example http://ur1.ca/ao6ok


= fixing errors =

Tips to fixing test errors:

    Check for build-depencies on rubygems.org: they are listed as development (see the commented line in debian/control produced by gem2deb). You may not need all the build dependencies listed there, so the only way to be sure is to see the build errors. Normally, you need also the dependencies during the build, if you run the tests (since your library will be used).


    If you see a file is missing in the error message, it may be provided by a gem not yet installed in your system. For example if you see 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

    If you cannot find the package via apt, try if it is a gem file not yet packaged, then run gem list -r shoulda If you find it in the remote gem list, then you need to package it first :) So start from step 1 for this gem and come back to your current gem once your package enters debian!

    If you see spec_helper or test_helper is missing, you may need to add spec or test directory to library load path. Uncomment the following line in ruby-tests.rb and modify it accordingly.

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

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.

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.

    You can try ruby-tests.rb, see ruby-warden for a sample file http://ur1.ca/ao6o8 It allows you to add custom directories to ruby library load path and you may need it if your tests fail to find files already present in 'lib' or 'test' directories.

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.

  • You may also try ruby-tests.rake if the gem uses rspec to run the tests (in this case you have a spec/ directory with *_spec.rb files). See ruby-dataobjects-sqlite3 for an example http://ur1.ca/ao6ok

fixing errors

Tips to fixing test errors:

  • Check for build-depencies on rubygems.org: they are listed as development (see the commented line in debian/control produced by gem2deb). You may not need all the build dependencies listed there, so the only way to be sure is to see the build errors. Normally, you need also the dependencies during the build, if you run the tests (since your library will be used).

    If you see a file is missing in the error message, it may be provided by a gem not yet installed in your system. For example if you see 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

  • If you cannot find the package via apt, try if it is a gem file not yet packaged, then run gem list -r shoulda If you find it in the remote gem list, then you need to package it first :) So start from step 1 for this gem and come back to your current gem once your package enters debian! If you see spec_helper or test_helper is missing, you may need to add spec or test directory to library load path. Uncomment the following line in ruby-tests.rb and modify it accordingly.

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