Class: TestThat::RubyTester

Inherits:
Object
  • Object
show all
Defined in:
lib/test_that/ruby_tester.rb

Constant Summary collapse

REQUIRE_ALL_TESTS =
'-e "Dir.glob(\"**/*_test.rb\", base: \"test\"){|f| require f}"'
REQUIRE_EACH_TEST =
'-e "ARGV.each{|f| require f}"'

Instance Method Summary collapse

Instance Method Details

#enabled?Boolean



8
9
10
# File 'lib/test_that/ruby_tester.rb', line 8

def enabled?
  File.directory?("test")
end

#select_tests(files) ⇒ Object



12
13
14
15
16
# File 'lib/test_that/ruby_tester.rb', line 12

def select_tests(files)
  files
    .select { |f| f.start_with?("test/") }
    .select { |f| f.end_with?("_test.rb") }
end

#test_all_commandObject



18
19
20
# File 'lib/test_that/ruby_tester.rb', line 18

def test_all_command
  ["ruby", "-Itest", REQUIRE_ALL_TESTS].join(" ")
end

#test_files_command(files) ⇒ Object



22
23
24
25
# File 'lib/test_that/ruby_tester.rb', line 22

def test_files_command(files)
  files_relative_to_test_dir = files.map { |f| f.sub(%r{\Atest/}, "") }
  ["ruby", "-Itest", REQUIRE_EACH_TEST, *files_relative_to_test_dir].join(" ")
end