|
%check ruby -Ilib -e 'Dir.glob "./test/**/*_test.rb", &method(:require)'
|
|
|
You might need to adjust `+-Ilib+` to be `+-Ilib:test+`, or you could need to use a slightly different matching pattern for `+test_*.rb+`, etc. Packagers are expected to use the right pattern for each gem.
|
|
|
RSpec
|
|
|
To run tests using RSpec >= 3 you add `BuildRequires: rubygem-rspec` and use something like:
|
|
|
%check rspec -Ilib spec
|
|
|
Test suites not included in the package
|
|
|
Sometimes you have to get the tests separately from upstream's gem package. As an example lets suppose you're packaging `rubygem-delorean`, version 1.2.0, which is hosted on Github. Tests are not included in the Gem itself, so you need to get them and adjust the specfile accordingly:
|
|
|
# git clone https://github.com/bebanjo/delorean.git && cd delorean # git checkout v1.2.0 # tar -czf rubygem-delorean-1.2.0-specs.tgz spec/ Source1: %{name}-%{version}-specs.tgz
|
|
|
# ... %prep %setup -q -n %{gem_name}-%{version} -b 1
|
|
|
# ...
|
|
|
%check pushd ./%{gem_instdir} # Link the test suite into the right place in source tree. ln -s %{_builddir}/spec .
|
|
|
# Run tests rspec spec popd
|
|
|
Make sure to include the version of the tests in the source name, so that when updating to new version, rpmbuild will fail because it won't find the proper `+%{SOURCE1}+` (and this will remind you to update the tests, too).
|
|
|
Add the commands you used to get the tests into the specfile as comments. This will make it a lot easier the next time you will need to get them.
|
|
|
Run the tests as you normally would.
|
|