Commit 4901ee9020df692ba9e34427fad4865c3474084e
Committed by
Paulo Meireles
1 parent
d773724a
Exists in
master
and in
29 other branches
[Mezuro] Refactored Compound Metric entity to model.
Showing
5 changed files
with
28 additions
and
33 deletions
Show diff stats
plugins/mezuro/lib/kalibro/entities/compound_metric.rb
plugins/mezuro/test/fixtures/compound_metric_fixtures.rb
1 | 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 | 5 | end |
11 | 6 | |
12 | - def self.sc_hash | |
7 | + def self.compound_metric_hash | |
13 | 8 | {:name => 'Structural Complexity', :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'} |
14 | 9 | end |
15 | 10 | ... | ... |
plugins/mezuro/test/unit/kalibro/compound_metric_test.rb
0 → 100644
... | ... | @@ -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 | -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 | 0 | \ No newline at end of file |