Module: Hoe::Test
- Defined in:
- lib/hoe/test.rb
Overview
Test plugin for hoe.
Tasks Provided:
- audit
-
Run ZenTest against the package.
- default
-
Run the default task(s).
- multi
-
Run the test suite using multiruby.
- test
-
Run the test suite.
- test_deps
-
Show which test files fail when run alone.
Constant Summary collapse
- SUPPORTED_TEST_FRAMEWORKS =
Configuration for the supported test frameworks for test task.
{ :minitest => "minitest/autorun", :none => nil, }
Instance Attribute Summary collapse
-
#multiruby_skip ⇒ Object
Optional: Array of incompatible versions for multiruby filtering.
-
#test_prelude ⇒ Object
Optional: Additional ruby to run before the test framework is loaded.
-
#test_task ⇒ Object
The test task created for this plugin.
-
#testlib ⇒ Object
Optional: What test library to require [default: :minitest].
Instance Method Summary collapse
-
#define_test_tasks ⇒ Object
Define tasks for plugin.
-
#initialize_test ⇒ Object
Initialize variables for plugin.
Instance Attribute Details
#multiruby_skip ⇒ Object
Optional: Array of incompatible versions for multiruby filtering. Used as a regex.
Can be defined both in .hoerc and in your hoe spec. Both will be used.
30 31 32 |
# File 'lib/hoe/test.rb', line 30 def multiruby_skip @multiruby_skip end |
#test_prelude ⇒ Object
Optional: Additional ruby to run before the test framework is loaded.
40 41 42 |
# File 'lib/hoe/test.rb', line 40 def test_prelude @test_prelude end |
#test_task ⇒ Object
The test task created for this plugin.
45 46 47 |
# File 'lib/hoe/test.rb', line 45 def test_task @test_task end |
#testlib ⇒ Object
Optional: What test library to require [default: :minitest]
35 36 37 |
# File 'lib/hoe/test.rb', line 35 def testlib @testlib end |
Instance Method Details
#define_test_tasks ⇒ Object
Define tasks for plugin.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/hoe/test.rb', line 60 def define_test_tasks default_tasks = [] task :test if File.directory? "test" then case testlib when :minitest then require "minitest/test_task" # in minitest 5.16+ test_prelude = self.test_prelude self.test_task = Minitest::TestTask.create :test do |t| t.test_prelude = test_prelude t.libs.prepend Hoe.include_dirs.uniq end when :none then # do nothing else warn "Unsupported? Moving to Minitest::TestTask. Let me know if you use this!" end desc "Run the test suite using multiruby." task :multi do skip = with_config do |config, _| config["multiruby_skip"] + self.multiruby_skip end ENV["EXCLUDED_VERSIONS"] = skip.join(":") system "multiruby -S rake" end default_tasks << :test end desc "Run the default task(s)." task :default => default_tasks desc "Run ZenTest against the package." task :audit do libs = %w[lib test ext].join(File::PATH_SEPARATOR) sh "zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(" ")}" end end |
#initialize_test ⇒ Object
Initialize variables for plugin.
50 51 52 53 54 55 |
# File 'lib/hoe/test.rb', line 50 def initialize_test self.multiruby_skip ||= [] self.testlib ||= :minitest self.test_prelude ||= nil self.test_task = nil end |