Class: Gemma::RakeTasks::MinitestTasks
- Defined in:
- lib/gemma/rake_tasks/minitest_tasks.rb
Overview
Create tasks to run minitest tests. By default, the require_paths from
the gemspec and the gem's test directory are placed on the load path,
and the test_files given in the gemspec are executed as tests.
Minitest works on both 1.8 and 1.9, and it's mostly compatible with Test::Unit tests.
This plugin is based on the Rake::TestTask that comes bundled with rake.
If you need an option that isn't exposed by the plugin, you can modify the
TestTask object directly in a block passed to #with_test_task.
Instance Attribute Summary collapse
-
#files ⇒ Array<String>
The files to test; defaults to the
test_filesfrom the gemspec. -
#task_name ⇒ Symbol
Name of rake task used to run the test; defaults to test.
Attributes inherited from Plugin
Instance Method Summary collapse
-
#create_rake_tasks ⇒ nil
Internal method; see Plugin#create_rake_tasks.
-
#initialize(gemspec) ⇒ MinitestTasks
constructor
A new instance of MinitestTasks.
-
#with_test_task {|tt| ... } ⇒ nil
Customize the test task.
Constructor Details
#initialize(gemspec) ⇒ MinitestTasks
Returns a new instance of MinitestTasks.
21 22 23 24 25 26 27 28 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 21 def initialize(gemspec) super # Defaults. @task_name = :test @files = gemspec.test_files.dup @with_test_task = nil end |
Instance Attribute Details
#files ⇒ Array<String>
The files to test; defaults to the test_files from the gemspec.
42 43 44 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 42 def files @files end |
#task_name ⇒ Symbol
Name of rake task used to run the test; defaults to test.
35 36 37 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 35 def task_name @task_name end |
Instance Method Details
#create_rake_tasks ⇒ nil
Internal method; see Plugin#create_rake_tasks.
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 66 def create_rake_tasks unless files.empty? require 'rake/testtask' Rake::TestTask.new(task_name) do |tt| tt.libs = gemspec.require_paths.dup tt.libs << 'test' tt.test_files = files @with_test_task&.call(tt) end end nil end |
#with_test_task {|tt| ... } ⇒ nil
Customize the test task.
is generated
54 55 56 57 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 54 def with_test_task(&block) @with_test_task = block nil end |