kalibro_gatekeeper_client 0.0.1.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +29 -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/base_tool/all_names.feature +8 -0
- data/features/base_tool/find_by_name.feature +12 -0
- data/features/configuration/all.feature +10 -0
- data/features/metric_configuration/find.feature +18 -0
- data/features/metric_configuration/metric_configurations_of.feature +18 -0
- data/features/metric_result/descendant_results.feature +19 -0
- data/features/metric_result/history_of.feature +20 -0
- data/features/metric_result/metric_results_of.feature +19 -0
- data/features/module_result/children.feature +18 -0
- data/features/module_result/find.feature +15 -0
- data/features/module_result/history_of.feature +11 -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 +18 -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/all.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/all.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/repository/all.feature +14 -0
- data/features/repository/cancel_processing.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 +9 -0
- data/features/step_definitions/base_tool_steps.rb +28 -0
- data/features/step_definitions/configuration_steps.rb +11 -0
- data/features/step_definitions/metric_configuration_steps.rb +52 -0
- data/features/step_definitions/metric_result_steps.rb +29 -0
- data/features/step_definitions/metric_steps.rb +3 -0
- data/features/step_definitions/module_result_steps.rb +30 -0
- data/features/step_definitions/processing_steps.rb +91 -0
- data/features/step_definitions/project_steps.rb +48 -0
- data/features/step_definitions/range_steps.rb +68 -0
- data/features/step_definitions/reading_group_steps.rb +19 -0
- data/features/step_definitions/reading_steps.rb +39 -0
- data/features/step_definitions/repository_steps.rb +61 -0
- data/features/support/env.rb +25 -0
- data/features/support/kalibro_cucumber_helpers.yml.sample +10 -0
- data/kalibro_gatekeeper_client.gemspec +49 -0
- data/lib/kalibro_gatekeeper_client/entities/base_tool.rb +55 -0
- data/lib/kalibro_gatekeeper_client/entities/configuration.rb +34 -0
- data/lib/kalibro_gatekeeper_client/entities/date_metric_result.rb +39 -0
- data/lib/kalibro_gatekeeper_client/entities/date_module_result.rb +39 -0
- data/lib/kalibro_gatekeeper_client/entities/metric.rb +21 -0
- data/lib/kalibro_gatekeeper_client/entities/metric_configuration.rb +76 -0
- data/lib/kalibro_gatekeeper_client/entities/metric_configuration_snapshot.rb +57 -0
- data/lib/kalibro_gatekeeper_client/entities/metric_result.rb +72 -0
- data/lib/kalibro_gatekeeper_client/entities/model.rb +174 -0
- data/lib/kalibro_gatekeeper_client/entities/module.rb +27 -0
- data/lib/kalibro_gatekeeper_client/entities/module_result.rb +75 -0
- data/lib/kalibro_gatekeeper_client/entities/process_time.rb +31 -0
- data/lib/kalibro_gatekeeper_client/entities/processing.rb +113 -0
- data/lib/kalibro_gatekeeper_client/entities/project.rb +35 -0
- data/lib/kalibro_gatekeeper_client/entities/range.rb +100 -0
- data/lib/kalibro_gatekeeper_client/entities/range_snapshot.rb +37 -0
- data/lib/kalibro_gatekeeper_client/entities/reading.rb +67 -0
- data/lib/kalibro_gatekeeper_client/entities/reading_group.rb +44 -0
- data/lib/kalibro_gatekeeper_client/entities/repository.rb +89 -0
- data/lib/kalibro_gatekeeper_client/entities/repository_observer.rb +50 -0
- data/lib/kalibro_gatekeeper_client/entities/stack_trace_element.rb +31 -0
- data/lib/kalibro_gatekeeper_client/entities/throwable.rb +42 -0
- data/lib/kalibro_gatekeeper_client/entities.rb +37 -0
- data/lib/kalibro_gatekeeper_client/errors/record_not_found.rb +22 -0
- data/lib/kalibro_gatekeeper_client/errors/standard.rb +24 -0
- data/lib/kalibro_gatekeeper_client/errors.rb +18 -0
- data/lib/kalibro_gatekeeper_client/helpers/aggregation_options.rb +25 -0
- data/lib/kalibro_gatekeeper_client/helpers/hash_converters.rb +48 -0
- data/lib/kalibro_gatekeeper_client/helpers/request_methods.rb +47 -0
- data/lib/kalibro_gatekeeper_client/helpers/xml_converters.rb +20 -0
- data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/configuration.rb +39 -0
- data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/hooks.rb +56 -0
- data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/delete_all_kalibro_entries.sh +23 -0
- data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/prepare_kalibro_query_file.sh +38 -0
- data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/put_kalibro_on_test_mode.sh +39 -0
- data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/return_kalibro_from_test_mode.sh +26 -0
- data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers.rb +40 -0
- data/lib/kalibro_gatekeeper_client/version.rb +19 -0
- data/lib/kalibro_gatekeeper_client.rb +61 -0
- data/lib/rake/test_task.rb +57 -0
- data/spec/entities/base_tool_spec.rb +168 -0
- data/spec/entities/configuration_spec.rb +61 -0
- data/spec/entities/date_metric_result_spec.rb +62 -0
- data/spec/entities/date_module_result_spec.rb +61 -0
- data/spec/entities/metric_configuration_snapshot_spec.rb +107 -0
- data/spec/entities/metric_configuration_spec.rb +173 -0
- data/spec/entities/metric_result_spec.rb +188 -0
- data/spec/entities/metric_spec.rb +47 -0
- data/spec/entities/model_spec.rb +322 -0
- data/spec/entities/module_result_spec.rb +163 -0
- data/spec/entities/process_time_spec.rb +33 -0
- data/spec/entities/processing_spec.rb +334 -0
- data/spec/entities/project_spec.rb +68 -0
- data/spec/entities/range_snapshot_spec.rb +50 -0
- data/spec/entities/range_spec.rb +225 -0
- data/spec/entities/reading_group_spec.rb +90 -0
- data/spec/entities/reading_spec.rb +148 -0
- data/spec/entities/repository_observer_spec.rb +123 -0
- data/spec/entities/repository_spec.rb +191 -0
- data/spec/entities/stack_trace_element_spec.rb +26 -0
- data/spec/entities/throwable_spec.rb +51 -0
- data/spec/factories/base_tools.rb +31 -0
- data/spec/factories/configurations.rb +29 -0
- data/spec/factories/date_metric_results.rb +28 -0
- data/spec/factories/date_module_results.rb +22 -0
- data/spec/factories/metric_configurations.rb +28 -0
- data/spec/factories/metric_configurations_snapshot.rb +26 -0
- data/spec/factories/metric_results.rb +24 -0
- data/spec/factories/metrics.rb +35 -0
- data/spec/factories/models.rb +20 -0
- data/spec/factories/module_results.rb +33 -0
- data/spec/factories/modules.rb +22 -0
- data/spec/factories/process_times.rb +27 -0
- data/spec/factories/processings.rb +25 -0
- data/spec/factories/projects.rb +29 -0
- data/spec/factories/ranges.rb +35 -0
- data/spec/factories/ranges_snapshot.rb +26 -0
- data/spec/factories/reading_groups.rb +23 -0
- data/spec/factories/readings.rb +25 -0
- data/spec/factories/repositories.rb +34 -0
- data/spec/factories/repository_observers.rb +24 -0
- data/spec/factories/stack_trace_elements.rb +24 -0
- data/spec/factories/throwables.rb +23 -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 +108 -0
- data/spec/savon/fixtures/config.yml +1 -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 +56 -0
- metadata +466 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# This file is part of KalibroGatekeeperClient
|
|
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 KalibroGatekeeperClient::Entities::Processing do
|
|
20
|
+
subject {FactoryGirl.build(:processing)}
|
|
21
|
+
let(:date) { DateTime.now }
|
|
22
|
+
describe 'id=' do
|
|
23
|
+
it 'should convert the id attribute to integer' do
|
|
24
|
+
subject.id = "41"
|
|
25
|
+
subject.id.should eq 41
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'date=' do
|
|
30
|
+
it 'should set the date attribute' do
|
|
31
|
+
subject.date = date
|
|
32
|
+
subject.date.should eq date
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should convert strings to date format' do
|
|
36
|
+
subject.date = "2013-09-17T18:26:43.151+00:00"
|
|
37
|
+
subject.date.should be_kind_of(DateTime)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe 'using process_time attribute' do
|
|
42
|
+
let(:another_process_time) { FactoryGirl.build(:analyzing_process_time) }
|
|
43
|
+
|
|
44
|
+
context 'process_time=' do
|
|
45
|
+
it 'should set the process_time attribute as a list of objects' do
|
|
46
|
+
subject.process_time = another_process_time.to_hash
|
|
47
|
+
subject.process_time.should eq [another_process_time]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context 'process_times=' do
|
|
52
|
+
it 'should set the process_time attribute' do
|
|
53
|
+
subject.process_times = [another_process_time]
|
|
54
|
+
subject.process_time.should eq [another_process_time]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context 'process_times' do
|
|
59
|
+
it 'should get the process_time attribute' do
|
|
60
|
+
subject.process_times.should eq subject.process_time
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe 'error=' do
|
|
66
|
+
let(:error) { FactoryGirl.build(:throwable, message: 'Another Error!') }
|
|
67
|
+
|
|
68
|
+
it 'should set the attribute error as an object' do
|
|
69
|
+
subject.error = error.to_hash
|
|
70
|
+
subject.error.should eq error
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe 'results_root_id=' do
|
|
75
|
+
it 'should set the attribute results root id as an integer' do
|
|
76
|
+
subject.results_root_id = "36"
|
|
77
|
+
subject.results_root_id.should eq 36
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context 'static methods' do
|
|
82
|
+
context 'using repository as parametter' do
|
|
83
|
+
let(:repository) { FactoryGirl.build(:repository) }
|
|
84
|
+
describe 'has_processing' do
|
|
85
|
+
before :each do
|
|
86
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
87
|
+
expects(:request).once.
|
|
88
|
+
with('has', {repository_id: repository.id}).
|
|
89
|
+
returns({'exists' => false})
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'should convert the hash to a Boolean class' do
|
|
93
|
+
response = KalibroGatekeeperClient::Entities::Processing.has_processing repository.id
|
|
94
|
+
response.should be_a_kind_of(FalseClass)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe 'has_ready_processing' do
|
|
99
|
+
before :each do
|
|
100
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
101
|
+
expects(:request).once.
|
|
102
|
+
with('has_ready', {repository_id: repository.id}).
|
|
103
|
+
returns({'exists' => false})
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'should convert the hash to a Boolean class' do
|
|
107
|
+
response = KalibroGatekeeperClient::Entities::Processing.has_ready_processing repository.id
|
|
108
|
+
response.should be_a_kind_of(FalseClass)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe 'has_processing_after' do
|
|
113
|
+
before :each do
|
|
114
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
115
|
+
expects(:request).once.
|
|
116
|
+
with('has_after', {repository_id: repository.id, date: date}).
|
|
117
|
+
returns({'exists' => false})
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'should convert the hash to a Boolean class' do
|
|
121
|
+
response = KalibroGatekeeperClient::Entities::Processing.has_processing_after(repository.id, date)
|
|
122
|
+
response.should be_a_kind_of(FalseClass)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe 'has_processing_before' do
|
|
127
|
+
before :each do
|
|
128
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
129
|
+
expects(:request).once.
|
|
130
|
+
with('has_before', {repository_id: repository.id, date: date}).
|
|
131
|
+
returns({'exists' => false})
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'should convert the hash to a Boolean class' do
|
|
135
|
+
response = KalibroGatekeeperClient::Entities::Processing.has_processing_before(repository.id, date)
|
|
136
|
+
response.should be_a_kind_of(FalseClass)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
describe 'last_processing_state_of' do
|
|
141
|
+
let(:any_state) { "READY" }
|
|
142
|
+
before :each do
|
|
143
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
144
|
+
expects(:request).once.
|
|
145
|
+
with('last_state_of', {repository_id: repository.id}).
|
|
146
|
+
returns({'state' => any_state})
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it 'should return the state as string' do
|
|
150
|
+
response = KalibroGatekeeperClient::Entities::Processing.last_processing_state_of repository.id
|
|
151
|
+
response.should eq(any_state)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
context 'getting processing entity from Kalibro web service' do
|
|
156
|
+
let(:processing) { FactoryGirl.build(:processing) }
|
|
157
|
+
|
|
158
|
+
describe 'processing_of' do
|
|
159
|
+
context 'when the repository has a ready processing' do
|
|
160
|
+
before do
|
|
161
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
162
|
+
expects(:request).once.
|
|
163
|
+
with('has_ready', {repository_id: repository.id}).
|
|
164
|
+
returns({'exists' => true})
|
|
165
|
+
|
|
166
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
167
|
+
expects(:request).once.
|
|
168
|
+
with('last_ready_of', {repository_id: repository.id}).
|
|
169
|
+
returns({'processing' => processing.to_hash})
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it 'should return the last ready processing' do
|
|
173
|
+
response = KalibroGatekeeperClient::Entities::Processing.processing_of repository.id
|
|
174
|
+
response.state.should eq(processing.state)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
context 'when the repository has not a ready processing' do
|
|
179
|
+
before do
|
|
180
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
181
|
+
expects(:request).once.
|
|
182
|
+
with('has_ready', {repository_id: repository.id}).
|
|
183
|
+
returns({'exists' => false})
|
|
184
|
+
|
|
185
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
186
|
+
expects(:request).once.
|
|
187
|
+
with('last_of', {repository_id: repository.id}).
|
|
188
|
+
returns({'processing' => processing.to_hash})
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it 'should return the last processing' do
|
|
192
|
+
response = KalibroGatekeeperClient::Entities::Processing.processing_of repository.id
|
|
193
|
+
response.state.should eq(processing.state)
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
describe 'processing_with_date_of' do
|
|
199
|
+
context 'when the repository has a processing after the given date' do
|
|
200
|
+
before do
|
|
201
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
202
|
+
expects(:request).once.
|
|
203
|
+
with('has_after', {repository_id: repository.id, date: date}).
|
|
204
|
+
returns({'exists' => true})
|
|
205
|
+
|
|
206
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
207
|
+
expects(:request).once.
|
|
208
|
+
with('first_after_of', {repository_id: repository.id, date: date}).
|
|
209
|
+
returns({'processing' => processing.to_hash})
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it 'should return the first processing after the given date' do
|
|
213
|
+
response = KalibroGatekeeperClient::Entities::Processing.processing_with_date_of(repository.id, date)
|
|
214
|
+
response.state.should eq(processing.state)
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
context 'when the repository has a processing before the given date' do
|
|
219
|
+
before do
|
|
220
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
221
|
+
expects(:request).once.
|
|
222
|
+
with('has_after', {repository_id: repository.id, date: date}).
|
|
223
|
+
returns({'exists' => false})
|
|
224
|
+
|
|
225
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
226
|
+
expects(:request).once.
|
|
227
|
+
with('has_before', {repository_id: repository.id, date: date}).
|
|
228
|
+
returns({'exists' => true})
|
|
229
|
+
|
|
230
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
231
|
+
expects(:request).once.
|
|
232
|
+
with('last_before_of', {repository_id: repository.id, date: date}).
|
|
233
|
+
returns({'processing' => processing.to_hash})
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
it 'should return the last ready processing' do
|
|
237
|
+
response = KalibroGatekeeperClient::Entities::Processing.processing_with_date_of(repository.id, date)
|
|
238
|
+
response.state.should eq(processing.state)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
context 'when the repository has not a processing after or before the given date' do
|
|
243
|
+
before do
|
|
244
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
245
|
+
expects(:request).once.
|
|
246
|
+
with('has_after', {repository_id: repository.id, date: date}).
|
|
247
|
+
returns({'exists' => false})
|
|
248
|
+
|
|
249
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
250
|
+
expects(:request).once.
|
|
251
|
+
with('has_before', {repository_id: repository.id, date: date}).
|
|
252
|
+
returns({'exists' => false})
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
it 'should return the last ready processing' do
|
|
256
|
+
response = KalibroGatekeeperClient::Entities::Processing.processing_with_date_of(repository.id, date)
|
|
257
|
+
response.should be_nil
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
describe 'last_ready_processing_of' do
|
|
263
|
+
before :each do
|
|
264
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
265
|
+
expects(:request).once.
|
|
266
|
+
with('last_ready_of', {repository_id: repository.id}).
|
|
267
|
+
returns({'processing' => processing.to_hash})
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
it 'should return a processing object' do
|
|
271
|
+
response = KalibroGatekeeperClient::Entities::Processing.last_ready_processing_of repository.id
|
|
272
|
+
response.state.should eq(processing.state)
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
describe 'first_processing_of' do
|
|
277
|
+
before :each do
|
|
278
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
279
|
+
expects(:request).once.
|
|
280
|
+
with('first_of', {repository_id: repository.id}).
|
|
281
|
+
returns({'processing' => processing.to_hash})
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
it 'should return a processing object' do
|
|
285
|
+
response = KalibroGatekeeperClient::Entities::Processing.first_processing_of repository.id
|
|
286
|
+
response.state.should eq(processing.state)
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
describe 'last_processing_of' do
|
|
291
|
+
before :each do
|
|
292
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
293
|
+
expects(:request).once.
|
|
294
|
+
with('last_of', {repository_id: repository.id}).
|
|
295
|
+
returns({'processing' => processing.to_hash})
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
it 'should return a processing object' do
|
|
299
|
+
response = KalibroGatekeeperClient::Entities::Processing.last_processing_of repository.id
|
|
300
|
+
response.state.should eq(processing.state)
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
describe 'first_processing_after' do
|
|
305
|
+
before :each do
|
|
306
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
307
|
+
expects(:request).once.
|
|
308
|
+
with('first_after_of', {repository_id: repository.id, date: date}).
|
|
309
|
+
returns({'processing' => processing.to_hash})
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
it 'should return a processing object' do
|
|
313
|
+
response = KalibroGatekeeperClient::Entities::Processing.first_processing_after(repository.id, date)
|
|
314
|
+
response.state.should eq(processing.state)
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
describe 'last_processing_before' do
|
|
319
|
+
before :each do
|
|
320
|
+
KalibroGatekeeperClient::Entities::Processing.
|
|
321
|
+
expects(:request).once.
|
|
322
|
+
with('last_before_of', {repository_id: repository.id, date: date}).
|
|
323
|
+
returns({'processing' => processing.to_hash})
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
it 'should return a processing object' do
|
|
327
|
+
response = KalibroGatekeeperClient::Entities::Processing.last_processing_before(repository.id, date)
|
|
328
|
+
response.state.should eq(processing.state)
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# This file is part of KalibroGatekeeperClient
|
|
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 KalibroGatekeeperClient::Entities::Project do
|
|
20
|
+
describe 'initialize' do
|
|
21
|
+
subject { FactoryGirl.build(:project, {id: 42}) }
|
|
22
|
+
|
|
23
|
+
it 'should have the id set to 42' do
|
|
24
|
+
subject.id.should eq(42)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe 'id=' do
|
|
29
|
+
it 'should set the value of the attribute id as integer' do
|
|
30
|
+
subject.id = "42"
|
|
31
|
+
subject.id.should eq(42)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe 'all' do
|
|
36
|
+
context 'with no projects' do
|
|
37
|
+
before :each do
|
|
38
|
+
KalibroGatekeeperClient::Entities::Project.
|
|
39
|
+
expects(:request).
|
|
40
|
+
with('all', {}, :get).
|
|
41
|
+
returns({:projects => nil}.to_json)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'should return nil' do
|
|
45
|
+
KalibroGatekeeperClient::Entities::Project.all.should be_empty
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context 'with many projects' do
|
|
50
|
+
let(:project) { FactoryGirl.build(:project) }
|
|
51
|
+
let(:another_project) { FactoryGirl.build(:another_project) }
|
|
52
|
+
|
|
53
|
+
before :each do
|
|
54
|
+
KalibroGatekeeperClient::Entities::Project.
|
|
55
|
+
expects(:request).
|
|
56
|
+
with('all', {}, :get).
|
|
57
|
+
returns({:projects => [project.to_hash, another_project.to_hash]}.to_json)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'should return a list with projects' do
|
|
61
|
+
projects = KalibroGatekeeperClient::Entities::Project.all
|
|
62
|
+
|
|
63
|
+
projects.first.name.should eq(project.name)
|
|
64
|
+
projects.last.name.should eq(another_project.name)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# This file is part of KalibroGatekeeperClient
|
|
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 KalibroGatekeeperClient::Entities::RangeSnapshot do
|
|
20
|
+
describe 'beginning=' do
|
|
21
|
+
it 'should set the value of the attribute beginning' do
|
|
22
|
+
subject.beginning = 3
|
|
23
|
+
subject.beginning.should eq(3)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should value -1.0/0 when value be set to -INF' do
|
|
27
|
+
subject.beginning = "-INF"
|
|
28
|
+
subject.beginning.should 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
|
+
subject.end.should eq(6)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should value 1.0/0 when value be set to INF' do
|
|
39
|
+
subject.end = "INF"
|
|
40
|
+
subject.end.should 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
|
+
subject.grade.should eq(18)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# This file is part of KalibroGatekeeperClient
|
|
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 KalibroGatekeeperClient::Entities::Range do
|
|
20
|
+
subject { FactoryGirl.build(:range) }
|
|
21
|
+
|
|
22
|
+
describe 'id=' do
|
|
23
|
+
it 'should set the value of the attribute id as an integer' do
|
|
24
|
+
subject.id = "4"
|
|
25
|
+
subject.id.should eq(4)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'reading_id=' do
|
|
30
|
+
it 'should set the value of the attribute reading_id as an integer' do
|
|
31
|
+
subject.reading_id = "12"
|
|
32
|
+
subject.reading_id.should eq(12)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe 'beginning=' do
|
|
37
|
+
it 'should set the value of the attribute as a float' do
|
|
38
|
+
subject.beginning = "12.3"
|
|
39
|
+
subject.beginning.should eq(12.3)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should set beginning to infinity' do
|
|
43
|
+
subject.beginning = "-INF"
|
|
44
|
+
subject.beginning.should eq("-INF")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe 'end=' do
|
|
49
|
+
it 'should set the value of the attribute as a float' do
|
|
50
|
+
subject.end = "23.4"
|
|
51
|
+
subject.end.should eq(23.4)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should set end to infinity' do
|
|
55
|
+
subject.end = "INF"
|
|
56
|
+
subject.end.should eq("INF")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe 'getting reading attribute' do
|
|
61
|
+
let(:reading) { FactoryGirl.build(:reading) }
|
|
62
|
+
|
|
63
|
+
before :each do
|
|
64
|
+
KalibroGatekeeperClient::Entities::Reading.
|
|
65
|
+
expects(:find).
|
|
66
|
+
with(subject.reading_id).
|
|
67
|
+
returns(reading)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context 'label' do
|
|
71
|
+
it 'should get the label of the reading' do
|
|
72
|
+
subject.label.should eq(reading.label)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context 'grade' do
|
|
77
|
+
it 'should get the grade of the reading' do
|
|
78
|
+
subject.grade.should eq(reading.grade)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context 'color' do
|
|
83
|
+
it 'should get the color of the reading' do
|
|
84
|
+
subject.color.should eq(reading.color)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe 'ranges_of' do
|
|
90
|
+
let(:metric_configuration) { FactoryGirl.build(:metric_configuration) }
|
|
91
|
+
|
|
92
|
+
context 'when does not exists the asked range' do
|
|
93
|
+
before :each do
|
|
94
|
+
KalibroGatekeeperClient::Entities::Range.
|
|
95
|
+
expects(:request).
|
|
96
|
+
with('of', {metric_configuration_id: metric_configuration.id}).
|
|
97
|
+
returns({'ranges' => nil})
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'should return a list with the ranges' do
|
|
101
|
+
KalibroGatekeeperClient::Entities::Range.ranges_of(metric_configuration.id).should eq([])
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
context 'when exist only one range for the given metric configuration' do
|
|
106
|
+
before :each do
|
|
107
|
+
KalibroGatekeeperClient::Entities::Range.
|
|
108
|
+
expects(:request).
|
|
109
|
+
with('of', {metric_configuration_id: metric_configuration.id}).
|
|
110
|
+
returns({'ranges' => subject.to_hash})
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'should return a list with the range' do
|
|
114
|
+
KalibroGatekeeperClient::Entities::Range.ranges_of(metric_configuration.id).
|
|
115
|
+
first.beginning.should eq(subject.beginning)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
context 'when exists many ranges for the given metric configuration' do
|
|
120
|
+
let(:another_range) { FactoryGirl.build(:another_range) }
|
|
121
|
+
|
|
122
|
+
before :each do
|
|
123
|
+
KalibroGatekeeperClient::Entities::Range.
|
|
124
|
+
expects(:request).
|
|
125
|
+
with('of', {metric_configuration_id: metric_configuration.id}).
|
|
126
|
+
returns({'ranges' => [subject.to_hash, another_range.to_hash]})
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'should return a list with the ranges' do
|
|
130
|
+
ranges = KalibroGatekeeperClient::Entities::Range.ranges_of(metric_configuration.id)
|
|
131
|
+
ranges.first.comments.should eq(subject.comments)
|
|
132
|
+
ranges.last.comments.should eq(another_range.comments)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# The only purpose of this test is to cover the overrided save_params method
|
|
138
|
+
describe 'save' do
|
|
139
|
+
subject {FactoryGirl.build(:range, {id: nil})}
|
|
140
|
+
|
|
141
|
+
before :each do
|
|
142
|
+
KalibroGatekeeperClient::Entities::Range.
|
|
143
|
+
expects(:request).
|
|
144
|
+
with('save', {:range => subject.to_hash, :metric_configuration_id => subject.metric_configuration_id}).
|
|
145
|
+
returns({'id' => 2})
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'should make a request to save model with id and return true without errors' do
|
|
149
|
+
subject.save.should be(true)
|
|
150
|
+
subject.kalibro_errors.should be_empty
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe 'exists?' do
|
|
155
|
+
context 'when the range exists' do
|
|
156
|
+
before :each do
|
|
157
|
+
KalibroGatekeeperClient::Entities::Range.expects(:find).with(subject.id).returns(subject)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it 'should return true' do
|
|
161
|
+
KalibroGatekeeperClient::Entities::Range.exists?(subject.id).should be_true
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
context 'when the range does not exists' do
|
|
166
|
+
before :each do
|
|
167
|
+
KalibroGatekeeperClient::Entities::Range.expects(:find).with(subject.id).raises(KalibroGatekeeperClient::Errors::RecordNotFound)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'should return false' do
|
|
171
|
+
KalibroGatekeeperClient::Entities::Range.exists?(subject.id).should be_false
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
describe 'find' do
|
|
177
|
+
context 'when the range exists' do
|
|
178
|
+
before :each do
|
|
179
|
+
KalibroGatekeeperClient::Entities::Range.
|
|
180
|
+
expects(:all).
|
|
181
|
+
returns([subject])
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it 'should return the range' do
|
|
185
|
+
KalibroGatekeeperClient::Entities::Range.find(subject.id).should eq(subject)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
context "when the range doesn't exists" do
|
|
190
|
+
before :each do
|
|
191
|
+
KalibroGatekeeperClient::Entities::Range.
|
|
192
|
+
expects(:all).
|
|
193
|
+
returns([FactoryGirl.build(:another_range)])
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it 'should raise a RecordNotFound error' do
|
|
197
|
+
expect { KalibroGatekeeperClient::Entities::Range.find(subject.id) }.
|
|
198
|
+
to raise_error(KalibroGatekeeperClient::Errors::RecordNotFound)
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
describe 'all' do
|
|
204
|
+
let(:configuration) { FactoryGirl.build(:configuration) }
|
|
205
|
+
let(:metric_configuration) { FactoryGirl.build(:metric_configuration) }
|
|
206
|
+
|
|
207
|
+
before :each do
|
|
208
|
+
KalibroGatekeeperClient::Entities::Configuration.
|
|
209
|
+
expects(:all).
|
|
210
|
+
returns([configuration])
|
|
211
|
+
KalibroGatekeeperClient::Entities::MetricConfiguration.
|
|
212
|
+
expects(:metric_configurations_of).
|
|
213
|
+
with(configuration.id).
|
|
214
|
+
returns([metric_configuration])
|
|
215
|
+
KalibroGatekeeperClient::Entities::Range.
|
|
216
|
+
expects(:ranges_of).
|
|
217
|
+
with(metric_configuration.id).
|
|
218
|
+
returns([subject])
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
it 'should list all the ranges' do
|
|
222
|
+
KalibroGatekeeperClient::Entities::Range.all.should include(subject)
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|