lib/rake/funnel/tasks/nunit.rb in rake-funnel-0.1.0.pre vs lib/rake/funnel/tasks/nunit.rb in rake-funnel-0.2.0.pre
- old
+ new
@@ -2,38 +2,38 @@
module Rake::Funnel::Tasks
class NUnit < Rake::TaskLib
include Rake::Funnel::Support
- attr_accessor :name, :files, :args
+ attr_accessor :name, :nunit, :files, :args
- def initialize(name = :test)
- @name = name
- @args = {}
- @files = %w(build/specs/**/*.dll build/specs/**/*.exe)
+ def initialize(*args, &task_block)
+ setup_ivars(args)
- yield self if block_given?
- define
+ define(args, &task_block)
end
- def nunit
- @_nunit || 'nunit-console.exe'
- end
+ private
+ def setup_ivars(args)
+ @name = args.shift || :test
- def nunit=(value)
- @_nunit = value
+ @nunit = 'nunit-console.exe'
+ @args = {}
+ @files = %w(build/specs/**/*.dll build/specs/**/*.exe)
end
- private
- def define
- desc "Test #{test_assemblies.all_or_default.join(', ')}"
- task name do
+ def define(args, &task_block)
+ desc "Test #{test_assemblies.all_or_default.join(', ')}" unless Rake.application.last_description
+
+ task(name, *args) do |_, task_args|
+ task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
+
Rake::Funnel::Integration::TeamCity::NUnitPlugin.setup(nunit)
cmd = [
*Mono.invocation(nunit),
*test_assemblies.all,
- *Mapper.new(:NUnit).map(args)
+ *Mapper.new(:NUnit).map(@args)
]
sh(*cmd)
end