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_files
from 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.
19 20 21 22 23 24 25 26 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 19 def initialize gemspec super(gemspec) # 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.
40 41 42 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 40 def files @files end |
#task_name ⇒ Symbol
Name of rake task used to run the test; defaults to test.
33 34 35 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 33 def task_name @task_name end |
Instance Method Details
#create_rake_tasks ⇒ nil
Internal method; see Plugin#create_rake_tasks.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 64 def create_rake_tasks unless self.files.empty? require 'rake/testtask' Rake::TestTask.new(self.task_name) do |tt| tt.libs = gemspec.require_paths.dup tt.libs << 'test' tt.test_files = self.files tt.ruby_opts << '-rubygems' << '-rbundler/setup' @with_test_task.call(tt) if @with_test_task end end nil end |
#with_test_task {|tt| ... } ⇒ nil
Customize the test task.
is generated
52 53 54 55 |
# File 'lib/gemma/rake_tasks/minitest_tasks.rb', line 52 def with_test_task &block @with_test_task = block nil end |