Sha256: 640931375bb2a7ef892212349db1e68a576d0b4b034f6e1fb999982994e77f8a
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
require 'spec_helper' describe "community (executable)" do let(:filename) { File.dirname(__FILE__) + "/../data/karate.bin" } context "outputs a hierarchy", :retry => 2 do it "works when no level given" do run "community #{filename}" relevant_lines = out.split("\n").last(4) 3.times do |i| relevant_lines[i].should == "#{i+1} #{i+1}" end relevant_lines[3].to_f.round(2).should == 0.43 end it "works when level given is -1" do run "community -l -1 #{filename}" relevant_lines = out.split("\n").last(4) 3.times do |i| relevant_lines[i].should == "#{i+1} #{i+1}" end relevant_lines[3].to_f.round(2).should == 0.43 end it "can provide verbose output", :retry => 2 do run "community #{filename} -v" output = out 3.times do |i| output.should match /^level #{i}:\n start computation [0-9\-: ]+\n network size: \d+ nodes, \d+ links, \d+ weight.$(\n\d+ \d+){4,}\n modularity increased from (-)?\d+\.\d+ to \d+\.\d+\n end computation [0-9\-: ]+$/ end lines = output.split("\n") lines.first.should match /^Begin: [0-9\-: ]+$/ lines[lines.length-3].should match /^End: [0-9\-: ]+$/ lines[lines.length-2].should match /^Total duration: \d+\.\d+ sec\.$/ lines.last.to_f.round(2).should == 0.43 end end it "outputs level 2 in the hierchy", :retry => 2 do run "community -l 2 #{filename}" lines = out.split("\n") lines.length.should > 5 lines[0..lines.length-2].each_with_index do |l, i| l.should match /\A#{i}:( \(\d+ \d+\)){3,}\z/ end lines.last.to_f.round(2).should == 0.43 end it "outputs level 3 in the hierchy", :retry => 2 do run "community #{filename} -l 3" lines = out.split("\n") lines.length.should == 5 lines[0..lines.length-2].each_with_index do |l, i| l.should match /\A#{i}:( \(\d+ \d+\)){2,}\z/ end lines.last.to_f.round(2).should == 0.43 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
find_communities-0.0.3 | spec/bin/community_spec.rb |