module RJack::TarPit::TestTaskDefiner
Attributes
rspec_task_config[RW]
Proc for setting RSpec::Core::RakeTask options (default: nil, no-op)
test_loader[RW]
Support same options as Rake::TestTask, plus tarpit's own :mini_in_proc (default) option, which loads minitest tests and runs in (rake) process.
test_task_config[RW]
Proc for setting Rake TestTask options (default: nil, no-op)
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/rjack-tarpit/test.rb, line 34 def initialize super @test_loader = :mini_in_proc @test_task_config = nil @rspec_task_config = nil add_define_hook( :define_test_tasks ) add_define_hook( :define_spec_tasks ) end
Public Instance Methods
define_spec_tasks()
click to toggle source
# File lib/rjack-tarpit/test.rb, line 45 def define_spec_tasks if File.directory?( "spec" ) || rspec_task_config require 'rspec/core/rake_task' desc "Run RSpec on specifications" RSpec::Core::RakeTask.new( :spec ) do |t| t.rspec_opts ||= [] t.rspec_opts += %w[ -Ispec:lib ] rspec_task_config.call( t ) if rspec_task_config end desc "Run RSpec on specifications" task :test => [ :spec ] task :default => [ :test ] end end
define_test_tasks()
click to toggle source
# File lib/rjack-tarpit/test.rb, line 65 def define_test_tasks if test_loader == :mini_in_proc tfiles = FileList[ "test/test*.rb" ] if !tfiles.empty? desc "Run minitest tests (in rake process)" task :test do |t,args| # Let minitest/autorun at_exit run the test require 'minitest/autorun' tfiles.each { |f| load File.expand_path( f ) } end else desc "No-op" task :test end else require 'rake/testtask' Rake::TestTask.new do |t| t.loader = test_loader test_task_config.call( t ) if test_task_config end end task :default => [ :test ] end