Commit 40903bd9f783e56dddc38ecbf3ffb0ff8f862888
Committed by
Rafael Manzo
1 parent
d8272290
Exists in
colab
and in
4 other branches
[WIP] Fixing more tests for kalibro client integration
Signed off by: Daniel Alves <danpaulalves@gmail.com>
Showing
6 changed files
with
15 additions
and
17 deletions
Show diff stats
Gemfile.lock
1 | GIT | 1 | GIT |
2 | remote: https://github.com/mezuro/kalibro_client | 2 | remote: https://github.com/mezuro/kalibro_client |
3 | - revision: 1a4ef5f0ea168a6d91d1e86866f906ffccf59cad | 3 | + revision: e8367929a341a2eaf16599a858972703151a8967 |
4 | specs: | 4 | specs: |
5 | kalibro_client (0.0.1) | 5 | kalibro_client (0.0.1) |
6 | activeresource (~> 4.0.0) | 6 | activeresource (~> 4.0.0) |
@@ -165,7 +165,7 @@ GEM | @@ -165,7 +165,7 @@ GEM | ||
165 | net-scp (1.2.1) | 165 | net-scp (1.2.1) |
166 | net-ssh (>= 2.6.5) | 166 | net-ssh (>= 2.6.5) |
167 | net-ssh (2.9.1) | 167 | net-ssh (2.9.1) |
168 | - netrc (0.8.0) | 168 | + netrc (0.9.0) |
169 | nokogiri (1.6.5) | 169 | nokogiri (1.6.5) |
170 | mini_portile (~> 0.6.0) | 170 | mini_portile (~> 0.6.0) |
171 | orm_adapter (0.5.0) | 171 | orm_adapter (0.5.0) |
@@ -195,7 +195,7 @@ GEM | @@ -195,7 +195,7 @@ GEM | ||
195 | activesupport (= 4.1.6) | 195 | activesupport (= 4.1.6) |
196 | rake (>= 0.8.7) | 196 | rake (>= 0.8.7) |
197 | thor (>= 0.18.1, < 2.0) | 197 | thor (>= 0.18.1, < 2.0) |
198 | - rake (10.4.0) | 198 | + rake (10.4.2) |
199 | rdoc (4.1.2) | 199 | rdoc (4.1.2) |
200 | json (~> 1.4) | 200 | json (~> 1.4) |
201 | ref (1.0.5) | 201 | ref (1.0.5) |
app/controllers/metric_configurations_controller.rb
@@ -2,18 +2,18 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -2,18 +2,18 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
2 | def choose_metric | 2 | def choose_metric |
3 | @mezuro_configuration_id = params[:mezuro_configuration_id].to_i | 3 | @mezuro_configuration_id = params[:mezuro_configuration_id].to_i |
4 | @metric_configuration_id = params[:metric_configuration_id].to_i | 4 | @metric_configuration_id = params[:metric_configuration_id].to_i |
5 | - @metric_collectors = KalibroGatekeeperClient::Entities::MetricCollector.all | 5 | + @metric_collectors = KalibroClient::Processor::MetricCollector.all |
6 | end | 6 | end |
7 | 7 | ||
8 | def new | 8 | def new |
9 | super | 9 | super |
10 | metric_configuration.metric_collector_name = params[:metric_collector_name] | 10 | metric_configuration.metric_collector_name = params[:metric_collector_name] |
11 | - metric_configuration.metric = KalibroGatekeeperClient::Entities::MetricCollector.find_by_name(params[:metric_collector_name]).metric params[:metric_name] | 11 | + metric_configuration.metric = KalibroClient::Processor::MetricCollector.find_by_name(params[:metric_collector_name]).metric params[:metric_name] |
12 | end | 12 | end |
13 | 13 | ||
14 | def create | 14 | def create |
15 | super | 15 | super |
16 | - @metric_configuration.metric = KalibroGatekeeperClient::Entities::MetricCollector.find_by_name(params[:metric_collector_name]).metric params[:metric_name] | 16 | + @metric_configuration.metric = KalibroClient::Processor::MetricCollector.find_by_name(params[:metric_collector_name]).metric params[:metric_name] |
17 | @metric_configuration.metric_collector_name = params[:metric_collector_name] | 17 | @metric_configuration.metric_collector_name = params[:metric_collector_name] |
18 | @metric_configuration.code = @metric_configuration.metric.code | 18 | @metric_configuration.code = @metric_configuration.metric.code |
19 | respond_to do |format| | 19 | respond_to do |format| |
spec/controllers/metric_configurations_controller_spec.rb
@@ -11,7 +11,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -11,7 +11,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
11 | context 'when adding new metrics' do | 11 | context 'when adding new metrics' do |
12 | before :each do | 12 | before :each do |
13 | subject.expects(:mezuro_configuration_owner?).returns true | 13 | subject.expects(:mezuro_configuration_owner?).returns true |
14 | - KalibroGatekeeperClient::Entities::MetricCollector.expects(:all).returns([metric_collector]) | 14 | + KalibroClient::Processor::MetricCollector.expects(:all).returns([metric_collector]) |
15 | get :choose_metric, mezuro_configuration_id: mezuro_configuration.id | 15 | get :choose_metric, mezuro_configuration_id: mezuro_configuration.id |
16 | end | 16 | end |
17 | 17 | ||
@@ -29,7 +29,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -29,7 +29,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
29 | context 'when the current user owns the mezuro configuration' do | 29 | context 'when the current user owns the mezuro configuration' do |
30 | before :each do | 30 | before :each do |
31 | subject.expects(:mezuro_configuration_owner?).returns true | 31 | subject.expects(:mezuro_configuration_owner?).returns true |
32 | - KalibroGatekeeperClient::Entities::MetricCollector.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) | 32 | + KalibroClient::Processor::MetricCollector.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) |
33 | post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", metric_collector_name: metric_collector.name | 33 | post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", metric_collector_name: metric_collector.name |
34 | end | 34 | end |
35 | 35 | ||
@@ -65,7 +65,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -65,7 +65,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
65 | context 'with valid fields' do | 65 | context 'with valid fields' do |
66 | before :each do | 66 | before :each do |
67 | MetricConfiguration.any_instance.expects(:save).returns(true) | 67 | MetricConfiguration.any_instance.expects(:save).returns(true) |
68 | - KalibroGatekeeperClient::Entities::MetricCollector.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) | 68 | + KalibroClient::Processor::MetricCollector.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) |
69 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | 69 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) |
70 | 70 | ||
71 | post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name | 71 | post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name |
@@ -77,7 +77,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -77,7 +77,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
77 | context 'with invalid fields' do | 77 | context 'with invalid fields' do |
78 | before :each do | 78 | before :each do |
79 | MetricConfiguration.any_instance.expects(:save).returns(false) | 79 | MetricConfiguration.any_instance.expects(:save).returns(false) |
80 | - KalibroGatekeeperClient::Entities::MetricCollector.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) | 80 | + KalibroClient::Processor::MetricCollector.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) |
81 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) | 81 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) |
82 | 82 | ||
83 | post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name | 83 | post :create, mezuro_configuration_id: mezuro_configuration.id, metric_configuration: metric_configuration_params, metric_collector_name: metric_collector.name, metric_name: metric_configuration.metric.name |
spec/factories/metric_collectors.rb
1 | FactoryGirl.define do | 1 | FactoryGirl.define do |
2 | - factory :metric_collector, class: MetricCollector do | 2 | + factory :metric_collector, class: KalibroClient::Processor::MetricCollector do |
3 | name 'Analizo' | 3 | name 'Analizo' |
4 | - supported_metrics { { "total_abstract_classes" => FactoryGirl.build(:metric).to_hash, "loc" => FactoryGirl.build(:loc).to_hash } } | 4 | + supported_metrics { { "total_abstract_classes" => FactoryGirl.build(:metric), "loc" => FactoryGirl.build(:loc)} } |
5 | end | 5 | end |
6 | end | 6 | end |
spec/factories/metric_configurations.rb
@@ -13,7 +13,7 @@ FactoryGirl.define do | @@ -13,7 +13,7 @@ FactoryGirl.define do | ||
13 | factory :compound_metric_configuration, class: MetricConfiguration do | 13 | factory :compound_metric_configuration, class: MetricConfiguration do |
14 | id 1 | 14 | id 1 |
15 | code 'compound' | 15 | code 'compound' |
16 | - metric {FactoryGirl.build(:compound_metric, script: 'native*2;')} | 16 | + metric { FactoryGirl.build(:compound_metric, script: 'native*2;') } |
17 | weight 1 | 17 | weight 1 |
18 | aggregation_form "AVERAGE" | 18 | aggregation_form "AVERAGE" |
19 | reading_group_id 1 | 19 | reading_group_id 1 |
spec/factories/metrics.rb
@@ -19,15 +19,13 @@ FactoryGirl.define do | @@ -19,15 +19,13 @@ FactoryGirl.define do | ||
19 | initialize_with { new(compound, name, code, scope) } | 19 | initialize_with { new(compound, name, code, scope) } |
20 | end | 20 | end |
21 | 21 | ||
22 | - factory :compound_metric, class: KalibroClient::Processor::Metric do | 22 | + factory :compound_metric, class: KalibroClient::Processor::CompoundMetric do |
23 | name "Compound" | 23 | name "Compound" |
24 | code "compound" | 24 | code "compound" |
25 | - compound true | ||
26 | scope "CLASS" | 25 | scope "CLASS" |
27 | description nil | 26 | description nil |
28 | script "" | 27 | script "" |
29 | - language ["C", "CPP", "JAVA"] | ||
30 | 28 | ||
31 | - initialize_with { new(compound, name, code, scope) } | 29 | + initialize_with { new(name, code, scope, script) } |
32 | end | 30 | end |
33 | end | 31 | end |