Module: Anyt::Tests
- Defined in:
- lib/anyt/tests.rb
Overview
Loads and runs test cases
Constant Summary collapse
- DEFAULT_PATTERNS =
[ File.("tests/**/*.rb", __dir__) ].freeze
Class Method Summary collapse
- .list ⇒ Object
-
.load_all_tests ⇒ Object
Load all test files.
-
.load_tests ⇒ Object
Load tests code (filtered if present).
-
.run ⇒ Object
Run all loaded tests.
Class Method Details
.list ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/anyt/tests.rb', line 24 def list printer = Object.new printer.extend include ANSI::Code Minitest::Runnable.runnables.each do |runnable| def runnable.test_order :sorted end next unless runnable.runnable_methods.any? $stdout.puts(runnable.name) runnable.runnable_methods.each do |method| test_name = method.gsub(/^test_/, "").strip $stdout.puts(printer.magenta { " #{test_name}" }) end end end |
.load_all_tests ⇒ Object
Load all test files
67 68 69 70 71 |
# File 'lib/anyt/tests.rb', line 67 def load_all_tests test_files_patterns.each do |pattern| Dir.glob(pattern).sort.each { |file| require file } end end |
.load_tests ⇒ Object
Load tests code (filtered if present)
NOTE: We should run this before launching RPC server
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/anyt/tests.rb', line 47 def load_tests return load_all_tests unless Anyt.config.filter_tests? skipped = [] filter = Anyt.config.tests_filter test_files_patterns.each do |pattern| Dir.glob(pattern).sort.each do |file| if filter.call(file) require file else skipped << file.gsub(File.join(__dir__, "tests/"), "").gsub("_test.rb", "") end end end $stdout.print "Skipping tests: #{skipped.join(", ")}\n" end |