Sha256: e1a4f570a4d0836b0eb3b1cea658d3ca45b653cc86fdb19c1712373156c35246

Contents?: true

Size: 1.61 KB

Versions: 131

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require 'avm/git/commit'

RSpec.describe ::Avm::Git::Commit, git: true do
  let(:git) { stubbed_git_local_repo }

  let(:first_commit_sha1) do
    git.file('a.txt').write('AAA')
    git.file('b.txt').write('BBB')
    git.command('add', '.').execute!
    git.command('commit', '-m', 'First commit.').execute!
    git.rev_parse('HEAD')
  end

  let(:second_commit_sha1) do
    first_commit_sha1
    git.file('a.txt').write('AAAAA')
    git.file('b.txt').delete
    git.file('ç.txt').write('CCC')
    git.command('add', '.').execute!
    git.command('commit', '-m', 'Second commit.').execute!
    git.rev_parse('HEAD')
  end

  let(:first_commit) { described_class.new(git, first_commit_sha1) }
  let(:second_commit) { described_class.new(git, second_commit_sha1) }

  describe '#files' do
    it { expect(first_commit.files.count).to eq(2) }
    it { expect(second_commit.files.count).to eq(3) }

    {
      'first_commit' => %w[a.txt b.txt],
      'second_commit' => %w[a.txt b.txt ç.txt]
    }.each do |commit_name, filenames|
      filenames.each do |filename|
        it "find file \"#{filename}\" in commit \"#{commit_name}\"" do
          commit = send(commit_name)
          file = commit.files.find { |f| f.path == filename }
          expect(file).to be_a(::Avm::Git::Commit::File)
        end
      end
    end
  end

  describe '#files_size' do
    it { expect(first_commit.files_size).to eq(6) }
    it { expect(second_commit.files_size).to eq(8) }
  end

  describe '#root_child?' do
    it { expect(first_commit.root_child?).to eq(true) }
    it { expect(second_commit.root_child?).to eq(false) }
  end
end

Version data entries

131 entries across 131 versions & 2 rubygems

Version Path
eac_tools-0.45.1 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.45.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.44.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.43.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.42.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.41.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.40.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.39.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.38.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.37.2 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.37.1 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.37.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.36.1 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.36.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.35.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
avm-tools-0.129.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.16.0 sub/avm-tools/sub/avm-git/spec/lib/avm/git/commit_spec.rb
avm-tools-0.128.0 sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.15.0 sub/avm-tools/sub/avm-git/spec/lib/avm/git/commit_spec.rb
eac_tools-0.14.0 sub/avm-tools/sub/avm-git/spec/lib/avm/git/commit_spec.rb