require 'fedux_org/stdlib/filesystem' module LocalPac 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.init(path) end ::File.join(working_directory, path) end def git_add(repo, object) Dir.chdir(::File.join(working_directory, repo)) do Git.add(object) end ::File.join(working_directory, repo, object) end def git_status(repo) Dir.chdir(::File.join(working_directory, repo)) do Git.status end end def git_commit(repo, message = 'Yay... Added objects') Dir.chdir(::File.join(working_directory, repo)) do Git.commit(message) end end def git_show(repo, sha) Dir.chdir(::File.join(working_directory, repo)) do Git.show(sha) end end def git_ls_tree(repo) Dir.chdir(::File.join(working_directory, repo)) do Git.ls_tree end end def git_config(repo, option, value, is_global = false) if is_global Git.config(option, value, is_global) else Dir.chdir(::File.join(working_directory, repo)) do Git.config(option, value, is_global) end end end def git_set_author(repo) git_config(repo, 'user.email', 'user@local_pac') git_config(repo, 'user.name', 'local_pac') end end end end # encoding: utf-8 RSpec.configure do |c| c.include LocalPac::SpecHelper::GitHelper end