Sha256: 86a383169b3396325c374779c81d5d8a9bb11a4d897a2928f7dd3961d364a890

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'fedux_org/stdlib/filesystem'

module Git
  module SpecHelper
    module GitHelper
      include FeduxOrg::Stdlib::Filesystem

      def root_directory
        ::File.expand_path('../../../', __FILE__)
      end

      def git_init(path)
        switch_to_working_directory do
          Git::Command.init(path)
        end
      end

      def git_add(repo, object)
        Dir.chdir(::File.join(working_directory, repo)) do
          Git::Command.add(object)
        end
      end

      def git_commit(repo, message = 'Yay... Added objects')
        Dir.chdir(::File.join(working_directory, repo)) do
          Git::Command.commit(message)
        end
      end

      def git_status(repo)
        Dir.chdir(::File.join(working_directory, repo)) do
          Git::Command.status
        end
      end

      def git_show(repo, sha)
        Dir.chdir(::File.join(working_directory, repo)) do
          Git::Command.show(sha)
        end
      end

      def git_diff_tree(repo, new)
        Dir.chdir(::File.join(working_directory, repo)) do
          Git::Command.diff_tree(new)
        end
      end
    end
  end
end

# encoding: utf-8
RSpec.configure do |c|
  c.include Git::SpecHelper::GitHelper
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_hook-pre_receive-0.0.2 spec/support/git.rb