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