Sha256: 60d897f86fc1404da2b03a14bca4a04c21a9c93e17439af168905800c64a7ec9

Contents?: true

Size: 1013 Bytes

Versions: 1

Compression:

Stored size: 1013 Bytes

Contents

require 'simple_shell'
require 'tmpdir'

module MockProject
  def fake_me_a_heidi
    this_repo = Dir.pwd rescue ENV['PWD']

    # create a heidi dir with the bare minimum
    @fake = Dir.mktmpdir(nil, '/tmp')

    shell = SimpleShell.new(@fake)
    shell.mkdir "-p", "projects/heidi_test"
    shell.in "projects/heidi_test" do |sh|
      sh.git %W(clone #{this_repo} cached)
      sh.mkdir "logs"
      %w(build tests failure success before).each do |hook|
        sh.mkdir %W(-p hooks/#{hook})
      end
    end

    spec = File.join(@fake, "projects/heidi_test/hooks/tests", "01_rspec")

    # this test hook touches a file so we can test if it did touch a file :-)
    File.open(spec, File::CREAT|File::WRONLY) do |f|
      f.puts %Q(#!/bin/sh

touch #{@fake}/#{File.basename(@fake)})
    end

    shell.chmod %W(+x #{spec})

    @heidi = Heidi.new(@fake)
  rescue Exception => ex
    $stderr.puts "Faking heidi failed... #{ex.message}"
    $stderr.puts ex.backtrace.join("\n")
  end
end

RWorld(MockProject)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heidi-0.4.0 spec/support/mock_project.rb