Sha256: 5656636e09ecb65b615eb7759730c1ea1d6d257cd52e6383b37d80e1176a78b1

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 Bytes

Contents

# encoding: utf-8
require 'spec_helper'

describe Git::File do
  let(:git_repo) { 'git_repo' }

  context '#initialize' do
    it 'expects a line' do
      line = ':000000 100644 0000000... a82b332... A  test.d/test333.txt'
      file = Git::File.new(line)
    end
  end

  context '#content' do
    it 'returns content of file in git repository' do
      git_init(git_repo)

      create_file(File.join(git_repo, 'file.txt'), 'content')
      git_add(git_repo, 'file.txt')
      git_commit(git_repo)

      commit = git_show(git_repo, nil).first.split(" ")[1]

      file = Git::File.new(git_diff_tree(git_repo, commit).last)

      Dir.chdir(::File.join(working_directory, git_repo)) do
        expect(file.content).to include('content')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git_hook-pre_receive-0.1.0 spec/file_spec.rb
git_hook-pre_receive-0.0.2 spec/file_spec.rb