From b73ab20877e1b831f7c67bfb4bbca504e8a5b098 Mon Sep 17 00:00:00 2001 From: Carlos Morais Date: Thu, 9 Feb 2012 20:22:05 -0200 Subject: [PATCH] [Mezuro] MetricResultFixtures --- plugins/mezuro/test/fixtures/metric_result_fixtures.rb | 29 +++++++++++++++++++++++++++++ plugins/mezuro/test/unit/kalibro/entities/metric_result_test.rb | 33 ++++----------------------------- plugins/mezuro/test/unit/kalibro/entities/metric_test.rb | 1 + 3 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 plugins/mezuro/test/fixtures/metric_result_fixtures.rb diff --git a/plugins/mezuro/test/fixtures/metric_result_fixtures.rb b/plugins/mezuro/test/fixtures/metric_result_fixtures.rb new file mode 100644 index 0000000..0fedea5 --- /dev/null +++ b/plugins/mezuro/test/fixtures/metric_result_fixtures.rb @@ -0,0 +1,29 @@ +class MetricResultFixtures + + def self.amloc_result + result = Kalibro::Entities::MetricResult.new + result.metric = NativeMetricFixtures.amloc + result.value = 0.0 + result.descendent_results = [40.0, 42.0] + result.range = RangeFixtures.amloc_excellent + result + end + + def self.sc_result + result = Kalibro::Entities::MetricResult.new + result.metric = CompoundMetricFixtures.sc + result.value = 1.0 + result.descendent_results = [2.0, 42.0] + result + end + + def self.amloc_result_hash + {:metric => NativeMetricFixtures.amloc_hash, :value => 0.0, :descendent_result => [40.0, 42.0], + :range => RangeFixtures.amloc_excellent_hash} + end + + def self.sc_result_hash + {:metric => CompoundMetricFixtures.sc_hash, :value => 1.0, :descendent_result => [2.0, 42.0]} + end + +end diff --git a/plugins/mezuro/test/unit/kalibro/entities/metric_result_test.rb b/plugins/mezuro/test/unit/kalibro/entities/metric_result_test.rb index 59f9d44..6db1169 100644 --- a/plugins/mezuro/test/unit/kalibro/entities/metric_result_test.rb +++ b/plugins/mezuro/test/unit/kalibro/entities/metric_result_test.rb @@ -1,37 +1,12 @@ require "test_helper" -class MetricResultTest < ActiveSupport::TestCase - - def self.amloc_result - result = Kalibro::Entities::MetricResult.new - result.metric = NativeMetricTest.amloc - result.value = 0.0 - result.descendent_results = [40.0, 42.0] - result.range = RangeTest.amloc_excellent - result - end - - def self.sc_result - result = Kalibro::Entities::MetricResult.new - result.metric = CompoundMetricTest.sc - result.value = 1.0 - result.descendent_results = [2.0, 42.0] - result - end - def self.amloc_result_hash - {:metric => NativeMetricTest.amloc_hash, - :value => 0.0, :descendent_result => [40.0, 42.0], - :range => RangeTest.amloc_excellent_hash} - end +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_result_fixtures" - def self.sc_result_hash - {:metric => CompoundMetricTest.sc_hash, - :value => 1.0, :descendent_result => [2.0, 42.0]} - end +class MetricResultTest < ActiveSupport::TestCase def setup - @hash = self.class.amloc_result_hash - @result = self.class.amloc_result + @hash = MetricResultFixtures.amloc_result_hash + @result = MetricResultFixtures.amloc_result end should 'create metric result from hash' do diff --git a/plugins/mezuro/test/unit/kalibro/entities/metric_test.rb b/plugins/mezuro/test/unit/kalibro/entities/metric_test.rb index 5f05101..d088c69 100644 --- a/plugins/mezuro/test/unit/kalibro/entities/metric_test.rb +++ b/plugins/mezuro/test/unit/kalibro/entities/metric_test.rb @@ -1,4 +1,5 @@ require "test_helper" + class MetricTest < ActiveSupport::TestCase def setup -- libgit2 0.21.2