Sha256: 9c16285a93260b0330c0ce4554953d2aa6d4c6b1b6b98619c61339cc0e061232

Contents?: true

Size: 1.73 KB

Versions: 10

Compression:

Stored size: 1.73 KB

Contents

# -*- coding: utf-8 -*-

require 'spec_helper.rb'

module GitObjectBrowser::Models
  describe IndexTreeExtension do

    let(:input) { File.open(File.join(FIXTURES_DIR, 'git/indexes', infile)) }
    subject { Index.new(input) }
    after { input.close if input && ! input.closed? }

    context 'when tree extension exists' do
      let(:infile) { '001' }

      it 'should parse extension signature and length' do
        data = subject.parse.to_hash
        tree = data[:extensions][0]
        tree[:signature].should eq 'TREE'
        tree[:total_length].should eq 25
      end

      it 'should parse entries' do
        entries = subject.parse.to_hash[:extensions][0][:entries]
        entries.length.should eq 1
        entry = entries.first
        entry[:sha1].should eq 'c36491256978d26c08cd7aa97eee0f5631f96659'
        entry[:entry_count].should eq 2
        entry[:subtree_count].should eq 0
      end
    end

    context 'when extension includes no entries' do
      let(:infile) { '002-empty-tree-extension' }

      it 'should parse extension signature and length' do
        data = subject.parse.to_hash
        tree = data[:extensions][0]
        tree[:signature].should eq 'TREE'
        tree[:total_length].should eq 6
      end

      it 'should return -1 entry_count' do
        entries = subject.parse.to_hash[:extensions][0][:entries]
        entries.length.should eq 1
        entry = entries.first
        entry[:entry_count].should eq -1
        entry[:subtree_count].should eq 0
        entry[:path_component].should eq ''
        entry[:sha1].should be_nil
      end

      it 'return correct hash' do
        data = subject.parse.to_hash
        data[:sha1].should eq 'ad7408a5d4e6050d3b95c21d260ae568b24e4d19'
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
git-object-browser-0.1.3 spec/git-object-browser/models/index_tree_extension_spec.rb
git-object-browser-0.1.2 spec/git-object-browser/models/index_tree_extension_spec.rb
git-object-browser-0.1.1 spec/git-object-browser/models/index_tree_extension_spec.rb
git-object-browser-0.1.0 spec/git-object-browser/models/index_tree_extension_spec.rb
git-object-browser-0.0.9 spec/git-object-browser/models/index_tree_extension_spec.rb
git-object-browser-0.0.8 spec/git-object-browser/models/index_tree_extension_spec.rb
git-object-browser-0.0.7 spec/git-object-browser/models/index_tree_extension_spec.rb
git-object-browser-0.0.6 spec/git-object-browser/models/index_tree_extension_spec.rb
git-object-browser-0.0.4 spec/git-object-browser/models/index_tree_extension_spec.rb
git-object-browser-0.0.3 spec/git-object-browser/models/index_tree_extension_spec.rb