From 39b9ebc78f292e2cd34575d460eb624fa52b7073 Mon Sep 17 00:00:00 2001 From: Carlos Morais Date: Thu, 9 Feb 2012 20:12:42 -0200 Subject: [PATCH] MetricConfigurationFixtures --- plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb | 32 ++++++++++++++++++++++++++++++++ plugins/mezuro/test/unit/kalibro/entities/metric_configuration_test.rb | 39 ++++----------------------------------- 2 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb diff --git a/plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb b/plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb new file mode 100644 index 0000000..3e4352a --- /dev/null +++ b/plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb @@ -0,0 +1,32 @@ +class MetricConfigurationFixtures + + def self.amloc_configuration + amloc = Kalibro::Entities::MetricConfiguration.new + amloc.metric = NativeMetricFixtures.amloc + amloc.code = 'amloc' + amloc.weight = 1.0 + amloc.aggregation_form = 'AVERAGE' + amloc.ranges = [RangeFixtures.amloc_excellent, RangeFixtures.amloc_bad] + amloc + end + + def self.sc_configuration + sc = Kalibro::Entities::MetricConfiguration.new + sc.metric = CompoundMetricFixtures.sc + sc.code = 'sc' + sc.weight = 1.0 + sc.aggregation_form = 'AVERAGE' + sc + end + + def self.amloc_configuration_hash + {:metric => NativeMetricFixtures.amloc_hash, :code => 'amloc', :weight => 1.0, + :aggregation_form => 'AVERAGE', :range => + [RangeFixtures.amloc_excellent_hash, RangeFixtures.amloc_bad_hash]} + end + + def self.sc_configuration_hash + {:metric => CompoundMetricFixtures.sc_hash, :code => 'sc', :weight => 1.0, :aggregation_form => 'AVERAGE'} + end + +end diff --git a/plugins/mezuro/test/unit/kalibro/entities/metric_configuration_test.rb b/plugins/mezuro/test/unit/kalibro/entities/metric_configuration_test.rb index c990672..da00940 100644 --- a/plugins/mezuro/test/unit/kalibro/entities/metric_configuration_test.rb +++ b/plugins/mezuro/test/unit/kalibro/entities/metric_configuration_test.rb @@ -1,43 +1,12 @@ require "test_helper" -class MetricConfigurationTest < ActiveSupport::TestCase - - def self.amloc_configuration - range1 = RangeTest.amloc_excellent - range2 = RangeTest.amloc_bad - amloc = Kalibro::Entities::MetricConfiguration.new - amloc.metric = NativeMetricTest.amloc - amloc.code = 'amloc' - amloc.weight = 1.0 - amloc.aggregation_form = 'AVERAGE' - amloc.ranges = [range1, range2] - amloc - end - - def self.sc_configuration - sc = Kalibro::Entities::MetricConfiguration.new - sc.metric = CompoundMetricTest.sc - sc.code = 'sc' - sc.weight = 1.0 - sc.aggregation_form = 'AVERAGE' - sc - end - def self.amloc_configuration_hash - range1 = RangeTest.amloc_excellent_hash - range2 = RangeTest.amloc_bad_hash - {:metric => NativeMetricTest.amloc_hash, - :code => 'amloc', :weight => 1.0, :aggregation_form => 'AVERAGE', - :range => [range1, range2]} - end +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" - def self.sc_configuration_hash - {:metric => CompoundMetricTest.sc_hash, - :code => 'sc', :weight => 1.0, :aggregation_form => 'AVERAGE'} - end +class MetricConfigurationTest < ActiveSupport::TestCase def setup - @hash = self.class.amloc_configuration_hash - @range = self.class.amloc_configuration + @hash = MetricConfigurationFixtures.amloc_configuration_hash + @range = MetricConfigurationFixtures.amloc_configuration end should 'create metric configuration from hash' do -- libgit2 0.21.2