[rubygems/rubygems] Update `TarWriter` test to store mtime in a variable
authorEllen Marie Dash <[email protected]>
Mon, 5 May 2025 22:03:26 +0000 (5 18:03 -0400)
committerHiroshi SHIBATA <[email protected]>
Thu, 8 May 2025 09:03:04 +0000 (8 18:03 +0900)
https://github.com/rubygems/rubygems/commit/0e2cec3fa3

test/rubygems/test_gem_package_tar_writer.rb

index 7efe9cb..cb9e0d2 100644 (file)
@@ -52,11 +52,13 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
 
   def test_add_file_with_mtime
     Time.stub :now, Time.at(1_458_518_157) do
-      @tar_writer.add_file "x", 0o644, Time.now do |f|
+      mtime = Time.now
+
+      @tar_writer.add_file "x", 0o644, mtime do |f|
         f.write "a" * 10
       end
 
-      assert_headers_equal(tar_file_header("x", "", 0o644, 10, Time.now),
+      assert_headers_equal(tar_file_header("x", "", 0o644, 10, mtime),
                          @io.string[0, 512])
     end
   end