Class: Shoe::Tasks::Test
Overview
Defines `rake test`
to run your tests.
Uses testrb
to run your test_files
.
To enable and configure, edit the test_files[http://docs.rubygems.org/read/chapter/20#test_files]
in your gemspec.
(You may also want to add a .gemtest
file to the root of your gem, so that others can run your tests via rubygems-test.)
A Few Precautions
-
Using
testrb
means that onlyTest::Unit
(all Rubies) andMiniTest::Unit
(Ruby 1.9) tests will be run. -
You’ll need to
Bundler.setup(:default, :development)
in yourRakefile
so thattestrb
can find your code. -
Your
test_files
need only contain actual tests – support files, like test_helper, need not be included. -
The
LOAD_PATH
will contain all of the immediate parent directories of yourtest_files
. You should not count on the top-level project directory being included – in other words,"require 'test/test_helper'"
may not work, and"require 'test_helper'"
will only work iftest_helper
is a sibling of one of yourtest_files
.
For further clarification on these guidelines, you may find it helpful to browse Shoe’s own test setup.
Instance Attribute Summary
Attributes inherited from Task
Instance Method Summary collapse
Methods inherited from Task
Constructor Details
This class inherits a constructor from Shoe::Tasks::Task
Instance Method Details
#active? ⇒ Boolean
38 39 40 |
# File 'lib/shoe/tasks/test.rb', line 38 def active? !spec.test_files.empty? end |
#define ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/shoe/tasks/test.rb', line 42 def define desc <<-END.gsub(/^ */, '') Run tests. Configure via the `test_files` field in #{spec.name}.gemspec. END task :test do system 'testrb', *spec.test_files end task :prepare task :test => :prepare task :default Rake.application[:default].prerequisites.unshift(Rake.application[:test]) end |