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



49
50
51
52
53
# File 'lib/anyt/tests.rb', line 49

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

.load_testsObject

rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength



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

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).each do |file|
      if file.match?(filter)
        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