kalibro_gem 0.0.4 → 0.0.5
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 +4 -4
- data/.rspec +2 -0
- data/features/step_definitions/base_tool_steps.rb +5 -5
- data/features/step_definitions/processing_steps.rb +6 -6
- data/kalibro_gem.gemspec +3 -2
- data/lib/kalibro_gem/version.rb +1 -1
- data/spec/entities/base_tool_spec.rb +13 -13
- data/spec/entities/configuration_spec.rb +5 -5
- data/spec/entities/date_metric_result_spec.rb +5 -5
- data/spec/entities/date_module_result_spec.rb +5 -5
- data/spec/entities/metric_configuration_snapshot_spec.rb +10 -10
- data/spec/entities/metric_configuration_spec.rb +14 -14
- data/spec/entities/metric_result_spec.rb +17 -17
- data/spec/entities/metric_spec.rb +3 -3
- data/spec/entities/model_spec.rb +30 -30
- data/spec/entities/module_result_spec.rb +14 -14
- data/spec/entities/process_time_spec.rb +2 -2
- data/spec/entities/processing_spec.rb +23 -23
- data/spec/entities/project_spec.rb +5 -5
- data/spec/entities/range_snapshot_spec.rb +5 -5
- data/spec/entities/range_spec.rb +20 -20
- data/spec/entities/reading_group_spec.rb +5 -5
- data/spec/entities/reading_spec.rb +11 -11
- data/spec/entities/repository_observer_spec.rb +14 -14
- data/spec/entities/repository_spec.rb +12 -12
- data/spec/entities/stack_trace_element_spec.rb +1 -1
- data/spec/entities/throwable_spec.rb +4 -4
- data/spec/helpers/aggregation_options_spec.rb +1 -1
- data/spec/helpers/hash_converters_spec.rb +10 -10
- data/spec/helpers/xml_converters_spec.rb +5 -5
- data/spec/kalibro_entities_spec.rb +10 -11
- data/spec/spec_helper.rb +62 -6
- metadata +21 -6
@@ -24,7 +24,7 @@ describe KalibroGem::Entities::MetricResult do
|
|
24
24
|
context 'with value NaN' do
|
25
25
|
it 'should set the value with aggregated_value' do
|
26
26
|
metric_result = KalibroGem::Entities::MetricResult.new( FactoryGirl.attributes_for(:metric_result, {value: "NaN", aggregated_value: 1.6}) )
|
27
|
-
metric_result.value.
|
27
|
+
expect(metric_result.value).to eq(1.6)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -32,35 +32,35 @@ describe KalibroGem::Entities::MetricResult do
|
|
32
32
|
describe 'id=' do
|
33
33
|
it 'should set the value of the attribute id' do
|
34
34
|
subject.id = 42
|
35
|
-
subject.id.
|
35
|
+
expect(subject.id).to eq(42)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe 'configuration=' do
|
40
40
|
it 'should set the configuration' do
|
41
41
|
subject.configuration = metric_configuration_snapshot.to_hash
|
42
|
-
subject.configuration.code.
|
42
|
+
expect(subject.configuration.code).to eq(metric_configuration_snapshot.code)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe 'metric_configuration_snapshot' do
|
47
47
|
it 'should be an alias to configuration' do
|
48
48
|
subject.configuration = metric_configuration_snapshot.to_hash
|
49
|
-
subject.metric_configuration_snapshot.code.
|
49
|
+
expect(subject.metric_configuration_snapshot.code).to eq(metric_configuration_snapshot.code)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe 'value=' do
|
54
54
|
it 'should set the value of the attribute value' do
|
55
55
|
subject.value = 42
|
56
|
-
subject.value.
|
56
|
+
expect(subject.value).to eq(42)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe 'aggregated_value=' do
|
61
61
|
it 'should set the value of the attribute aggregated_value' do
|
62
62
|
subject.aggregated_value = 42
|
63
|
-
subject.aggregated_value.
|
63
|
+
expect(subject.aggregated_value).to eq(42)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -74,7 +74,7 @@ describe KalibroGem::Entities::MetricResult do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should return an unitary list with the descendant result' do
|
77
|
-
subject.descendant_results.
|
77
|
+
expect(subject.descendant_results).to eq([13.3])
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -87,7 +87,7 @@ describe KalibroGem::Entities::MetricResult do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'should return an empty list' do
|
90
|
-
subject.descendant_results.
|
90
|
+
expect(subject.descendant_results).to eq([])
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -100,7 +100,7 @@ describe KalibroGem::Entities::MetricResult do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'should return a list with the descendant results' do
|
103
|
-
subject.descendant_results.
|
103
|
+
expect(subject.descendant_results).to eq([-13.3, 42.42, 1])
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
@@ -115,7 +115,7 @@ describe KalibroGem::Entities::MetricResult do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'should return an unitary list with the metric result' do
|
118
|
-
KalibroGem::Entities::MetricResult.metric_results_of(123).first.value.
|
118
|
+
expect(KalibroGem::Entities::MetricResult.metric_results_of(123).first.value).to eq(subject.value)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -128,7 +128,7 @@ describe KalibroGem::Entities::MetricResult do
|
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'should return an empty list' do
|
131
|
-
KalibroGem::Entities::MetricResult.metric_results_of(42).
|
131
|
+
expect(KalibroGem::Entities::MetricResult.metric_results_of(42)).to eq([])
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -142,7 +142,7 @@ describe KalibroGem::Entities::MetricResult do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
it 'should return a list with the descendant results' do
|
145
|
-
metric_results.first.value.
|
145
|
+
expect(metric_results.first.value).to eq(subject.value)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
@@ -160,7 +160,7 @@ describe KalibroGem::Entities::MetricResult do
|
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'should return an empty list' do
|
163
|
-
KalibroGem::Entities::MetricResult.history_of(metric.name, module_result.id).
|
163
|
+
expect(KalibroGem::Entities::MetricResult.history_of(metric.name, module_result.id)).to eq([])
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
@@ -175,8 +175,8 @@ describe KalibroGem::Entities::MetricResult do
|
|
175
175
|
end
|
176
176
|
|
177
177
|
it 'should return the date metric result as an object into a list' do
|
178
|
-
KalibroGem::Entities::MetricResult.history_of(metric.name, module_result.id).
|
179
|
-
first.metric_result.id.
|
178
|
+
expect(KalibroGem::Entities::MetricResult.history_of(metric.name, module_result.id).
|
179
|
+
first.metric_result.id).to eq(subject.id)
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -193,8 +193,8 @@ describe KalibroGem::Entities::MetricResult do
|
|
193
193
|
|
194
194
|
it 'should return a list of date metric results as objects' do
|
195
195
|
response = KalibroGem::Entities::MetricResult.history_of(metric.name, module_result.id)
|
196
|
-
response.first.metric_result.id.
|
197
|
-
response.last.metric_result.id.
|
196
|
+
expect(response.first.metric_result.id).to eq(date_metric_result.metric_result.id)
|
197
|
+
expect(response.last.metric_result.id).to eq(another_date_metric_result.metric_result.id)
|
198
198
|
end
|
199
199
|
end
|
200
200
|
end
|
@@ -21,14 +21,14 @@ describe KalibroGem::Entities::Metric do
|
|
21
21
|
subject { FactoryGirl.build(:metric) }
|
22
22
|
|
23
23
|
it 'should return the value of the language attribute' do
|
24
|
-
subject.languages.
|
24
|
+
expect(subject.languages).to eq(["C", "CPP", "JAVA"])
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe 'languages=' do
|
29
29
|
it 'should set the value of the attribute language' do
|
30
30
|
subject.languages = ["Java", "C"]
|
31
|
-
subject.languages.
|
31
|
+
expect(subject.languages).to eq(["Java", "C"])
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -41,7 +41,7 @@ describe KalibroGem::Entities::Metric do
|
|
41
41
|
|
42
42
|
it 'should convert the value to an array of objects' do
|
43
43
|
subject.language = "Java"
|
44
|
-
subject.languages.
|
44
|
+
expect(subject.languages).to eq(["Java"])
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/spec/entities/model_spec.rb
CHANGED
@@ -22,17 +22,17 @@ describe KalibroGem::Entities::Model do
|
|
22
22
|
describe 'new' do
|
23
23
|
it 'should create a model from an empty hash' do
|
24
24
|
subject = KalibroGem::Entities::Model.new {}
|
25
|
-
subject.kalibro_errors.
|
25
|
+
expect(subject.kalibro_errors).to eq([])
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe 'class_name' do
|
30
30
|
it 'should be a String' do
|
31
|
-
subject.class.class_name.
|
31
|
+
expect(subject.class.class_name).to be_a(String)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should return Model' do
|
35
|
-
subject.class.class_name.
|
35
|
+
expect(subject.class.class_name).to eq('Model')
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -40,13 +40,13 @@ describe KalibroGem::Entities::Model do
|
|
40
40
|
it 'should return the class_name' do
|
41
41
|
endpoint = 'test'
|
42
42
|
KalibroGem::Entities::Model.expects(:class_name).returns(endpoint)
|
43
|
-
KalibroGem::Entities::Model.endpoint.
|
43
|
+
expect(KalibroGem::Entities::Model.endpoint).to eq(endpoint)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe 'client' do
|
48
48
|
it 'returns a Savon::Client' do
|
49
|
-
KalibroGem::Entities::Model.client('Model').
|
49
|
+
expect(KalibroGem::Entities::Model.client('Model')).to be_a(Savon::Client)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -63,8 +63,8 @@ describe KalibroGem::Entities::Model do
|
|
63
63
|
expects(:client).
|
64
64
|
with(any_parameters).
|
65
65
|
returns(client)
|
66
|
-
KalibroGem::Entities::Model.
|
67
|
-
request(:project_exists, {project_id: 1})[:exists].
|
66
|
+
expect(KalibroGem::Entities::Model.
|
67
|
+
request(:project_exists, {project_id: 1})[:exists]).to eq(false)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -79,36 +79,36 @@ describe KalibroGem::Entities::Model do
|
|
79
79
|
expects(:client).
|
80
80
|
with(any_parameters).
|
81
81
|
returns(client)
|
82
|
-
Child.
|
83
|
-
request(:project_exists, {project_id: 1})[:exists].
|
82
|
+
expect(Child.
|
83
|
+
request(:project_exists, {project_id: 1})[:exists]).to eq(false)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
describe 'to_hash' do
|
89
89
|
it 'should return an empty hash' do
|
90
|
-
subject.to_hash.
|
90
|
+
expect(subject.to_hash).to eq({kalibro_errors: []})
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe 'to_object' do
|
95
95
|
it 'should return an Object with an empty hash' do
|
96
|
-
KalibroGem::Entities::Model.to_object({}).
|
96
|
+
expect(KalibroGem::Entities::Model.to_object({})).to eq(FactoryGirl.build(:model))
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should remain an object if it isn't a Hash" do
|
100
|
-
KalibroGem::Entities::Model.to_object(Object.new).
|
100
|
+
expect(KalibroGem::Entities::Model.to_object(Object.new)).to be_an(Object)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
describe 'to_objects_array' do
|
105
105
|
it 'should convert [{}] to [Model]' do
|
106
|
-
KalibroGem::Entities::Model.to_objects_array({}).
|
106
|
+
expect(KalibroGem::Entities::Model.to_objects_array({})).to eq([FactoryGirl.build(:model)])
|
107
107
|
end
|
108
108
|
|
109
109
|
it 'should remain an array if it already is one' do
|
110
110
|
object = Object.new
|
111
|
-
KalibroGem::Entities::Model.to_objects_array([object]).
|
111
|
+
expect(KalibroGem::Entities::Model.to_objects_array([object])).to eq([object])
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -121,8 +121,8 @@ describe KalibroGem::Entities::Model do
|
|
121
121
|
|
122
122
|
context "when it doesn't have the method id=" do
|
123
123
|
it 'should make a request to save model with id returning false and an error' do
|
124
|
-
subject.save.
|
125
|
-
subject.kalibro_errors[0].
|
124
|
+
expect(subject.save).to be(false)
|
125
|
+
expect(subject.kalibro_errors[0]).to be_a(NoMethodError)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -135,8 +135,8 @@ describe KalibroGem::Entities::Model do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'should make a request to save model with id and return true without errors' do
|
138
|
-
subject.save.
|
139
|
-
subject.kalibro_errors.
|
138
|
+
expect(subject.save).to be(true)
|
139
|
+
expect(subject.kalibro_errors).to be_empty
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
@@ -160,14 +160,14 @@ describe KalibroGem::Entities::Model do
|
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'should instantiate and save the model' do
|
163
|
-
(KalibroGem::Entities::Model.create {}).
|
163
|
+
expect(KalibroGem::Entities::Model.create {}).to eq(subject)
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
167
|
describe '==' do
|
168
168
|
context 'comparing objects from different classes' do
|
169
169
|
it 'should return false' do
|
170
|
-
subject.
|
170
|
+
expect(subject).not_to eq(Object.new)
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
@@ -180,13 +180,13 @@ describe KalibroGem::Entities::Model do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
it 'should return false' do
|
183
|
-
subject.
|
183
|
+
expect(subject).not_to eq(another_model)
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
187
|
context 'with two empty models' do
|
188
188
|
it 'should return true' do
|
189
|
-
subject.
|
189
|
+
expect(subject).to eq(FactoryGirl.build(:model))
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
@@ -201,7 +201,7 @@ describe KalibroGem::Entities::Model do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
it 'should return false' do
|
204
|
-
KalibroGem::Entities::Model.exists?(0).
|
204
|
+
expect(KalibroGem::Entities::Model.exists?(0)).to eq(false)
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
@@ -214,7 +214,7 @@ describe KalibroGem::Entities::Model do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'should return false' do
|
217
|
-
KalibroGem::Entities::Model.exists?(42).
|
217
|
+
expect(KalibroGem::Entities::Model.exists?(42)).to eq(true)
|
218
218
|
end
|
219
219
|
end
|
220
220
|
end
|
@@ -241,7 +241,7 @@ describe KalibroGem::Entities::Model do
|
|
241
241
|
end
|
242
242
|
|
243
243
|
it 'should return an empty model' do
|
244
|
-
KalibroGem::Entities::Model.find(42).
|
244
|
+
expect(KalibroGem::Entities::Model.find(42)).to eq(subject)
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
@@ -257,7 +257,7 @@ describe KalibroGem::Entities::Model do
|
|
257
257
|
|
258
258
|
it 'should remain with the errors array empty' do
|
259
259
|
subject.destroy
|
260
|
-
subject.kalibro_errors.
|
260
|
+
expect(subject.kalibro_errors).to be_empty
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
@@ -272,7 +272,7 @@ describe KalibroGem::Entities::Model do
|
|
272
272
|
it "should have an exception inside it's errors" do
|
273
273
|
subject.destroy
|
274
274
|
|
275
|
-
subject.kalibro_errors[0].
|
275
|
+
expect(subject.kalibro_errors[0]).to be_an(Exception)
|
276
276
|
end
|
277
277
|
end
|
278
278
|
end
|
@@ -280,13 +280,13 @@ describe KalibroGem::Entities::Model do
|
|
280
280
|
describe 'create_objects_array_from_hash' do
|
281
281
|
context 'with nil' do
|
282
282
|
it 'should return an empty array' do
|
283
|
-
KalibroGem::Entities::Model.create_objects_array_from_hash(nil).
|
283
|
+
expect(KalibroGem::Entities::Model.create_objects_array_from_hash(nil)).to eq([])
|
284
284
|
end
|
285
285
|
end
|
286
286
|
|
287
287
|
context 'with a Hash' do
|
288
288
|
it 'should return the correspondent object to the given hash inside of an Array' do
|
289
|
-
KalibroGem::Entities::Model.create_objects_array_from_hash({}).
|
289
|
+
expect(KalibroGem::Entities::Model.create_objects_array_from_hash({})).to eq([subject])
|
290
290
|
end
|
291
291
|
end
|
292
292
|
end
|
@@ -295,7 +295,7 @@ describe KalibroGem::Entities::Model do
|
|
295
295
|
it 'should assign to kalibro_errors' do
|
296
296
|
subject.errors = "test"
|
297
297
|
|
298
|
-
subject.kalibro_errors.
|
298
|
+
expect(subject.kalibro_errors).to eq('test')
|
299
299
|
end
|
300
300
|
end
|
301
301
|
end
|
@@ -29,8 +29,8 @@ describe KalibroGem::Entities::ModuleResult do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should return a hash with module result' do
|
32
|
-
KalibroGem::Entities::ModuleResult.
|
33
|
-
find(subject.id).id.
|
32
|
+
expect(KalibroGem::Entities::ModuleResult.
|
33
|
+
find(subject.id).id).to eq(subject.id)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -61,7 +61,7 @@ describe KalibroGem::Entities::ModuleResult do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should return a list of a objects' do
|
64
|
-
subject.children.
|
64
|
+
expect(subject.children).to eq [subject]
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -77,13 +77,13 @@ describe KalibroGem::Entities::ModuleResult do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'should return its parent' do
|
80
|
-
subject.parents.
|
80
|
+
expect(subject.parents).to eq [root_module_result]
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
context 'when module result does not have a parent' do
|
85
85
|
it 'should return an empty list' do
|
86
|
-
root_module_result.parents.
|
86
|
+
expect(root_module_result.parents).to eq []
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -91,7 +91,7 @@ describe KalibroGem::Entities::ModuleResult do
|
|
91
91
|
describe 'id=' do
|
92
92
|
it 'should set the id attribute as integer' do
|
93
93
|
subject.id = "23"
|
94
|
-
subject.id.
|
94
|
+
expect(subject.id).to eq 23
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -100,21 +100,21 @@ describe KalibroGem::Entities::ModuleResult do
|
|
100
100
|
|
101
101
|
it 'should set the module attribute as a Module object' do
|
102
102
|
subject.module = another_module.to_hash
|
103
|
-
subject.module.
|
103
|
+
expect(subject.module).to eq another_module
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
describe 'grade=' do
|
108
108
|
it 'should set the grade attribute as float' do
|
109
109
|
subject.grade = "12.5"
|
110
|
-
subject.grade.
|
110
|
+
expect(subject.grade).to eq 12.5
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
describe 'parent_id=' do
|
115
115
|
it 'should set the parent_id attribute as integer' do
|
116
116
|
subject.parent_id = "73"
|
117
|
-
subject.parent_id.
|
117
|
+
expect(subject.parent_id).to eq 73
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -129,7 +129,7 @@ describe KalibroGem::Entities::ModuleResult do
|
|
129
129
|
|
130
130
|
it 'should return a list of date_module_results' do
|
131
131
|
date_module_results = KalibroGem::Entities::ModuleResult.history_of subject.id
|
132
|
-
date_module_results.first.result.
|
132
|
+
expect(date_module_results.first.result).to eq date_module_result.result
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
@@ -142,8 +142,8 @@ describe KalibroGem::Entities::ModuleResult do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
it 'should return true for folder? and false for file?' do
|
145
|
-
subject.folder
|
146
|
-
subject.file
|
145
|
+
expect(subject.folder?).to be_truthy
|
146
|
+
expect(subject.file?).to be_falsey
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
@@ -155,8 +155,8 @@ describe KalibroGem::Entities::ModuleResult do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'should return true for folder? and false for file?' do
|
158
|
-
subject.folder
|
159
|
-
subject.file
|
158
|
+
expect(subject.folder?).to be_falsey
|
159
|
+
expect(subject.file?).to be_truthy
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|