Sha256: 571ac35057dd44aa98cc6a826b71c409e735582bb3f3e0c0f9b7e6f87c3bd3a6

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

##############################################################################
# File::    dirs.rb
# Purpose:: Spec directory helper methods
# 
# Author::    Jeff McAffee 07/05/2014
# Copyright:: Copyright (c) 2014, kTech Systems LLC. All rights reserved.
# Website::   http://ktechsystems.com
##############################################################################

def spec_tmp_dir(relative_path = '')
  here = Pathname.new(__dir__)
  tmp = here + '../../tmp/spec'
  tmp = tmp + relative_path unless relative_path.empty?
  tmp.mkpath
  tmp.realdirpath
end

def spec_data_dir
  here = Pathname.new(__dir__)
  tmp = here + '../data'
  tmp.mkpath
  tmp.realdirpath
end

def clean_target_dir dir
  target_dir = spec_tmp_dir + Pathname(dir)
  target_dir.rmtree if target_dir.exist?
  target_dir.mkpath
  target_dir
end

def with_target_dir dir
  working_dir = clean_target_dir dir
  FileUtils.cd working_dir do
    yield(working_dir)
  end
end

def copy_from_spec_data src_file, dest_file
  src_path = spec_data_dir + src_file
  dest_path = spec_tmp_dir + dest_file
  dest_path.dirname.mkpath
  FileUtils.cp src_path, dest_path
  dest_path
end

##
# DEPRECATED
#
def data_dir path = nil
  return 'spec/data' unless path
  return File.join('spec/data', path)
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
admin_module-0.1.8 spec/support/dirs.rb
admin_module-0.1.7 spec/support/dirs.rb
admin_module-0.1.6 spec/support/dirs.rb
admin_module-0.1.5 spec/support/dirs.rb
admin_module-0.1.4 spec/support/dirs.rb