Skip to content

Commit aa768eb

Browse files
tonywokTong-Kiat Tan
authored and
Tong-Kiat Tan
committed
Add initial tests that run Jim's "checks"
1 parent d8b5619 commit aa768eb

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ jobs:
1212
with:
1313
ruby-version: "3.2.2"
1414

15-
- name: rake check
16-
run: rake check
15+
- name: run tests
16+
run: rake test

rakelib/test.rake

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'rake/testtask'
2+
3+
Rake::TestTask.new do |t|
4+
t.libs << "tests"
5+
t.test_files = FileList["tests/**/*_test.rb"]
6+
t.verbose = true
7+
end
8+
desc 'Run tests'
9+

tests/check_test.rb

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require_relative "test_helper"
2+
3+
class CheckTest < Minitest::Test
4+
def with_captured_stdout
5+
original_stdout = $stdout
6+
$stdout = StringIO.new
7+
yield
8+
$stdout.string
9+
ensure
10+
$stdout = original_stdout
11+
end
12+
13+
def test_check_asserts
14+
output = with_captured_stdout do
15+
Rake::Task['check:asserts'].invoke
16+
end
17+
assert_match(/OK/, output)
18+
end
19+
20+
def test_check_abouts
21+
output = with_captured_stdout do
22+
Rake::Task['check:abouts'].invoke
23+
end
24+
assert_match(/OK/, output)
25+
end
26+
end

tests/test_helper.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
require "minitest/autorun"
2+
require "rake"
3+
4+
Rake.application.load_rakefile

0 commit comments

Comments
 (0)