Sha256: cc02c4ffa4e23d5add126d8f5893e184040410f7f04e98c09aae8d9a0d009ba8

Contents?: true

Size: 1.71 KB

Versions: 30

Compression:

Stored size: 1.71 KB

Contents

require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb")

describe Tempster do
  it "should create a temporary file" do
    result = nil
    begin
      result = Tempster.mktemp(:verbose => false)
      File.exists?(result).should be_true
    ensure
      File.unlink(result) if result
    end
  end

  it "should create a temporary file and remove it with a block" do
    result = nil
    begin
      Tempster.mktemp(:verbose => false) do |path|
        result = path
        File.exists?(result).should be_true
      end
      File.exists?(result).should be_false
    ensure
      File.unlink(result) if result and File.exists?(result)
    end
  end

  it "should create a temporary directory" do
    result = nil
    begin
      result = Tempster.mktempdir(:verbose => false)
      File.directory?(result).should be_true
    ensure
      Dir.rmdir(result) if result
    end
  end

  it "should create a temporary directory and remove it with a block" do
    result = nil
    begin
      Tempster.mktempdir(:verbose => false) do |path|
        result = path
        File.directory?(result).should be_true
      end
      File.directory?(result).should be_false
    ensure
      Dir.rmdir(result) if result and File.directory?(result)
    end
  end

  it "should create a temporary directory, cd into it and remove it with a block" do
    result = nil
    previous = Dir.pwd
    begin
      Tempster.mktempdircd(:verbose => false) do |path|
        result = path
        File.directory?(result).should be_true
        Dir.pwd.should_not == previous
      end
      File.directory?(result).should be_false
      Dir.pwd.should == previous
    ensure
      Dir.rmdir(result) if result and File.directory?(result)
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
automate-it-0.9.2 spec/integration/tempster_spec.rb
automate-it-0.9.1 spec/integration/tempster_spec.rb
automate-it-0.9.0 spec/integration/tempster_spec.rb
automateit-0.70928 spec/integration/tempster_spec.rb
automateit-0.70930 spec/integration/tempster_spec.rb
automateit-0.71003 spec/integration/tempster_spec.rb
automateit-0.71021 spec/integration/tempster_spec.rb
automateit-0.71031.1 spec/integration/tempster_spec.rb
automateit-0.71031.2 spec/integration/tempster_spec.rb
automateit-0.71030 spec/integration/tempster_spec.rb
automateit-0.71017 spec/integration/tempster_spec.rb
automateit-0.71012 spec/integration/tempster_spec.rb
automateit-0.71006 spec/integration/tempster_spec.rb
automateit-0.71101 spec/integration/tempster_spec.rb
automateit-0.71102 spec/integration/tempster_spec.rb
automateit-0.71031 spec/integration/tempster_spec.rb
automateit-0.71103 spec/integration/tempster_spec.rb
automateit-0.71101.2 spec/integration/tempster_spec.rb
automateit-0.71101.1 spec/integration/tempster_spec.rb
automateit-0.71104 spec/integration/tempster_spec.rb