Sha256: 4686c6f49461ac8e71235c2c2212e8e4c2ec930859549669c4f08c757df6bd2b

Contents?: true

Size: 935 Bytes

Versions: 18

Compression:

Stored size: 935 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'spec_helper'

describe GitStats::GitData::Blob do
  let(:repo) { double }
  let(:png_blob) { GitStats::GitData::Blob.new(filename: 'abc.png', sha: 'hash_png', repo: repo) }
  let(:txt_blob) { GitStats::GitData::Blob.new(filename: 'abc.txt', sha: 'hash_txt', repo: repo) }

  it 'should return 0 as lines count when files is binary' do
    png_blob.should_receive(:binary?).and_return true
    png_blob.lines_count.should == 0
  end

  it 'should return actual lines count when files is not binary' do
    txt_blob.should_receive(:binary?).and_return false
    repo.should_receive(:run).with("git cat-file blob hash_txt | wc -l").and_return 42
    txt_blob.lines_count.should == 42
  end

  it 'should invoke grep to check if file is binary' do
    repo.should_receive(:run).with("git cat-file blob hash_png | grep -m 1 '^'").and_return "Binary file matches"
    png_blob.should be_binary
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
git_stats-1.0.17 spec/git_data/blob_spec.rb
git_stats-1.0.16 spec/git_data/blob_spec.rb
git_stats-1.0.15 spec/git_data/blob_spec.rb
git_stats-1.0.14 spec/git_data/blob_spec.rb
git_stats-1.0.13 spec/git_data/blob_spec.rb
git_stats-1.0.12 spec/git_data/blob_spec.rb
git_stats-1.0.11 spec/git_data/blob_spec.rb
git_stats-1.0.10 spec/git_data/blob_spec.rb
git_stats-1.0.9 spec/git_data/blob_spec.rb
git_stats-1.0.8 spec/git_data/blob_spec.rb
git_stats-1.0.7 spec/git_data/blob_spec.rb
git_stats-1.0.6 spec/git_data/blob_spec.rb
git_stats-1.0.5 spec/git_data/blob_spec.rb
git_stats-1.0.4 spec/git_data/blob_spec.rb
git_stats-1.0.3 spec/git_data/blob_spec.rb
git_stats-1.0.2 spec/git_data/blob_spec.rb
git_stats-1.0.1 spec/git_data/blob_spec.rb
git_stats-1.0.0 spec/git_data/blob_spec.rb