Sha256: 15695d1314cdf53352b637ac6229e91f2dd62b5363a043de3a8debd709722a8b

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

require 'spec_helper'

RSpec.describe CLOC do
  describe ".language_counts" do
    it "returns an empty array when there is no code" do
      csv = CSV.parse("", headers: true)
      expect(CLOC.new(csv).language_counts).to eq []
    end

    it "returns an array of language count objects" do
      csv = CSV.parse(CLOC_CSV_OUTPUT.lstrip, headers: true)
      cloc = CLOC.new(csv)
      expect(cloc.language_counts[2].language).to eq "Ruby"
      expect(cloc.language_counts[2].sloc).to eq 1119
      expect(cloc.language_counts[2].file_count).to eq 30
    end
  end

  # Output starts with a newline
  CLOC_CSV_OUTPUT = <<-EOS

    files,language,blank,comment,code,"http://cloc.sourceforge.net v 1.62  T=0.34 s (106.4 files/s, 28129.6 lines/s)"
    1,HTML,2070,0,2734
    1,Javascript,220,173,1166
    30,Ruby,303,154,1119
    2,JSON,0,0,758
    1,CSS,80,70,649
    1,YAML,7,0,17
  EOS
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pluginscan-0.9.0 spec/pluginscan/cloc_scanner/cloc_spec.rb