Sha256: a33568c100fbe19283cedcc064ec320a7ce602a93128a8803678d7a358da879b

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 Bytes

Contents

module TestConstruct

  module Helpers
    extend self

    def within_construct(opts = {})
      chdir = opts.fetch(:chdir, true)
      container = create_construct(chdir)
      container.maybe_change_dir(chdir) do
        yield(container)
      end
    ensure
      container.destroy! if container.respond_to?(:destroy!)
    end

    def create_construct(chdir = true)
      path = (Pathname(TestConstruct.tmpdir) +
        "#{CONTAINER_PREFIX}-#{$PROCESS_ID}-#{rand(1_000_000_000)}")
      path.mkpath
      path.extend(PathnameExtensions)
      path.construct__chdir_default = chdir
      path
    end

  end

  extend Helpers
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
test_construct-1.0.0 lib/test_construct/helpers.rb