From 9687825fe03dd66adce33fc831f57c9747f69d42 Mon Sep 17 00:00:00 2001 From: Tony Schneider Date: Tue, 15 Aug 2023 08:45:00 -0400 Subject: [PATCH] Add initial tests that run Jim's "checks" --- .github/workflows/ci.yml | 4 ++-- rakelib/test.rake | 9 +++++++++ tests/check_test.rb | 26 ++++++++++++++++++++++++++ tests/test_helper.rb | 4 ++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 rakelib/test.rake create mode 100644 tests/check_test.rb create mode 100644 tests/test_helper.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4df57da..523c778 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,5 +12,5 @@ jobs: with: ruby-version: "3.2.2" - - name: rake check - run: rake check \ No newline at end of file + - name: run tests + run: rake test \ No newline at end of file diff --git a/rakelib/test.rake b/rakelib/test.rake new file mode 100644 index 0000000..952ce7f --- /dev/null +++ b/rakelib/test.rake @@ -0,0 +1,9 @@ +require 'rake/testtask' + +Rake::TestTask.new do |t| + t.libs << "tests" + t.test_files = FileList["tests/**/*_test.rb"] + t.verbose = true +end +desc 'Run tests' + diff --git a/tests/check_test.rb b/tests/check_test.rb new file mode 100644 index 0000000..ba51df2 --- /dev/null +++ b/tests/check_test.rb @@ -0,0 +1,26 @@ +require_relative "test_helper" + +class CheckTest < Minitest::Test + def with_captured_stdout + original_stdout = $stdout + $stdout = StringIO.new + yield + $stdout.string + ensure + $stdout = original_stdout + end + + def test_check_asserts + output = with_captured_stdout do + Rake::Task['check:asserts'].invoke + end + assert_match(/OK/, output) + end + + def test_check_abouts + output = with_captured_stdout do + Rake::Task['check:abouts'].invoke + end + assert_match(/OK/, output) + end +end \ No newline at end of file diff --git a/tests/test_helper.rb b/tests/test_helper.rb new file mode 100644 index 0000000..0abf0b6 --- /dev/null +++ b/tests/test_helper.rb @@ -0,0 +1,4 @@ +require "minitest/autorun" +require "rake" + +Rake.application.load_rakefile \ No newline at end of file