Sha256: c96287b2ffb7d064afc0c72e8dc2ae2597915e8be7c3c97ee6ca87612435905e

Contents?: true

Size: 1.62 KB

Versions: 15

Compression:

Stored size: 1.62 KB

Contents

require "#{File.dirname(__FILE__)}/../lib/gitrb"
require 'pp'

describe Gitrb::Commit do

  REPO = '/tmp/gitrb_test'

  attr_reader :repo

  before(:each) do
    FileUtils.rm_rf REPO
    Dir.mkdir REPO

    @repo = Gitrb::Repository.new(:path => REPO, :create => true)
  end

  it "should dump in right format" do
    user = Gitrb::User.new("hanni", "hanni@email.de", Time.now)

    commit = Gitrb::Commit.new
    commit.tree = @repo.root
    commit.author = user
    commit.committer = user
    commit.message = "This is a message"

    content = commit.dump

    content.should == "tree #{@repo.root.id}
author #{user.dump}
committer #{user.dump}

This is a message"
  end

  it "should be readable by git binary" do
    time = Time.local(2009, 4, 20)
    author = Gitrb::User.new("hans", "hans@email.de", time)

    repo.root['a'] = Gitrb::Blob.new(:data => "Yay")
    commit = repo.commit("Commit Message", author, author)

    IO.popen("git log") do |io|
      io.gets.should == "commit #{commit.id}\n"
      io.gets.should == "Author: hans <hans@email.de>\n"
      io.gets.should == "Date:   Mon Apr 20 00:00:00 2009 #{Time.now.strftime('%z')}\n"
      io.gets.should == "\n"
      io.gets.should == "    Commit Message\n"
    end
  end

  it "should diff 2 commits" do
    repo.root['x'] = Gitrb::Blob.new(:data => 'a')
    repo.root['y'] = Gitrb::Blob.new(:data => "
First Line.
Second Line.
Last Line.
")
    a = repo.commit

    repo.root.delete('x')
    repo.root['y'] = Gitrb::Blob.new(:data => "
First Line.
Last Line.
Another Line.
")
    repo.root['z'] = Gitrb::Blob.new(:data => 'c')

    b = repo.commit

    diff = repo.diff(a, b)
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gitrb-0.1.5 test/commit_spec.rb
gitrb-0.1.4 test/commit_spec.rb
gitrb-0.1.3 test/commit_spec.rb
gitrb-0.1.2 test/commit_spec.rb
gitrb-0.1.1 test/commit_spec.rb
gitrb-0.1.0 test/commit_spec.rb
gitrb-0.0.9 test/commit_spec.rb
gitrb-0.0.8 test/commit_spec.rb
gitrb-0.0.7 test/commit_spec.rb
gitrb-0.0.6 test/commit_spec.rb
gitrb-0.0.5 test/commit_spec.rb
gitrb-0.0.4 test/commit_spec.rb
gitrb-0.0.3 test/commit_spec.rb
gitrb-0.0.2 test/commit_spec.rb
gitrb-0.0.1 test/commit_spec.rb