Sha256: b90f3bc09e7bb6fb0feb5e865127eeeb0fdb846351bf99b01e3de686f59bb003

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

require 'tmpdir'
require 'fileutils'
require 'securerandom'

module GitRepository
  extend RSpec::SharedContext

  let(:repo) { @repo }
  before { create_sample_repo }
  after { remove_sample_repo }

  def create_sample_repo
    @previous_dir = Dir.pwd
    @repo = Dir.mktmpdir 'git_shizzle'
    Dir.chdir(@repo)
    `git init`
    `git config user.name somebody`
    `git config user.email somebody@example.com`
  end

  def create(file)
    FileUtils.touch file
    modify(file)
  end

  def modify(file)
    File.write file, ::SecureRandom.uuid
  end

  def move(src, dst)
    FileUtils.mv src, dst
  end

  def delete(file)
    FileUtils.rm file
  end

  def stage(file = nil)
    `git add --all #{file}`
  end

  def remove_sample_repo
    Dir.chdir(@previous_dir)
    FileUtils.rm_rf @repo
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_shizzle-0.2.8 spec/helpers/git_repository.rb