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 | 1 | GIT |
2 | 2 | remote: https://github.com/mezuro/kalibro_client |
3 | - revision: 1a4ef5f0ea168a6d91d1e86866f906ffccf59cad | |
3 | + revision: e8367929a341a2eaf16599a858972703151a8967 | |
4 | 4 | specs: |
5 | 5 | kalibro_client (0.0.1) |
6 | 6 | activeresource (~> 4.0.0) |
... | ... | @@ -165,7 +165,7 @@ GEM |
165 | 165 | net-scp (1.2.1) |
166 | 166 | net-ssh (>= 2.6.5) |
167 | 167 | net-ssh (2.9.1) |
168 | - netrc (0.8.0) | |
168 | + netrc (0.9.0) | |
169 | 169 | nokogiri (1.6.5) |
170 | 170 | mini_portile (~> 0.6.0) |
171 | 171 | orm_adapter (0.5.0) |
... | ... | @@ -195,7 +195,7 @@ GEM |
195 | 195 | activesupport (= 4.1.6) |
196 | 196 | rake (>= 0.8.7) |
197 | 197 | thor (>= 0.18.1, < 2.0) |
198 | - rake (10.4.0) | |
198 | + rake (10.4.2) | |
199 | 199 | rdoc (4.1.2) |
200 | 200 | json (~> 1.4) |
201 | 201 | ref (1.0.5) | ... | ... |
app/controllers/metric_configurations_controller.rb
... | ... | @@ -2,18 +2,18 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
2 | 2 | def choose_metric |
3 | 3 | @mezuro_configuration_id = params[:mezuro_configuration_id].to_i |
4 | 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 | 6 | end |
7 | 7 | |
8 | 8 | def new |
9 | 9 | super |
10 | 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 | 12 | end |
13 | 13 | |
14 | 14 | def create |
15 | 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 | 17 | @metric_configuration.metric_collector_name = params[:metric_collector_name] |
18 | 18 | @metric_configuration.code = @metric_configuration.metric.code |
19 | 19 | respond_to do |format| | ... | ... |
spec/controllers/metric_configurations_controller_spec.rb
... | ... | @@ -11,7 +11,7 @@ describe MetricConfigurationsController, :type => :controller do |
11 | 11 | context 'when adding new metrics' do |
12 | 12 | before :each do |
13 | 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 | 15 | get :choose_metric, mezuro_configuration_id: mezuro_configuration.id |
16 | 16 | end |
17 | 17 | |
... | ... | @@ -29,7 +29,7 @@ describe MetricConfigurationsController, :type => :controller do |
29 | 29 | context 'when the current user owns the mezuro configuration' do |
30 | 30 | before :each do |
31 | 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 | 33 | post :new, mezuro_configuration_id: mezuro_configuration.id, metric_name: "Lines of Code", metric_collector_name: metric_collector.name |
34 | 34 | end |
35 | 35 | |
... | ... | @@ -65,7 +65,7 @@ describe MetricConfigurationsController, :type => :controller do |
65 | 65 | context 'with valid fields' do |
66 | 66 | before :each do |
67 | 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 | 69 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) |
70 | 70 | |
71 | 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 | 77 | context 'with invalid fields' do |
78 | 78 | before :each do |
79 | 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 | 81 | metric_collector.expects(:metric).with(metric_configuration.metric.name).returns(metric_configuration.metric) |
82 | 82 | |
83 | 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 | 1 | FactoryGirl.define do |
2 | - factory :metric_collector, class: MetricCollector do | |
2 | + factory :metric_collector, class: KalibroClient::Processor::MetricCollector do | |
3 | 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 | 5 | end |
6 | 6 | end | ... | ... |
spec/factories/metric_configurations.rb
... | ... | @@ -13,7 +13,7 @@ FactoryGirl.define do |
13 | 13 | factory :compound_metric_configuration, class: MetricConfiguration do |
14 | 14 | id 1 |
15 | 15 | code 'compound' |
16 | - metric {FactoryGirl.build(:compound_metric, script: 'native*2;')} | |
16 | + metric { FactoryGirl.build(:compound_metric, script: 'native*2;') } | |
17 | 17 | weight 1 |
18 | 18 | aggregation_form "AVERAGE" |
19 | 19 | reading_group_id 1 | ... | ... |
spec/factories/metrics.rb
... | ... | @@ -19,15 +19,13 @@ FactoryGirl.define do |
19 | 19 | initialize_with { new(compound, name, code, scope) } |
20 | 20 | end |
21 | 21 | |
22 | - factory :compound_metric, class: KalibroClient::Processor::Metric do | |
22 | + factory :compound_metric, class: KalibroClient::Processor::CompoundMetric do | |
23 | 23 | name "Compound" |
24 | 24 | code "compound" |
25 | - compound true | |
26 | 25 | scope "CLASS" |
27 | 26 | description nil |
28 | 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 | 30 | end |
33 | 31 | end | ... | ... |