spec/support/git_helpers.rb in git_presenter-0.4.0 vs spec/support/git_helpers.rb in git_presenter-1.0.0
- old
+ new
@@ -14,14 +14,14 @@
@code_file = "a_file.rb"
commits = []
content = ('a'..'z').to_a
Dir.mkdir(presentation_dir)
Dir.chdir(presentation_dir) do
- @git_repo = Grit::Repo.init(".")
+ @git_repo = Git.init(".")
(1..no_of_commits).each do |n|
- edit_file_and_commit("commit number #{n}", content[n])
- commits << @git_repo.commits[0]
+ commit = edit_file_and_commit("commit number #{n}", content[n])
+ commits << commit
#need to make it sleep for a second.
#git is not accurate enough with the speed of the test
#to sort correctly only when required
sleep 1 if delay
end
@@ -38,11 +38,11 @@
def edit_file_and_commit(commit_message, content)
edit_file(content)
@git_repo.add(".")
@git_repo.commit_all(commit_message)
- @git_repo.commits[0]
+ @git_repo.log.to_a[0]
end
def setup_presentation_file(commits)
File.open(".presentation", "w") do |file|
@commits.each do |commit|
@@ -54,11 +54,11 @@
def clean_up_repo(dir)
`rm -fr #{dir}`
end
def head_position
- File.open(@presentation_dir + '/.git/HEAD').lines.first.strip
+ File.open(@presentation_dir + '/.git/HEAD').each_line.first.strip
end
def initialise_presentation(params={})
settings = {:no_of_commits => 3, :delay => false}.merge(params)
commits = initialise_test_repo(@presentation_dir, settings[:delay], settings[:no_of_commits])
@@ -141,11 +141,11 @@
end
end
def current_branch
Dir.chdir(PRESENTATION_DIR) do
- repo = Grit::Repo.init('.')
- repo.head
+ repo = Git.open('.')
+ repo.current_branch
end
end
end