Sha256: 80f231865bc4f5d751c8564d38ed76491a56d98ceb573712af9139f362eb5736

Contents?: true

Size: 1.03 KB

Versions: 21

Compression:

Stored size: 1.03 KB

Contents

require "fileutils"
require "pathname"

require "log4r"

require "support/isolated_environment"

module Unit
  class IsolatedEnvironment < ::IsolatedEnvironment
    def create_vagrant_env(options=nil)
      options = {
        :cwd => @workdir,
        :home_path => @homedir
      }.merge(options || {})

      Vagrant::Environment.new(options)
    end

    # This creates a file in the isolated environment. By default this file
    # will be created in the working directory of the isolated environment.
    def file(name, contents)
      @workdir.join(name).open("w+") do |f|
        f.write(contents)
      end
    end

    def vagrantfile(contents, root=nil)
      root ||= @workdir
      root.join("Vagrantfile").open("w+") do |f|
        f.write(contents)
      end
    end

    def box(name, vagrantfile_contents="")
      box_dir = boxes_dir.join(name)
      box_dir.mkpath
      vagrantfile(vagrantfile_contents, box_dir)
      box_dir
    end

    def boxes_dir
      dir = @homedir.join("boxes")
      dir.mkpath
      dir
    end
  end
end

Version data entries

21 entries across 21 versions & 6 rubygems

Version Path
bmhatfield-vagrant-1.0.10 test/unit/support/isolated_environment.rb
bmhatfield-vagrant-1.0.9 test/unit/support/isolated_environment.rb
bmhatfield-vagrant-1.0.8 test/unit/support/isolated_environment.rb
bmhatfield-vagrant-1.0.7 test/unit/support/isolated_environment.rb
vagrantup-1.0.7 test/unit/support/isolated_environment.rb
vagrantup-1.0.6 test/unit/support/isolated_environment.rb
vagrantup-1.0.5 test/unit/support/isolated_environment.rb
vagrantup-1.0.4 test/unit/support/isolated_environment.rb
vagrantup-1.0.3 test/unit/support/isolated_environment.rb
vagrantup-1.0.2 test/unit/support/isolated_environment.rb
vagrantup-1.0.1 test/unit/support/isolated_environment.rb
vagrant-fixed-ssh-1.0.7 test/unit/support/isolated_environment.rb
vagrant-1.0.7 test/unit/support/isolated_environment.rb
vagrant-1.0.6 test/unit/support/isolated_environment.rb
boxcar-0.10005.1 test/unit/support/isolated_environment.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/vagrant-1.0.5/test/unit/support/isolated_environment.rb
vagrant-1.0.5 test/unit/support/isolated_environment.rb
vagrant-1.0.4 test/unit/support/isolated_environment.rb
vagrant-1.0.3 test/unit/support/isolated_environment.rb
vagrant-1.0.2 test/unit/support/isolated_environment.rb