lib/lolcommits/test_helpers/git_repo.rb in lolcommits-0.12.1 vs lib/lolcommits/test_helpers/git_repo.rb in lolcommits-0.13.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Lolcommits module TestHelpers module GitRepo def repo @repo ||= Git.open(repo_path) @@ -17,10 +19,11 @@ repo.log.first end def setup_repo return if repo_exists? + `git init --quiet #{repo_path}` end def commit_repo_with_message(message = 'test message', file_name: 'test.txt', file_content: 'testing') setup_repo unless repo_exists? @@ -29,9 +32,10 @@ `cd #{repo_path} && git commit -m "#{message}"` end def in_repo return unless repo_exists? + Dir.chdir(File.expand_path(repo_path)) do yield end end