Sha256: cd015e8fbcd4309dbd2e245ffda63c92e69006dbf782d39f9178ea0796506da3

Contents?: true

Size: 1.91 KB

Versions: 13

Compression:

Stored size: 1.91 KB

Contents

# encoding: UTF-8

require 'spec_helper'

describe Gjp::Git do
  before(:each) do
    @git_path = File.expand_path(File.join("spec", "data", "test-repo"))
    Dir.mkdir(@git_path)

    @git = Gjp::Git.new(@git_path)
    @git.init
  end

  after(:each) do
    FileUtils.rm_rf(@git_path)
  end

  describe "#init"  do
    it "complains if a double initialization is attempted" do
      expect {
        @git.init
      }.to raise_error(Gjp::GitAlreadyInitedError)
    end
  end

  describe "#changed_files_since"  do
    it "lists files changed since a gjp tag" do
      Dir.chdir(@git_path) do
        File.open("file1", "w") do |file|
          file.write "test"
        end

        @git.commit_whole_directory("test", "test")

        File.open("file2", "w") do |file|
          file.write "test"
        end

        @git.commit_whole_directory("test end")

        files = @git.changed_files_since("test")

        files.should_not include("file1")
        files.should include("file2")
      end
    end
  end

  describe "#changed_files_between"  do
    it "lists files changed between gjp tags" do
      Dir.chdir(@git_path) do
        File.open("file1", "w") do |file|
          file.write "test"
        end

        @git.commit_whole_directory("test", "test_start")

        File.open("file2", "w") do |file|
          file.write "test"
        end
        Dir.mkdir("subdir")
        File.open(File.join("subdir","file3"), "w") do |file|
          file.write "test"
        end

        @git.commit_whole_directory("test", "test_end")

        File.open("file4", "w") do |file|
          file.write "test"
        end

        @git.commit_whole_directory("test")

        files = @git.changed_files_between("test_start", "test_end", "subdir")

        files.should_not include("file1")
        files.should_not include("file2")
        files.should include("subdir/file3")
        files.should_not include("file4")
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gjp-0.36.0 spec/lib/git_spec.rb
gjp-0.35.0 spec/lib/git_spec.rb
gjp-0.34.0 spec/lib/git_spec.rb
gjp-0.33.0 spec/lib/git_spec.rb
gjp-0.32.0 spec/lib/git_spec.rb
gjp-0.31.0 spec/lib/git_spec.rb
gjp-0.30.0 spec/lib/git_spec.rb
gjp-0.29.0 spec/lib/git_spec.rb
gjp-0.28.0 spec/lib/git_spec.rb
gjp-0.27.0 spec/lib/git_spec.rb
gjp-0.26.0 spec/lib/git_spec.rb
gjp-0.25.0 spec/lib/git_spec.rb
gjp-0.24.0 spec/lib/git_spec.rb