Commit 6d19fa16311ccdda4b107b74301449be4163eb3a
1 parent
8bf9a57a
Exists in
colab
and in
4 other branches
Rename metric_result => tree_metric_result on spec
* Also created date_metric_result factory and started using it on the metric history unit test Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
5 changed files
with
25 additions
and
14 deletions
Show diff stats
spec/controllers/modules_controller_spec.rb
... | ... | @@ -16,7 +16,7 @@ describe ModulesController, :type => :controller do |
16 | 16 | let (:module_id){ 1 } |
17 | 17 | let (:metric_name ){ FactoryGirl.build(:loc).name } |
18 | 18 | let (:date ){ DateTime.parse("2011-10-20T18:26:43.151+00:00") } |
19 | - let (:metric_result){ FactoryGirl.build(:metric_result) } | |
19 | + let (:tree_metric_result){ FactoryGirl.build(:tree_metric_result) } | |
20 | 20 | let! (:module_result){ FactoryGirl.build(:module_result) } |
21 | 21 | |
22 | 22 | before :each do |
... | ... | @@ -29,4 +29,4 @@ describe ModulesController, :type => :controller do |
29 | 29 | it { is_expected.to respond_with(:success) } |
30 | 30 | it { is_expected.to render_template(:metric_history) } |
31 | 31 | end |
32 | -end | |
33 | 32 | \ No newline at end of file |
33 | +end | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +FactoryGirl.define do | |
2 | + factory :date_metric_result, class: KalibroClient::Entities::Miscellaneous::DateMetricResult do | |
3 | + date '2011-10-20T18:26:43.151+00:00' | |
4 | + | |
5 | + # FIXME: A DateMetricResult should be able to create either a TreeMetricResult or a HotspotMetricResult based on | |
6 | + # the arguments passed to it | |
7 | + metric_result_attributes { FactoryGirl.attributes_for(:tree_metric_result).except(:aggregated_value) } | |
8 | + | |
9 | + initialize_with { new('date' => date, 'metric_result' => metric_result_attributes) } | |
10 | + end | |
11 | +end | ... | ... |
spec/factories/tree_metric_results.rb
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 | FactoryGirl.define do |
18 | - factory :metric_result, class: KalibroClient::Entities::Processor::TreeMetricResult do | |
18 | + factory :tree_metric_result, class: KalibroClient::Entities::Processor::TreeMetricResult do | |
19 | 19 | id "42" |
20 | 20 | metric_configuration { FactoryGirl.build(:metric_configuration_with_id) } |
21 | 21 | value "10.0" | ... | ... |
spec/helpers/processings_helper_spec.rb
... | ... | @@ -19,10 +19,10 @@ describe ProcessingsHelper, :type => :helper do |
19 | 19 | |
20 | 20 | describe 'find_range_snapshot' do |
21 | 21 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id)} |
22 | - let(:metric_result) { FactoryGirl.build(:metric_result, {value: 6.0, metric_configuration: metric_configuration})} | |
22 | + let(:tree_metric_result) { FactoryGirl.build(:tree_metric_result, {value: 6.0, metric_configuration: metric_configuration})} | |
23 | 23 | |
24 | 24 | before :each do |
25 | - metric_result.expects(:metric_configuration).returns(metric_configuration) | |
25 | + tree_metric_result.expects(:metric_configuration).returns(metric_configuration) | |
26 | 26 | metric_configuration.expects(:kalibro_ranges).returns(range_snapshots) |
27 | 27 | end |
28 | 28 | |
... | ... | @@ -30,7 +30,7 @@ describe ProcessingsHelper, :type => :helper do |
30 | 30 | let!(:range_snapshots) { [make_range(1.0, 5.0), make_range(5.1, 10.0), make_range(10.1, 15.0)] } |
31 | 31 | |
32 | 32 | it 'should return the range snapshot which contains the value' do |
33 | - expect(helper.find_range_snapshot(metric_result)).to eq(range_snapshots[1]) | |
33 | + expect(helper.find_range_snapshot(tree_metric_result)).to eq(range_snapshots[1]) | |
34 | 34 | end |
35 | 35 | end |
36 | 36 | |
... | ... | @@ -38,7 +38,7 @@ describe ProcessingsHelper, :type => :helper do |
38 | 38 | let!(:range_snapshots) { [make_range('-INF', 0.0), make_range(0, 'INF')] } |
39 | 39 | |
40 | 40 | it 'should return the range snapshot which contains the value' do |
41 | - expect(helper.find_range_snapshot(metric_result)).to eq(range_snapshots[1]) | |
41 | + expect(helper.find_range_snapshot(tree_metric_result)).to eq(range_snapshots[1]) | |
42 | 42 | end |
43 | 43 | end |
44 | 44 | |
... | ... | @@ -46,7 +46,7 @@ describe ProcessingsHelper, :type => :helper do |
46 | 46 | let!(:range_snapshots) { [make_range('-INF', 'INF')] } |
47 | 47 | |
48 | 48 | it 'should return the range snapshot which contains the value' do |
49 | - expect(helper.find_range_snapshot(metric_result)).to eq(range_snapshots[0]) | |
49 | + expect(helper.find_range_snapshot(tree_metric_result)).to eq(range_snapshots[0]) | |
50 | 50 | end |
51 | 51 | end |
52 | 52 | |
... | ... | @@ -54,7 +54,7 @@ describe ProcessingsHelper, :type => :helper do |
54 | 54 | let!(:range_snapshots) { [make_range('-INF', 6.0), make_range(6.1, 'INF')] } |
55 | 55 | |
56 | 56 | it 'should return nil' do |
57 | - expect(helper.find_range_snapshot(metric_result)).to be_nil | |
57 | + expect(helper.find_range_snapshot(tree_metric_result)).to be_nil | |
58 | 58 | end |
59 | 59 | end |
60 | 60 | ... | ... |
spec/models/module_result_spec.rb
... | ... | @@ -5,19 +5,19 @@ describe ModuleResult, :type => :model do |
5 | 5 | subject { FactoryGirl.build(:module_result) } |
6 | 6 | |
7 | 7 | describe 'metric_history' do |
8 | - let(:date_module_result) {FactoryGirl.build(:date_module_result)} | |
8 | + let(:date_metric_result) {FactoryGirl.build(:date_metric_result)} | |
9 | 9 | let(:metric_configuration) { FactoryGirl.build(:another_metric_configuration_with_id) } |
10 | - let!(:metric_result) { FactoryGirl.build(:metric_result, metric_configuration: metric_configuration) } | |
10 | + let!(:tree_metric_result) { FactoryGirl.build(:tree_metric_result, metric_configuration: metric_configuration) } | |
11 | 11 | let(:processing) {FactoryGirl.build(:processing)} |
12 | 12 | |
13 | 13 | before :each do |
14 | 14 | subject.expects(:processing).returns(processing) |
15 | - date_module_result.expects(:metric_result).returns(metric_result) | |
16 | - KalibroClient::Entities::Processor::TreeMetricResult.expects(:history_of).with(metric_configuration.metric.name, subject.id, processing.repository_id).returns([date_module_result]) | |
15 | + date_metric_result.expects(:metric_result).returns(tree_metric_result) | |
16 | + KalibroClient::Entities::Processor::TreeMetricResult.expects(:history_of).with(metric_configuration.metric.name, subject.id, processing.repository_id).returns([date_metric_result]) | |
17 | 17 | end |
18 | 18 | |
19 | 19 | it 'should return the history for the given metric name' do |
20 | - expect(subject.metric_history(metric_configuration.metric.name)).to eq({date_module_result.date => metric_result.value}) | |
20 | + expect(subject.metric_history(metric_configuration.metric.name)).to eq({date_metric_result.date => tree_metric_result.value}) | |
21 | 21 | end |
22 | 22 | end |
23 | 23 | end | ... | ... |