Sha256: 614d4a3c68c3fa79541e752f9a72c23fdaa3ee4715ddab24aa6ccba7deaa7057

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'
require 'tempfile'
require 'fileutils'
include FileUtils

TMPDIR = File.join(File.dirname(__FILE__), '../tmp')

describe "FileExtensions" do
  before(:all) do
    Dir.mkdir(TMPDIR) unless File.exist?(TMPDIR)
  end

  after(:each) do
    rm_rf(Dir.glob(File.join(TMPDIR,'file_extensions_spec*')))
  end

  it "should make a single directory when it does not exist" do
    dirspec = get_temp_filename
    File.mkdirs(dirspec)
    (File.exist?(dirspec).should be_true) && (File.directory?(dirspec).should be_true)
  end

  it "should make a multiple directories when they do not exist" do
    dirspec = File.join(get_temp_filename, 'foo', 'bar')
    File.mkdirs(dirspec)
    (File.exist?(dirspec).should be_true) && (File.directory?(dirspec).should be_true)
  end

  it "should not make any directories when they already exist" do
    dirspec = File.join(get_temp_filename, 'foo', 'bar')
    File.mkdirs(dirspec)
    File.mkdirs(dirspec)
    (File.exist?(dirspec).should be_true) && (File.directory?(dirspec).should be_true)
  end


  def get_temp_filename
    outfile = Tempfile.new('file_extensions_spec', TMPDIR)
    filespec = outfile.path
    outfile.unlink
    filespec
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
royw-roys_extensions-0.0.2 spec/file_extensions_spec.rb
royw-roys_extensions-0.0.3 spec/file_extensions_spec.rb