HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-3.0.2/spec/ruby/library/tempfile/close_spec.rb
require_relative '../../spec_helper'
require 'tempfile'

describe "Tempfile#close when passed no argument or [false]" do
  before :each do
    @tempfile = Tempfile.new("specs", tmp(""))
  end

  after :each do
    @tempfile.close!
  end

  it "closes self" do
    @tempfile.close
    @tempfile.closed?.should be_true
  end

  it "does not unlink self" do
    path = @tempfile.path
    @tempfile.close
    File.should.exist?(path)
  end
end

describe "Tempfile#close when passed [true]" do
  before :each do
    @tempfile = Tempfile.new("specs", tmp(""))
  end

  it "closes self" do
    @tempfile.close(true)
    @tempfile.closed?.should be_true
  end

  it "unlinks self" do
    path = @tempfile.path
    @tempfile.close(true)
    File.should_not.exist?(path)
  end
end

describe "Tempfile#close!" do
  before :each do
    @tempfile = Tempfile.new("specs", tmp(""))
  end

  it "closes self" do
    @tempfile.close!
    @tempfile.closed?.should be_true
  end

  it "unlinks self" do
    path =  @tempfile.path
    @tempfile.close!
    File.should_not.exist?(path)
  end
end