Commit 71dc709e95a9e9f283ee641aab3d42848920b97a
Committed by
João M. M. da Silva
1 parent
494ceb0c
Exists in
master
and in
28 other branches
[Mezuro] Completed metric configuration snapshot model and tests creation.
Showing
3 changed files
with
63 additions
and
0 deletions
Show diff stats
plugins/mezuro/lib/kalibro/metric_configuration_snapshot.rb
0 → 100644
... | ... | @@ -0,0 +1,17 @@ |
1 | +class Kalibro::MetricConfigurationSnapshot < Kalibro::Model | |
2 | + | |
3 | + attr_accessor :code, :weight, :aggregation_form, :metric, :base_tool_name, :range | |
4 | + | |
5 | + def metric=(value) | |
6 | + if value.kind_of?(Hash) | |
7 | + @metric = Kalibro::Metric.to_object(value) | |
8 | + else | |
9 | + @metric = value | |
10 | + end | |
11 | + end | |
12 | + | |
13 | + def range=(value) | |
14 | + @range = Kalibro::Range.to_object value | |
15 | + end | |
16 | + | |
17 | +end | ... | ... |
plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +require File.dirname(__FILE__) + '/metric_fixtures' | |
2 | +require File.dirname(__FILE__) + '/range_snapshot_fixtures' | |
3 | + | |
4 | +class MetricConfigurationSnapshotFixtures | |
5 | + | |
6 | + def self.metric_configuration_snapshot | |
7 | + Kalibro::MetricConfigurationSnapshot.new metric_configuration_snapshot_hash | |
8 | + end | |
9 | + | |
10 | + def self.metric_configuration_snapshot_hash | |
11 | + { | |
12 | + :code => "code", | |
13 | + :weight => 1, | |
14 | + :aggregation_form => 'AVERAGE', | |
15 | + :metric => MetricFixtures.amloc_hash, | |
16 | + :base_tool_name => "Analizo", | |
17 | + :range => [RangeSnapshotFixtures.range_snapshot_hash], | |
18 | + :attributes! => { | |
19 | + :metric => { | |
20 | + 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | |
21 | + 'xsi:type' => 'kalibro:metricXml' } | |
22 | + } | |
23 | + } | |
24 | + end | |
25 | + | |
26 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/metric_configuration_snapshot_test.rb
0 → 100644
... | ... | @@ -0,0 +1,20 @@ |
1 | +require "test_helper" | |
2 | + | |
3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures" | |
4 | + | |
5 | +class MetricConfigurationSnapshotTest < ActiveSupport::TestCase | |
6 | + | |
7 | + def setup | |
8 | + @hash = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash | |
9 | + @metric_configuration_snapshot = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot | |
10 | + end | |
11 | + | |
12 | + should 'create metric configuration snapshot from hash' do | |
13 | + assert_equal @hash[:code], Kalibro::MetricConfigurationSnapshot.new(@hash).code | |
14 | + end | |
15 | + | |
16 | + should 'convert metric configuration snapshot to hash' do | |
17 | + assert_equal @hash, @metric_configuration_snapshot.to_hash | |
18 | + end | |
19 | + | |
20 | +end | ... | ... |