Commit 4901ee9020df692ba9e34427fad4865c3474084e

Authored by Diego Camarinha
Committed by Paulo Meireles
1 parent d773724a

[Mezuro] Refactored Compound Metric entity to model.

plugins/mezuro/lib/kalibro/compound_metric.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +class Kalibro::CompoundMetric < Kalibro::Metric
  2 +
  3 + attr_accessor :script
  4 +
  5 +end
plugins/mezuro/lib/kalibro/entities/compound_metric.rb
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -class Kalibro::Entities::CompoundMetric < Kalibro::Entities::Metric  
2 -  
3 - attr_accessor :script  
4 -  
5 -end  
6 \ No newline at end of file 0 \ No newline at end of file
plugins/mezuro/test/fixtures/compound_metric_fixtures.rb
1 class CompoundMetricFixtures 1 class CompoundMetricFixtures
2 2
3 - def self.sc  
4 - sc = Kalibro::Entities::CompoundMetric.new  
5 - sc.description = 'Calculate the Structural Complexity of the Code'  
6 - sc.name = 'Structural Complexity'  
7 - sc.scope = 'CLASS'  
8 - sc.script = 'return 42;'  
9 - sc 3 + def self.compound_metric
  4 + Kalibro::CompoundMetric.new compound_metric_hash
10 end 5 end
11 6
12 - def self.sc_hash 7 + def self.compound_metric_hash
13 {:name => 'Structural Complexity', :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'} 8 {:name => 'Structural Complexity', :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'}
14 end 9 end
15 10
plugins/mezuro/test/unit/kalibro/compound_metric_test.rb 0 → 100644
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
  1 +require "test_helper"
  2 +
  3 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/compound_metric_fixtures"
  4 +
  5 +class CompoundMetricTest < ActiveSupport::TestCase
  6 +
  7 + def setup
  8 + @hash = CompoundMetricFixtures.compound_metric_hash
  9 + @metric = CompoundMetricFixtures.compound_metric
  10 + end
  11 +
  12 + should 'create compound metric from hash' do
  13 + assert_equal @hash[:script], Kalibro::CompoundMetric.new(@hash).script
  14 + end
  15 +
  16 + should 'convert compound metric to hash' do
  17 + assert_equal @hash, @metric.to_hash
  18 + end
  19 +
  20 +end
plugins/mezuro/test/unit/kalibro/entities/compound_metric_test.rb
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -require "test_helper"  
2 -  
3 -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/compound_metric_fixtures"  
4 -  
5 -class CompoundMetricTest < ActiveSupport::TestCase  
6 -  
7 - def setup  
8 - @hash = CompoundMetricFixtures.sc_hash  
9 - @metric = CompoundMetricFixtures.sc  
10 - end  
11 -  
12 - should 'create compound metric from hash' do  
13 - assert_equal @metric, Kalibro::Entities::CompoundMetric.from_hash(@hash)  
14 - end  
15 -  
16 - should 'convert compound metric to hash' do  
17 - assert_equal @hash, @metric.to_hash  
18 - end  
19 -  
20 -end  
21 \ No newline at end of file 0 \ No newline at end of file