Commit a00d04a1eb5fe07b195463f37e4b9e99b87ea158
1 parent
340aa60f
Exists in
master
and in
28 other branches
[Mezuro] ModuleResultFixtures
Showing
2 changed files
with
27 additions
and
23 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | +class ModuleResultFixtures | |
| 2 | + | |
| 3 | + def self.create | |
| 4 | + fixture = Kalibro::Entities::ModuleResult.new | |
| 5 | + fixture.module = ModuleFixtures.qt_calculator | |
| 6 | + fixture.date = DateTime.parse('Thu, 20 Oct 2011 18:26:43.151 +0000') | |
| 7 | + fixture.grade = 10.0 | |
| 8 | + fixture.metric_results = [ | |
| 9 | + MetricResultFixtures.amloc_result, | |
| 10 | + MetricResultFixtures.sc_result] | |
| 11 | + fixture.compound_metrics_with_error = [CompoundMetricWithErrorFixtures.create] | |
| 12 | + fixture | |
| 13 | + end | |
| 14 | + | |
| 15 | + def self.create_hash | |
| 16 | + {:module => ModuleFixtures.qt_calculator_hash, | |
| 17 | + :date => DateTime.parse('Thu, 20 Oct 2011 18:26:43.151 +0000'), :grade => 10.0, :metric_result => [ | |
| 18 | + MetricResultFixtures.amloc_result_hash, | |
| 19 | + MetricResultFixtures.sc_result_hash], | |
| 20 | + :compound_metric_with_error => [CompoundMetricWithErrorFixtures.create_hash]} | |
| 21 | + end | |
| 22 | + | |
| 23 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/module_result_test.rb
| 1 | 1 | require "test_helper" |
| 2 | 2 | |
| 3 | -class ModuleResultTest < ActiveSupport::TestCase | |
| 4 | - | |
| 5 | - def self.fixture | |
| 6 | - amloc_result = MetricResultTest.amloc_result | |
| 7 | - sc_result = MetricResultTest.sc_result | |
| 8 | - fixture = Kalibro::Entities::ModuleResult.new | |
| 9 | - fixture.module = ModuleTest.qt_calculator | |
| 10 | - fixture.date = DateTime.parse('Thu, 20 Oct 2011 18:26:43.151 +0000') | |
| 11 | - fixture.grade = 10.0 | |
| 12 | - fixture.metric_results = [amloc_result, sc_result] | |
| 13 | - fixture.compound_metrics_with_error = [CompoundMetricWithErrorTest.fixture] | |
| 14 | - fixture | |
| 15 | - end | |
| 3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" | |
| 16 | 4 | |
| 17 | - def self.fixture_hash | |
| 18 | - amloc_result = MetricResultTest.amloc_result_hash | |
| 19 | - sc_result = MetricResultTest.sc_result_hash | |
| 20 | - {:module => ModuleTest.qt_calculator_hash, | |
| 21 | - :date => DateTime.parse('Thu, 20 Oct 2011 18:26:43.151 +0000'), | |
| 22 | - :grade => 10.0, :metric_result => [amloc_result, sc_result], | |
| 23 | - :compound_metric_with_error => [CompoundMetricWithErrorTest.fixture_hash]} | |
| 24 | - end | |
| 5 | +class ModuleResultTest < ActiveSupport::TestCase | |
| 25 | 6 | |
| 26 | 7 | def setup |
| 27 | - @hash = self.class.fixture_hash | |
| 28 | - @result = self.class.fixture | |
| 8 | + @hash = ModuleResultFixtures.create_hash | |
| 9 | + @result = ModuleResultFixtures.create | |
| 29 | 10 | end |
| 30 | 11 | |
| 31 | 12 | should 'create module result from hash' do | ... | ... |