Module: Anyt::Tests

Defined in:
lib/anyt/tests.rb

Overview

Loads and runs test cases

Constant Summary collapse

DEFAULT_PATTERNS =
[
  File.expand_path("tests/**/*.rb", __dir__)
].freeze

Class Method Summary collapse

Class Method Details

.load_all_testsObject

Load all test files



47
48
49
50
51
# File 'lib/anyt/tests.rb', line 47

def load_all_tests
  test_files_patterns.each do |pattern|
    Dir.glob(pattern).sort.each { |file| require file }
  end
end

.load_testsObject

Load tests code (filtered if present)

NOTE: We should run this before launching RPC server



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/anyt/tests.rb', line 27

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

.runObject

Run all loaded tests



16
17
18
19
20
21
# File 'lib/anyt/tests.rb', line 16

def run
  Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new

  AnyCable.logger.debug "Run tests against: #{Anyt.config.target_url}"
  Minitest.run
end