-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating version number, more robust testing, spelling errors in read…
…me, dates on copyrighting
- Loading branch information
Showing
7 changed files
with
166 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
require 'bvm' | ||
|
||
describe "BVM" do | ||
|
||
describe Converter do | ||
|
||
before(:each) do | ||
@input = File.read('spec/multiple.xml') | ||
@converter = Converter.new | ||
end | ||
|
||
it "converts XML to CSV for given metrics" do | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,0.8,\"jar\",\"package\",\"Class\"\n200.0,0.6,\"jar\",\"other.package\",\"OtherClass\"\n300.0,0.2,\"jar\",\"other.package\",\"ThirdClass\"\n/ | ||
end | ||
|
||
it "changes the jar in the output when specified" do | ||
@converter.jar = 'foo' | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,0.8,\"foo\",\"package\",\"Class\"\n200.0,0.6,\"foo\",\"other.package\",\"OtherClass\"\n300.0,0.2,\"foo\",\"other.package\",\"ThirdClass\"\n/ | ||
end | ||
|
||
it "changes the size metric in the output when specified" do | ||
@converter.size_metric = 'coverage' | ||
output = @converter.convert @input | ||
output.should == %Q/0.8,0.8,\"jar\",\"package\",\"Class\"\n0.6,0.6,\"jar\",\"other.package\",\"OtherClass\"\n0.2,0.2,\"jar\",\"other.package\",\"ThirdClass\"\n/ | ||
end | ||
|
||
it "changes the color metric in the output when specified" do | ||
@converter.color_metric = 'ncloc' | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,100.0,\"jar\",\"package\",\"Class\"\n200.0,200.0,\"jar\",\"other.package\",\"OtherClass\"\n300.0,300.0,\"jar\",\"other.package\",\"ThirdClass\"\n/ | ||
end | ||
|
||
it "adjusts the color metric based on color adjustment" do | ||
@converter.color_adjustment = -2.0 | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,-1.2,"jar","package","Class"\n200.0,-1.4,"jar","other.package","OtherClass"\n300.0,-1.8,"jar","other.package","ThirdClass"\n/ | ||
end | ||
|
||
it 'inverts and adjusts by inverting first' do | ||
@converter.color_adjustment = 2.0 | ||
@converter.invert_color_metric = true; | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,1.2,"jar","package","Class"\n200.0,1.4,"jar","other.package","OtherClass"\n300.0,1.8,"jar","other.package","ThirdClass"\n/ | ||
end | ||
|
||
it "inverts the color metric" do | ||
@converter.invert_color_metric = true; | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,-0.8,"jar","package","Class"\n200.0,-0.6,"jar","other.package","OtherClass"\n300.0,-0.2,"jar","other.package","ThirdClass"\n/ | ||
end | ||
|
||
it 'returns 0 for not found metrics' do | ||
@converter.size_metric = 'foo' | ||
@converter.color_metric = 'bar' | ||
output = @converter.convert @input | ||
output.should == %Q/0.0,0.0,"jar","package","Class"\n0.0,0.0,"jar","other.package","OtherClass"\n0.0,0.0,"jar","other.package","ThirdClass"\n/ | ||
end | ||
|
||
it 'converts input with multiple lines' do | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,0.8,"jar","package","Class"\n200.0,0.6,"jar","other.package","OtherClass"\n300.0,0.2,"jar","other.package","ThirdClass"\n/ | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
require 'bvm' | ||
|
||
describe "BVM" do | ||
|
||
describe Converter do | ||
|
||
before(:each) do | ||
@input = File.read('spec/single.xml') | ||
@converter = Converter.new | ||
end | ||
|
||
it "defaults parameters correctly" do | ||
@converter.jar.should == 'jar' | ||
@converter.size_metric.should == 'ncloc' | ||
@converter.color_metric.should == 'coverage' | ||
@converter.color_adjustment.should == 0.0 | ||
@converter.invert_color_metric.should == false | ||
end | ||
|
||
it "converts XML to CSV for given metrics" do | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,0.8,"jar","package","Class"\n/ | ||
end | ||
|
||
it "changes the jar in the output when specified" do | ||
@converter.jar = 'foo' | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,0.8,"foo","package","Class"\n/ | ||
end | ||
|
||
it "changes the size metric in the output when specified" do | ||
@converter.size_metric = 'coverage' | ||
output = @converter.convert @input | ||
output.should == %Q/0.8,0.8,"jar","package","Class"\n/ | ||
end | ||
|
||
it "changes the color metric in the output when specified" do | ||
@converter.color_metric = 'ncloc' | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,100.0,"jar","package","Class"\n/ | ||
end | ||
|
||
it "adjusts the color metric based on color adjustment" do | ||
@converter.color_adjustment = -0.8 | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,0.0,"jar","package","Class"\n/ | ||
end | ||
|
||
it "inverts the color metric" do | ||
@converter.invert_color_metric = true; | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,-0.8,"jar","package","Class"\n/ | ||
end | ||
|
||
it 'inverts and adjusts by inverting first' do | ||
@converter.color_adjustment = 0.4 | ||
@converter.invert_color_metric = true; | ||
output = @converter.convert @input | ||
output.should == %Q/100.0,-0.4,"jar","package","Class"\n/ | ||
end | ||
|
||
it 'returns 0 for not found metrics' do | ||
@converter.size_metric = 'foo' | ||
@converter.color_metric = 'bar' | ||
output = @converter.convert @input | ||
output.should == %Q/0.0,0.0,"jar","package","Class"\n/ | ||
end | ||
|
||
end | ||
|
||
end |