def assert_command_line_eq(expected_command_line, method: :command, mocked_output: '', include_env: false)
    actual_command_line = nil

    command_output = ''

    in_temp_dir do |path|
      git = Git.init('test_project')

      git.lib.define_singleton_method(method) do |*cmd, **opts, &block|
        if include_env
          actual_command_line = [env_overrides, *cmd, opts]
        else
          actual_command_line = [*cmd, opts]
        end
        mocked_output
      end

      Dir.chdir 'test_project' do
        yield(git) if block_given?
      end
    end

    expected_command_line = expected_command_line.call if expected_command_line.is_a?(Proc)

    assert_equal(expected_command_line, actual_command_line)

    command_output
  end
Assert that the expected command line is generated by a given Git::Base method

This assertion generates an empty git repository and then yields to the
given block passing the Git::Base instance for the empty repository. The
current directory is set to the root of the repository's working tree.


@example Test that calling `git.fetch` generates the command line `git fetch`
# Only need to specify the arguments to the git command
expected_command_line = ['fetch']
assert_command_line_eq(expected_command_line) { |git| git.fetch }

@example Test that calling `git.fetch('origin', { ref: 'master', depth: '2' })` generates the command line `git fetch --depth 2 -- origin master`
expected_command_line = ['fetch', '--depth', '2', '--', 'origin', 'master']
assert_command_line_eq(expected_command_line) { |git| git.fetch('origin', { ref: 'master', depth: '2' }) }

@param expected_command_line [Array<String>] The expected arguments to be sent to Git::Lib#command
@param git_output [String] The mocked output to be returned by the Git::Lib#command method

@yield [git] a block to call the method to be tested
@yieldparam git [Git::Base] The Git::Base object resulting from initializing the test project
@yieldreturn [void] the return value of the block is ignored

@return [void]