kalibro_client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +27 -0
- data/AUTHORS +4 -0
- data/COPYING +674 -0
- data/COPYING.LESSER +165 -0
- data/Gemfile +4 -0
- data/README.md +77 -0
- data/Rakefile +6 -0
- data/cucumber.yml +1 -0
- data/features/kalibro_configuration/all.feature +10 -0
- data/features/kalibro_configuration/creation.feature +9 -0
- data/features/kalibro_configuration/destroy.feature +10 -0
- data/features/kalibro_configuration/metric_configurations.feature +12 -0
- data/features/metric_collector_details/all_names.feature +8 -0
- data/features/metric_collector_details/find_by_name.feature +12 -0
- data/features/metric_configuration/creation.feature +11 -0
- data/features/metric_configuration/destroy.feature +12 -0
- data/features/metric_configuration/find.feature +18 -0
- data/features/metric_configuration/metric_configurations_of.feature +18 -0
- data/features/metric_result/descendant_values.feature +19 -0
- data/features/metric_result/history_of.feature +20 -0
- data/features/metric_result/metric_results_of.feature +20 -0
- data/features/module_result/children.feature +19 -0
- data/features/module_result/find.feature +22 -0
- data/features/module_result/history_of.feature +19 -0
- data/features/processing/first_processing_after.feature +18 -0
- data/features/processing/first_processing_of.feature +18 -0
- data/features/processing/has_processing.feature +18 -0
- data/features/processing/has_processing_after.feature +18 -0
- data/features/processing/has_processing_before.feature +18 -0
- data/features/processing/has_ready_processing.feature +18 -0
- data/features/processing/last_processing_before.feature +18 -0
- data/features/processing/last_processing_of.feature +18 -0
- data/features/processing/last_processing_state_of.feature +18 -0
- data/features/processing/last_ready_processing_of.feature +19 -0
- data/features/processing/processing_of.feature +32 -0
- data/features/processing/processing_with_date_of.feature +32 -0
- data/features/project/all.feature +10 -0
- data/features/project/creation.feature +9 -0
- data/features/project/destroy.feature +10 -0
- data/features/project/exists.feature +9 -0
- data/features/project/find.feature +10 -0
- data/features/range/destroy.feature +14 -0
- data/features/range/exists.feature +13 -0
- data/features/range/find.feature +14 -0
- data/features/range/ranges_of.feature +22 -0
- data/features/range/save.feature +14 -0
- data/features/reading/destroy.feature +13 -0
- data/features/reading/exists.feature +13 -0
- data/features/reading/find.feature +11 -0
- data/features/reading/readings_of.feature +11 -0
- data/features/reading_group/all.feature +10 -0
- data/features/reading_group/creation.feature +9 -0
- data/features/reading_group/destroy.feature +11 -0
- data/features/repository/all.feature +14 -0
- data/features/repository/cancel_processing.feature +14 -0
- data/features/repository/destroy.feature +14 -0
- data/features/repository/exists.feature +14 -0
- data/features/repository/find.feature +14 -0
- data/features/repository/of.feature +15 -0
- data/features/repository/process.feature +16 -0
- data/features/repository/types.feature +8 -0
- data/features/step_definitions/configuration_steps.rb +40 -0
- data/features/step_definitions/metric_collector_details_steps.rb +28 -0
- data/features/step_definitions/metric_configuration_steps.rb +61 -0
- data/features/step_definitions/metric_result_steps.rb +33 -0
- data/features/step_definitions/metric_steps.rb +3 -0
- data/features/step_definitions/module_result_steps.rb +46 -0
- data/features/step_definitions/processing_steps.rb +95 -0
- data/features/step_definitions/project_steps.rb +48 -0
- data/features/step_definitions/range_steps.rb +72 -0
- data/features/step_definitions/reading_group_steps.rb +36 -0
- data/features/step_definitions/reading_steps.rb +47 -0
- data/features/step_definitions/repository_steps.rb +71 -0
- data/features/support/env.rb +25 -0
- data/features/support/kalibro_cucumber_helpers.yml.sample +3 -0
- data/kalibro_client.gemspec +49 -0
- data/lib/kalibro_client.rb +62 -0
- data/lib/kalibro_client/entities.rb +40 -0
- data/lib/kalibro_client/entities/base.rb +196 -0
- data/lib/kalibro_client/entities/configurations/base.rb +13 -0
- data/lib/kalibro_client/entities/configurations/kalibro_configuration.rb +37 -0
- data/lib/kalibro_client/entities/configurations/kalibro_range.rb +77 -0
- data/lib/kalibro_client/entities/configurations/metric_configuration.rb +93 -0
- data/lib/kalibro_client/entities/configurations/range_snapshot.rb +37 -0
- data/lib/kalibro_client/entities/configurations/reading.rb +56 -0
- data/lib/kalibro_client/entities/configurations/reading_group.rb +34 -0
- data/lib/kalibro_client/entities/miscellaneous/base.rb +57 -0
- data/lib/kalibro_client/entities/miscellaneous/compound_metric.rb +21 -0
- data/lib/kalibro_client/entities/miscellaneous/date_metric_result.rb +14 -0
- data/lib/kalibro_client/entities/miscellaneous/date_module_result.rb +18 -0
- data/lib/kalibro_client/entities/miscellaneous/granularity.rb +54 -0
- data/lib/kalibro_client/entities/miscellaneous/metric.rb +19 -0
- data/lib/kalibro_client/entities/miscellaneous/native_metric.rb +24 -0
- data/lib/kalibro_client/entities/processor/base.rb +16 -0
- data/lib/kalibro_client/entities/processor/kalibro_module.rb +27 -0
- data/lib/kalibro_client/entities/processor/metric_collector_details.rb +53 -0
- data/lib/kalibro_client/entities/processor/metric_result.rb +79 -0
- data/lib/kalibro_client/entities/processor/module_result.rb +82 -0
- data/lib/kalibro_client/entities/processor/process_time.rb +31 -0
- data/lib/kalibro_client/entities/processor/processing.rb +109 -0
- data/lib/kalibro_client/entities/processor/project.rb +34 -0
- data/lib/kalibro_client/entities/processor/repository.rb +75 -0
- data/lib/kalibro_client/errors.rb +18 -0
- data/lib/kalibro_client/errors/record_not_found.rb +22 -0
- data/lib/kalibro_client/errors/standard.rb +24 -0
- data/lib/kalibro_client/helpers/aggregation_options.rb +25 -0
- data/lib/kalibro_client/helpers/hash_converters.rb +48 -0
- data/lib/kalibro_client/helpers/request_methods.rb +55 -0
- data/lib/kalibro_client/helpers/xml_converters.rb +20 -0
- data/lib/kalibro_client/kalibro_cucumber_helpers.rb +60 -0
- data/lib/kalibro_client/kalibro_cucumber_helpers/configuration.rb +30 -0
- data/lib/kalibro_client/kalibro_cucumber_helpers/hooks.rb +25 -0
- data/lib/kalibro_client/version.rb +19 -0
- data/lib/rake/test_task.rb +57 -0
- data/spec/entities/base_spec.rb +313 -0
- data/spec/entities/configurations/base_spec.rb +26 -0
- data/spec/entities/configurations/kalibro_configuration_spec.rb +91 -0
- data/spec/entities/configurations/kalibro_range_spec.rb +174 -0
- data/spec/entities/configurations/metric_configuration_spec.rb +230 -0
- data/spec/entities/configurations/range_snapshot_spec.rb +50 -0
- data/spec/entities/configurations/reading_group_spec.rb +60 -0
- data/spec/entities/configurations/reading_spec.rb +87 -0
- data/spec/entities/miscellaneous/base_spec.rb +49 -0
- data/spec/entities/miscellaneous/compound_metric_spec.rb +36 -0
- data/spec/entities/miscellaneous/date_metric_result_spec.rb +4 -0
- data/spec/entities/miscellaneous/date_module_result_spec.rb +0 -0
- data/spec/entities/miscellaneous/granularity_spec.rb +96 -0
- data/spec/entities/miscellaneous/metric_spec.rb +15 -0
- data/spec/entities/miscellaneous/native_metric_spec.rb +37 -0
- data/spec/entities/processor/base_spec.rb +26 -0
- data/spec/entities/processor/metric_collector_details_spec.rb +146 -0
- data/spec/entities/processor/metric_result_spec.rb +209 -0
- data/spec/entities/processor/module_result_spec.rb +178 -0
- data/spec/entities/processor/process_time_spec.rb +33 -0
- data/spec/entities/processor/processing_spec.rb +333 -0
- data/spec/entities/processor/project_spec.rb +68 -0
- data/spec/entities/processor/repository_spec.rb +140 -0
- data/spec/factories/date_metric_results.rb +30 -0
- data/spec/factories/date_module_results.rb +24 -0
- data/spec/factories/granularities.rb +23 -0
- data/spec/factories/kalibro_configurations.rb +34 -0
- data/spec/factories/kalibro_module.rb +28 -0
- data/spec/factories/kalibro_ranges.rb +40 -0
- data/spec/factories/metric_collector_details.rb +30 -0
- data/spec/factories/metric_configurations.rb +31 -0
- data/spec/factories/metric_results.rb +24 -0
- data/spec/factories/metrics.rb +48 -0
- data/spec/factories/models.rb +23 -0
- data/spec/factories/module_results.rb +43 -0
- data/spec/factories/process_times.rb +27 -0
- data/spec/factories/processings.rb +24 -0
- data/spec/factories/projects.rb +35 -0
- data/spec/factories/ranges_snapshot.rb +26 -0
- data/spec/factories/reading_groups.rb +28 -0
- data/spec/factories/readings.rb +30 -0
- data/spec/factories/repositories.rb +39 -0
- data/spec/helpers/aggregation_options_spec.rb +31 -0
- data/spec/helpers/hash_converters_spec.rb +111 -0
- data/spec/helpers/xml_converters_spec.rb +64 -0
- data/spec/kalibro_entities_spec.rb +112 -0
- data/spec/savon/fixtures/config.yml +2 -0
- data/spec/savon/fixtures/invalid_config.yml +2 -0
- data/spec/savon/fixtures/project/does_not_exists.xml +1 -0
- data/spec/savon/savon_test_helper.rb +14 -0
- data/spec/spec_helper.rb +111 -0
- metadata +479 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
# This file is part of KalibroClient
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe KalibroClient::Entities::Configurations::RangeSnapshot do
|
20
|
+
describe 'beginning=' do
|
21
|
+
it 'should set the value of the attribute beginning' do
|
22
|
+
subject.beginning = 3
|
23
|
+
expect(subject.beginning).to eq(3)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should value -1.0/0 when value be set to -INF' do
|
27
|
+
subject.beginning = "-INF"
|
28
|
+
expect(subject.beginning).to eq(-1.0/0)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'end=' do
|
33
|
+
it 'should set the value of the attribute end' do
|
34
|
+
subject.end = 6
|
35
|
+
expect(subject.end).to eq(6)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should value 1.0/0 when value be set to INF' do
|
39
|
+
subject.end = "INF"
|
40
|
+
expect(subject.end).to eq(1.0/0)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'grade=' do
|
45
|
+
it 'should set the value of the attribute grade' do
|
46
|
+
subject.grade = 18
|
47
|
+
expect(subject.grade).to eq(18)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# This file is part of KalibroClient
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe KalibroClient::Entities::Configurations::ReadingGroup do
|
20
|
+
describe "id=" do
|
21
|
+
subject { FactoryGirl.build(:reading_group_with_id) }
|
22
|
+
|
23
|
+
it 'should set the id attribute values as an integer' do
|
24
|
+
subject.id = "222"
|
25
|
+
expect(subject.id).to eq(222)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'all' do
|
30
|
+
context 'with no reading_groups' do
|
31
|
+
before :each do
|
32
|
+
KalibroClient::Entities::Configurations::ReadingGroup.
|
33
|
+
expects(:request).
|
34
|
+
with('', {}, :get).
|
35
|
+
returns({'reading_groups' => nil})
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should return nil' do
|
39
|
+
expect(KalibroClient::Entities::Configurations::ReadingGroup.all).to be_empty
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with many reading_groups' do
|
44
|
+
let(:reading_group) { FactoryGirl.build(:reading_group_with_id) }
|
45
|
+
before :each do
|
46
|
+
KalibroClient::Entities::Configurations::ReadingGroup.
|
47
|
+
expects(:request).
|
48
|
+
with('', {}, :get).
|
49
|
+
returns({'reading_groups' => [reading_group.to_hash, reading_group.to_hash]})
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should return nil' do
|
53
|
+
reading_groups = KalibroClient::Entities::Configurations::ReadingGroup.all
|
54
|
+
|
55
|
+
expect(reading_groups.first.name).to eq(reading_group.name)
|
56
|
+
expect(reading_groups.last.name).to eq(reading_group.name)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# This file is part of KalibroClient
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe KalibroClient::Entities::Configurations::Reading do
|
20
|
+
describe "id=" do
|
21
|
+
it 'should set the id attribute as an integer' do
|
22
|
+
subject.id = "44"
|
23
|
+
expect(subject.id).to eq(44)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "grade=" do
|
28
|
+
it 'should set the grade attribute as a float' do
|
29
|
+
subject.grade = "44.7"
|
30
|
+
expect(subject.grade).to eq(44.7)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'static methods' do
|
35
|
+
let(:reading) { FactoryGirl.build(:reading_with_id) }
|
36
|
+
describe 'readings_of' do
|
37
|
+
let(:reading_group) { FactoryGirl.build(:reading_group_with_id) }
|
38
|
+
|
39
|
+
before do
|
40
|
+
KalibroClient::Entities::Configurations::Reading.
|
41
|
+
expects(:request).
|
42
|
+
with('', {}, :get, "reading_groups/#{reading_group.id}").
|
43
|
+
returns({'readings' => [reading.to_hash, reading.to_hash]})
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should returns a list of readings that belongs to the given reading group' do
|
47
|
+
response = KalibroClient::Entities::Configurations::Reading.readings_of reading_group.id
|
48
|
+
expect(response.first.label).to eq(reading.label)
|
49
|
+
expect(response.last.label).to eq(reading.label)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# The only purpose of this test is to cover the overrided save_params method
|
55
|
+
describe 'save' do
|
56
|
+
let(:reading) { FactoryGirl.build(:reading, {reading_group_id: FactoryGirl.build(:reading_group_with_id).id}) }
|
57
|
+
let(:reading_id) { 73 }
|
58
|
+
|
59
|
+
before :each do
|
60
|
+
KalibroClient::Entities::Configurations::Reading.
|
61
|
+
expects(:request).
|
62
|
+
with('', {reading: reading.to_hash, reading_group_id: reading.reading_group_id}, :post, "reading_groups/#{reading.reading_group_id}").
|
63
|
+
returns("reading" => {'id' => reading_id, 'kalibro_errors' => []})
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should make a request to save model with id and return true without errors' do
|
67
|
+
expect(reading.save).to be(true)
|
68
|
+
expect(reading.id).to eq(reading_id)
|
69
|
+
expect(reading.kalibro_errors).to be_empty
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# The only purpose of this test is to cover the overrided destroy_prefix method
|
74
|
+
describe 'destroy' do
|
75
|
+
subject {FactoryGirl.build(:reading_with_id)}
|
76
|
+
|
77
|
+
before :each do
|
78
|
+
KalibroClient::Entities::Configurations::Reading.
|
79
|
+
expects(:request).
|
80
|
+
with(":id", {id: subject.id}, :delete, "reading_groups/#{subject.reading_group_id}").returns({})
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should make a request to destroy' do
|
84
|
+
subject.destroy
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe KalibroClient::Entities::Miscellaneous::Base, :type => :model do
|
4
|
+
subject {FactoryGirl.build(:misc_model)}
|
5
|
+
describe 'methods' do
|
6
|
+
describe 'to_hash' do
|
7
|
+
it 'should return an empty hash' do
|
8
|
+
expect(subject.to_hash).to be_empty
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'to_object' do
|
13
|
+
it 'should return an Object with an empty hash' do
|
14
|
+
expect(KalibroClient::Entities::Miscellaneous::Base.to_object({})).to eq(FactoryGirl.build(:misc_model))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should remain an object if it isn't a Hash" do
|
18
|
+
expect(KalibroClient::Entities::Miscellaneous::Base.to_object(Object.new)).to be_an(Object)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '==' do
|
23
|
+
context 'comparing objects from different classes' do
|
24
|
+
it 'should return false' do
|
25
|
+
expect(subject).not_to eq(Object.new)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with two models with different attribute values' do
|
30
|
+
let(:another_model) { FactoryGirl.build(:misc_model) }
|
31
|
+
before :each do
|
32
|
+
subject.expects(:variable_names).returns(["answer"])
|
33
|
+
subject.expects(:send).with("answer").returns(42)
|
34
|
+
another_model.expects(:send).with("answer").returns(41)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should return false' do
|
38
|
+
expect(subject).not_to eq(another_model)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with two empty models' do
|
43
|
+
it 'should return true' do
|
44
|
+
expect(subject).to eq(FactoryGirl.build(:misc_model))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe KalibroClient::Entities::Miscellaneous::CompoundMetric, :type => :model do
|
4
|
+
describe 'methods' do
|
5
|
+
describe 'initialize' do
|
6
|
+
context 'with valid attributes' do
|
7
|
+
name = "Sample name"
|
8
|
+
code = "sample_code"
|
9
|
+
scope = KalibroClient::Entities::Miscellaneous::Granularity.new(:SOFTWARE)
|
10
|
+
script = "return 0;"
|
11
|
+
compound_metric = KalibroClient::Entities::Miscellaneous::CompoundMetric.new(name, code, scope, script)
|
12
|
+
|
13
|
+
it 'should return an instance of CompoundMetric' do
|
14
|
+
expect(compound_metric).to be_a(KalibroClient::Entities::Miscellaneous::CompoundMetric)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'to_object' do
|
20
|
+
subject{ FactoryGirl.build(:compound_metric) }
|
21
|
+
|
22
|
+
context 'with a hash' do
|
23
|
+
it 'is expected to create a object from the hash' do
|
24
|
+
subject_hash = Hash[subject.to_hash.map { |k,v| if v.is_a?(Array) then [k.to_s, v] else [k.to_s, v.to_s] end}]
|
25
|
+
expect(KalibroClient::Entities::Miscellaneous::CompoundMetric.to_object(subject_hash)).to eq(subject)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with a metric' do
|
30
|
+
it 'is expected to be the same object as the argument' do
|
31
|
+
expect(KalibroClient::Entities::Miscellaneous::CompoundMetric.to_object(subject)).to eq(subject)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
File without changes
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe KalibroClient::Entities::Miscellaneous::Granularity do
|
4
|
+
describe 'method' do
|
5
|
+
describe 'initialize' do
|
6
|
+
context 'with a valid type' do
|
7
|
+
it 'should return an instance of Granularity' do
|
8
|
+
expect(KalibroClient::Entities::Miscellaneous::Granularity.new(:SOFTWARE)).to be_a(KalibroClient::Entities::Miscellaneous::Granularity)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'with a invalid type' do
|
13
|
+
it 'should raise a TypeError' do
|
14
|
+
expect { KalibroClient::Entities::Miscellaneous::Granularity.new(:MCC) }.to raise_error(TypeError)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'parent' do
|
20
|
+
context 'with a SOFTWARE granularity' do
|
21
|
+
subject { FactoryGirl.build(:granularity) }
|
22
|
+
|
23
|
+
it 'should return SOFTWARE' do
|
24
|
+
expect(subject.parent.type).to eq(KalibroClient::Entities::Miscellaneous::Granularity::SOFTWARE)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with a METHOD granularity' do
|
29
|
+
subject { FactoryGirl.build(:granularity, type: KalibroClient::Entities::Miscellaneous::Granularity::METHOD) }
|
30
|
+
|
31
|
+
it 'should return CLASS' do
|
32
|
+
expect(subject.parent.type).to eq(KalibroClient::Entities::Miscellaneous::Granularity::CLASS)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'Comparison Operators' do
|
38
|
+
subject { FactoryGirl.build(:granularity, type: KalibroClient::Entities::Miscellaneous::Granularity::CLASS) }
|
39
|
+
context 'comparing to a greater one' do
|
40
|
+
let(:other_granularity) { FactoryGirl.build(:granularity, type: KalibroClient::Entities::Miscellaneous::Granularity::SOFTWARE) }
|
41
|
+
it 'should return true when checking for <' do
|
42
|
+
expect(subject < other_granularity).to be_truthy
|
43
|
+
end
|
44
|
+
it 'should return true when checking for <=' do
|
45
|
+
expect(subject <= other_granularity).to be_truthy
|
46
|
+
end
|
47
|
+
it 'should return false when checking for >' do
|
48
|
+
expect(subject > other_granularity).to be_falsey
|
49
|
+
end
|
50
|
+
it 'should return false when checking for >=' do
|
51
|
+
expect(subject >= other_granularity).to be_falsey
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'comparing to an equal one' do
|
56
|
+
let(:other_granularity) { FactoryGirl.build(:granularity, type: KalibroClient::Entities::Miscellaneous::Granularity::CLASS) }
|
57
|
+
it 'should return false when checking for <' do
|
58
|
+
expect(subject < other_granularity).to be_falsey
|
59
|
+
end
|
60
|
+
it 'should return true when checking for <=' do
|
61
|
+
expect(subject <= other_granularity).to be_truthy
|
62
|
+
end
|
63
|
+
it 'should return false when checking for >' do
|
64
|
+
expect(subject > other_granularity).to be_falsey
|
65
|
+
end
|
66
|
+
it 'should return true when checking for >=' do
|
67
|
+
expect(subject >= other_granularity).to be_truthy
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'comparing to a smaller one' do
|
72
|
+
let(:other_granularity) { FactoryGirl.build(:granularity, type: KalibroClient::Entities::Miscellaneous::Granularity::METHOD) }
|
73
|
+
it 'should return false when checking for <' do
|
74
|
+
expect(subject < other_granularity).to be_falsey
|
75
|
+
end
|
76
|
+
it 'should return false when checking for <=' do
|
77
|
+
expect(subject <= other_granularity).to be_falsey
|
78
|
+
end
|
79
|
+
it 'should return true when checking for >' do
|
80
|
+
expect(subject > other_granularity).to be_truthy
|
81
|
+
end
|
82
|
+
it 'should return true when checking for >=' do
|
83
|
+
expect(subject >= other_granularity).to be_truthy
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'to_s' do
|
89
|
+
subject { FactoryGirl.build(:granularity) }
|
90
|
+
|
91
|
+
it 'is expected to return the type as a string' do
|
92
|
+
expect(subject.to_s).to eq(subject.type.to_s)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe KalibroClient::Entities::Miscellaneous::Metric, :type => :model do
|
4
|
+
describe 'methods' do
|
5
|
+
describe 'initialize' do
|
6
|
+
it 'should return an instance of Metric' do
|
7
|
+
compound = true
|
8
|
+
name = "Sample name"
|
9
|
+
code = "sample_code"
|
10
|
+
scope = KalibroClient::Entities::Miscellaneous::Granularity.new(:SOFTWARE)
|
11
|
+
expect(KalibroClient::Entities::Miscellaneous::Metric.new(compound, name, code, scope)).to be_a(KalibroClient::Entities::Miscellaneous::Metric)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe KalibroClient::Entities::Miscellaneous::NativeMetric, :type => :model do
|
4
|
+
describe 'methods' do
|
5
|
+
describe 'initialize' do
|
6
|
+
context 'with valid attributes' do
|
7
|
+
name = "Sample name"
|
8
|
+
code = "sample_code"
|
9
|
+
scope = KalibroClient::Entities::Miscellaneous::Granularity.new(:SOFTWARE)
|
10
|
+
languages = [:C, :CPP, :JAVA]
|
11
|
+
metric_collector_name = "Analizo"
|
12
|
+
native_metric = KalibroClient::Entities::Miscellaneous::NativeMetric.new(name, code, scope, languages, metric_collector_name)
|
13
|
+
|
14
|
+
it 'should return an instance of NativeMetric' do
|
15
|
+
expect(native_metric).to be_a(KalibroClient::Entities::Miscellaneous::NativeMetric)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'to_object' do
|
21
|
+
subject{ FactoryGirl.build(:loc) }
|
22
|
+
|
23
|
+
context 'with a hash' do
|
24
|
+
it 'is expected to create a object from the hash' do
|
25
|
+
subject_hash = Hash[subject.to_hash.map { |k,v| if v.is_a?(Array) then [k.to_s, v] else [k.to_s, v.to_s] end}]
|
26
|
+
expect(KalibroClient::Entities::Miscellaneous::NativeMetric.to_object(subject_hash)).to eq(subject)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with a metric' do
|
31
|
+
it 'is expected to be the same object as the argument' do
|
32
|
+
expect(KalibroClient::Entities::Miscellaneous::NativeMetric.to_object(subject)).to eq(subject)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|