Skip to content

Commit

Permalink
Allow single tests to be passed in rake test task
Browse files Browse the repository at this point in the history
  • Loading branch information
svanhesteren committed Sep 5, 2024
1 parent c1a279a commit 6d78319
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ else
t.libs << "test"
t.libs << "lib"

# Running specific tests with line numbers, like with rails test, is not supported by default in rake.
# By setting the TESTOPS env var we can however specify the name of a single test with underscores instead of spaces.
# So run your single test by calling for ex:
#
# rake test /Users/sebastian/projects/cheddar/rails-twirp/test/ping_controller_test.rb "uncaught errors should bubble up to the test"

file_name = ARGV[1]
test_name = ARGV[2]&.tr(" ", "_")

ENV["TESTOPTS"] = "--verbose"

t.test_files = if file_name
if test_name
ENV["TESTOPTS"] = ENV["TESTOPTS"] + " --name=#{test_name}"
end
[file_name]
else
FileList["test/**/*_test.rb"]
Expand Down

0 comments on commit 6d78319

Please sign in to comment.