Sha256: 2b935300d798675366de1f9e5e2bc9ac90d47f2716e3c21ee861ad3d3c10a398

Contents?: true

Size: 892 Bytes

Versions: 4

Compression:

Stored size: 892 Bytes

Contents

module Omnibus
  module RSpec
    module FileHelpers
      def create_directory(*paths)
        path = File.join(*paths)
        FileUtils.mkdir_p(path)
        path
      end

      def remove_directory(*paths)
        path = File.join(*paths)
        FileUtils.rm_rf(path)
        path
      end

      def copy_file(source, destination)
        FileUtils.cp(source, destination)
        destination
      end

      def remove_file(*paths)
        path = File.join(*paths)
        FileUtils.rm_f(path)
        path
      end

      def create_file(*paths, &block)
        path = File.join(*paths)

        FileUtils.mkdir_p(File.dirname(path))

        if block
          File.open(path, 'wb') { |f| f.write(block.call) }
        else
          FileUtils.touch(path)
        end

        path
      end

      def create_link(a, b)
        FileUtils.ln_s(a, b)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
omnibus-4.0.0 spec/support/file_helpers.rb
omnibus-4.0.0.rc.2 spec/support/file_helpers.rb
omnibus-4.0.0.rc.1 spec/support/file_helpers.rb
omnibus-4.0.0.beta.1 spec/support/file_helpers.rb