class Test::Rake::TestTask
Define a test rake task.
The ‘TEST` environment variable can be used to select tests when using this task. Note, this is just a more convenient way than using `RUBYTEST_FILES`.
Constants
- DEFAULT_TESTS
Glob patterns are used by default to select test scripts.
Attributes
config[R]
Test
run configuration.
@return [Config]
Public Class Methods
new(name='test', desc='run tests', &block)
click to toggle source
Initialize new Rake::TestTask
instance.
# File lib/rubytest-rake.rb, line 35 def initialize(name='test', desc='run tests', &block) @name = name || 'test' @desc = desc @config = Test::Config.new @config.files << default_tests if @config.files.empty? @config.loadpath << 'lib' if @config.loadpath.empty? block.call(@config) define_task end
Public Instance Methods
default_tests()
click to toggle source
Default test globs. For extra convenience will look for list in ‘ENV` first.
@return [Array<String>]
# File lib/rubytest-rake.rb, line 106 def default_tests if ENV['TEST'] ENV['TEST'].split(/[:;]/) else DEFAULT_TESTS end end
define_task()
click to toggle source
Define rake task for testing.
@return nothing
# File lib/rubytest-rake.rb, line 52 def define_task desc @desc task @name do config.mode == 'shell' ? run_shell : run end end
run()
click to toggle source
Run tests, via fork is possible, otherwise straight out.
@return nothing
# File lib/rubytest-rake.rb, line 62 def run if Process.respond_to?(:fork) fork { runner = Test::Runner.new(config) success = runner.run exit -1 unless success } Process.wait else runner = Test::Runner.new(config) success = runner.run exit -1 unless success end end
shell_run()
click to toggle source
Run test via shell. (Not Currently Used)
Note, the problem with this approach is that before and after procedures cannot be passed along. In it’s current form it also requires that ‘rubytest-cli` be installed.
@return nothing
# File lib/rubytest-rake.rb, line 84 def shell_run success = ruby('rubytest', *config.to_shellwords) exit -1 unless success end