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 16d7faa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion test/pbbuilder_template_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PbbuilderTemplateTest < ActiveSupport::TestCase
end

test "render collections with partial as arg" do
skip("This will be addressed in future version of a gem")
skip("This will be addressed in a future version of this gem")
result = render('pb.friends "racers/racer", as: :racer, collection: [Racer.new(1, "Johnny Test", []), Racer.new(2, "Max Verstappen", [])]')

assert_equal 2, result.friends.count
Expand Down

0 comments on commit 16d7faa

Please sign in to comment.