Skip to content

Bring the Rake task into Rubytest - #13

Merged
trans merged 1 commit into
masterfrom
feature/rake-task
Nov 17, 2026
Merged

trans merged 1 commit into
masterfrom
feature/rake-task

Conversation

@trans

@trans trans commented Nov 17, 2026

Copy link
Copy Markdown
Member

Adds rubytest/rake with Test::Rake::TestTask, brought in from rubytest-rake 0.2.0, so the task no longer needs a separate gem.

require 'rubytest/rake'

Test::Rake::TestTask.new do |run|
  run.loadpath 'lib'
  run.test_files << 'test/*_test.rb'
end

Differences from rubytest-rake

  • The task fails when the run does. rubytest-rake forked, waited for the child and never looked at its status, so rake test exited 0 on failing or crashing tests. The task now exits 1.
  • Default globs. With no files given, the task uses only those of its four default globs that match a file. rubytest 0.10 fails a glob that matches nothing, so rubytest-rake's defaults crash unless a project has a file for every one. If none match, the task says which globs it looked for.
  • TEST replaces the task's files for one invocation (rake test TEST=test/foo_test.rb). In rubytest-rake it replaced only the defaults, and files added in the block still ran.
  • No shell mode. mode == 'shell' called run_shell, which was never defined. Config#mode itself is untouched.
  • Defaults are applied when the task runs, after the block, so a block that sets files or a load path replaces them instead of adding to them.

Rake stays a development dependency: anything that requires rubytest/rake already has it.

Testing

  • bundle exec rake test: 6 demos, 46 steps, 122 assertions, all passing on Ruby 3.4.9, and the same in a ruby:2.7 container. demo/06_rake_task.md is new and covers a passing run, a failing run, the default globs, no files found, and TEST.
  • A real Rakefile under rake: exit 1 with a failing test, exit 0 with TEST pointing at a passing file, and the task listed by rake -T.
  • Not tried on a platform without fork; that path runs the tests in Rake's own process.

🤖 Generated with Claude Code

Add rubytest/rake with Test::Rake::TestTask, from rubytest-rake 0.2.0.

Check the forked run's exit status, so the task fails when the run does:
rubytest-rake waited for the child and then always exited 0. Use only the
default globs that match a file, since the runner now fails a glob that
matches nothing. Let TEST replace the task's files for one invocation.
Drop the shell mode, which called an undefined method.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@trans
trans merged commit 5d0695a into master Nov 17, 2026
6 checks passed
@trans trans mentioned this pull request Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant