kalibro_gem 0.0.1.rc7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +21 -0
  6. data/AUTHORS +4 -0
  7. data/COPYING +674 -0
  8. data/COPYING.LESSER +165 -0
  9. data/Gemfile +4 -0
  10. data/README.md +77 -0
  11. data/Rakefile +6 -0
  12. data/cucumber.yml +1 -0
  13. data/features/base_tool/all_names.feature +8 -0
  14. data/features/base_tool/find_by_name.feature +12 -0
  15. data/features/configuration/all.feature +10 -0
  16. data/features/metric_configuration/find.feature +18 -0
  17. data/features/metric_configuration/metric_configurations_of.feature +18 -0
  18. data/features/metric_result/descendant_results.feature +19 -0
  19. data/features/metric_result/history_of.feature +20 -0
  20. data/features/metric_result/metric_results_of.feature +19 -0
  21. data/features/module_result/children.feature +18 -0
  22. data/features/module_result/find.feature +15 -0
  23. data/features/module_result/history_of.feature +11 -0
  24. data/features/processing/first_processing_after.feature +18 -0
  25. data/features/processing/first_processing_of.feature +18 -0
  26. data/features/processing/has_processing.feature +18 -0
  27. data/features/processing/has_processing_after.feature +18 -0
  28. data/features/processing/has_processing_before.feature +18 -0
  29. data/features/processing/has_ready_processing.feature +18 -0
  30. data/features/processing/last_processing_before.feature +18 -0
  31. data/features/processing/last_processing_of.feature +18 -0
  32. data/features/processing/last_processing_state_of.feature +18 -0
  33. data/features/processing/last_ready_processing_of.feature +18 -0
  34. data/features/processing/processing_of.feature +32 -0
  35. data/features/processing/processing_with_date_of.feature +32 -0
  36. data/features/project/all.feature +10 -0
  37. data/features/project/creation.feature +9 -0
  38. data/features/project/destroy.feature +10 -0
  39. data/features/project/exists.feature +9 -0
  40. data/features/project/find.feature +10 -0
  41. data/features/range/ranges_of.feature +22 -0
  42. data/features/range/save.feature +32 -0
  43. data/features/reading/find.feature +11 -0
  44. data/features/reading/readings_of.feature +11 -0
  45. data/features/reading_group/all.feature +10 -0
  46. data/features/repository/all.feature +14 -0
  47. data/features/repository/cancel_processing.feature +14 -0
  48. data/features/repository/exists.feature +14 -0
  49. data/features/repository/find.feature +14 -0
  50. data/features/repository/of.feature +15 -0
  51. data/features/repository/process.feature +16 -0
  52. data/features/repository/types.feature +9 -0
  53. data/features/step_definitions/base_tool_steps.rb +28 -0
  54. data/features/step_definitions/configuration_steps.rb +11 -0
  55. data/features/step_definitions/metric_configuration_steps.rb +52 -0
  56. data/features/step_definitions/metric_result_steps.rb +29 -0
  57. data/features/step_definitions/metric_steps.rb +3 -0
  58. data/features/step_definitions/module_result_steps.rb +30 -0
  59. data/features/step_definitions/processing_steps.rb +91 -0
  60. data/features/step_definitions/project_steps.rb +48 -0
  61. data/features/step_definitions/range_steps.rb +41 -0
  62. data/features/step_definitions/reading_group_steps.rb +19 -0
  63. data/features/step_definitions/reading_steps.rb +20 -0
  64. data/features/step_definitions/repository_steps.rb +61 -0
  65. data/features/support/env.rb +25 -0
  66. data/features/support/kalibro_cucumber_helpers.yml.sample +10 -0
  67. data/kalibro_gem.gemspec +48 -0
  68. data/lib/kalibro_gem.rb +61 -0
  69. data/lib/kalibro_gem/entities.rb +37 -0
  70. data/lib/kalibro_gem/entities/base_tool.rb +54 -0
  71. data/lib/kalibro_gem/entities/configuration.rb +33 -0
  72. data/lib/kalibro_gem/entities/date_metric_result.rb +39 -0
  73. data/lib/kalibro_gem/entities/date_module_result.rb +39 -0
  74. data/lib/kalibro_gem/entities/metric.rb +21 -0
  75. data/lib/kalibro_gem/entities/metric_configuration.rb +70 -0
  76. data/lib/kalibro_gem/entities/metric_configuration_snapshot.rb +57 -0
  77. data/lib/kalibro_gem/entities/metric_result.rb +74 -0
  78. data/lib/kalibro_gem/entities/model.rb +162 -0
  79. data/lib/kalibro_gem/entities/module.rb +27 -0
  80. data/lib/kalibro_gem/entities/module_result.rb +77 -0
  81. data/lib/kalibro_gem/entities/process_time.rb +31 -0
  82. data/lib/kalibro_gem/entities/processing.rb +113 -0
  83. data/lib/kalibro_gem/entities/project.rb +34 -0
  84. data/lib/kalibro_gem/entities/range.rb +75 -0
  85. data/lib/kalibro_gem/entities/range_snapshot.rb +37 -0
  86. data/lib/kalibro_gem/entities/reading.rb +51 -0
  87. data/lib/kalibro_gem/entities/reading_group.rb +43 -0
  88. data/lib/kalibro_gem/entities/repository.rb +86 -0
  89. data/lib/kalibro_gem/entities/repository_observer.rb +50 -0
  90. data/lib/kalibro_gem/entities/stack_trace_element.rb +31 -0
  91. data/lib/kalibro_gem/entities/throwable.rb +42 -0
  92. data/lib/kalibro_gem/errors.rb +18 -0
  93. data/lib/kalibro_gem/errors/record_not_found.rb +22 -0
  94. data/lib/kalibro_gem/errors/standard.rb +24 -0
  95. data/lib/kalibro_gem/helpers/aggregation_options.rb +25 -0
  96. data/lib/kalibro_gem/helpers/hash_converters.rb +48 -0
  97. data/lib/kalibro_gem/helpers/request_methods.rb +47 -0
  98. data/lib/kalibro_gem/helpers/xml_converters.rb +20 -0
  99. data/lib/kalibro_gem/kalibro_cucumber_helpers.rb +40 -0
  100. data/lib/kalibro_gem/kalibro_cucumber_helpers/configuration.rb +39 -0
  101. data/lib/kalibro_gem/kalibro_cucumber_helpers/hooks.rb +50 -0
  102. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/delete_all_kalibro_entries.sh +23 -0
  103. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/prepare_kalibro_query_file.sh +38 -0
  104. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/put_kalibro_on_test_mode.sh +35 -0
  105. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/return_kalibro_from_test_mode.sh +26 -0
  106. data/lib/kalibro_gem/version.rb +19 -0
  107. data/lib/rake/test_task.rb +57 -0
  108. data/spec/entities/base_tool_spec.rb +168 -0
  109. data/spec/entities/configuration_spec.rb +61 -0
  110. data/spec/entities/date_metric_result_spec.rb +62 -0
  111. data/spec/entities/date_module_result_spec.rb +61 -0
  112. data/spec/entities/metric_configuration_snapshot_spec.rb +107 -0
  113. data/spec/entities/metric_configuration_spec.rb +149 -0
  114. data/spec/entities/metric_result_spec.rb +201 -0
  115. data/spec/entities/metric_spec.rb +47 -0
  116. data/spec/entities/model_spec.rb +275 -0
  117. data/spec/entities/module_result_spec.rb +163 -0
  118. data/spec/entities/process_time_spec.rb +33 -0
  119. data/spec/entities/processing_spec.rb +334 -0
  120. data/spec/entities/project_spec.rb +68 -0
  121. data/spec/entities/range_snapshot_spec.rb +50 -0
  122. data/spec/entities/range_spec.rb +181 -0
  123. data/spec/entities/reading_group_spec.rb +90 -0
  124. data/spec/entities/reading_spec.rb +106 -0
  125. data/spec/entities/repository_observer_spec.rb +123 -0
  126. data/spec/entities/repository_spec.rb +191 -0
  127. data/spec/entities/stack_trace_element_spec.rb +26 -0
  128. data/spec/entities/throwable_spec.rb +51 -0
  129. data/spec/factories/base_tools.rb +31 -0
  130. data/spec/factories/configurations.rb +29 -0
  131. data/spec/factories/date_metric_results.rb +28 -0
  132. data/spec/factories/date_module_results.rb +22 -0
  133. data/spec/factories/metric_configurations.rb +28 -0
  134. data/spec/factories/metric_configurations_snapshot.rb +26 -0
  135. data/spec/factories/metric_results.rb +24 -0
  136. data/spec/factories/metrics.rb +35 -0
  137. data/spec/factories/models.rb +20 -0
  138. data/spec/factories/module_results.rb +33 -0
  139. data/spec/factories/modules.rb +22 -0
  140. data/spec/factories/process_times.rb +27 -0
  141. data/spec/factories/processings.rb +25 -0
  142. data/spec/factories/projects.rb +29 -0
  143. data/spec/factories/ranges.rb +30 -0
  144. data/spec/factories/ranges_snapshot.rb +26 -0
  145. data/spec/factories/reading_groups.rb +23 -0
  146. data/spec/factories/readings.rb +25 -0
  147. data/spec/factories/repositories.rb +34 -0
  148. data/spec/factories/repository_observers.rb +24 -0
  149. data/spec/factories/stack_trace_elements.rb +24 -0
  150. data/spec/factories/throwables.rb +23 -0
  151. data/spec/helpers/aggregation_options_spec.rb +31 -0
  152. data/spec/helpers/hash_converters_spec.rb +111 -0
  153. data/spec/helpers/xml_converters_spec.rb +64 -0
  154. data/spec/kalibro_entities_spec.rb +108 -0
  155. data/spec/savon/fixtures/config.yml +1 -0
  156. data/spec/savon/fixtures/invalid_config.yml +2 -0
  157. data/spec/savon/fixtures/project/does_not_exists.xml +1 -0
  158. data/spec/savon/savon_test_helper.rb +14 -0
  159. data/spec/spec_helper.rb +60 -0
  160. metadata +463 -0
@@ -0,0 +1,33 @@
1
+ # This file is part of KalibroGem
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 KalibroGem::Entities::ProcessTime do
20
+ describe 'time=' do
21
+ subject {FactoryGirl.build(:process_time)}
22
+
23
+ it 'should set the time attribute to 6' do
24
+ subject.time = 6
25
+ subject.time.should eq 6
26
+ end
27
+
28
+ it 'should convert to integer' do
29
+ subject.time = "5"
30
+ subject.time.should eq 5
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,334 @@
1
+ # This file is part of KalibroGem
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 KalibroGem::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
+ KalibroGem::Entities::Processing.
87
+ expects(:request).once.
88
+ with(:has_processing, {:repository_id => repository.id}).
89
+ returns({exists: false})
90
+ end
91
+
92
+ it 'should convert the hash to a Boolean class' do
93
+ response = KalibroGem::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
+ KalibroGem::Entities::Processing.
101
+ expects(:request).once.
102
+ with(:has_ready_processing, {:repository_id => repository.id}).
103
+ returns({exists: false})
104
+ end
105
+
106
+ it 'should convert the hash to a Boolean class' do
107
+ response = KalibroGem::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
+ KalibroGem::Entities::Processing.
115
+ expects(:request).once.
116
+ with(:has_processing_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 = KalibroGem::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
+ KalibroGem::Entities::Processing.
129
+ expects(:request).once.
130
+ with(:has_processing_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 = KalibroGem::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
+ KalibroGem::Entities::Processing.
144
+ expects(:request).once.
145
+ with(:last_processing_state, {:repository_id => repository.id}).
146
+ returns({process_state: any_state})
147
+ end
148
+
149
+ it 'should return the state as string' do
150
+ response = KalibroGem::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
+ KalibroGem::Entities::Processing.
162
+ expects(:request).once.
163
+ with(:has_ready_processing, {:repository_id => repository.id}).
164
+ returns({exists: true})
165
+
166
+ KalibroGem::Entities::Processing.
167
+ expects(:request).once.
168
+ with(:last_ready_processing, {:repository_id => repository.id}).
169
+ returns({processing: processing.to_hash})
170
+ end
171
+
172
+ it 'should return the last ready processing' do
173
+ response = KalibroGem::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
+ KalibroGem::Entities::Processing.
181
+ expects(:request).once.
182
+ with(:has_ready_processing, {:repository_id => repository.id}).
183
+ returns({exists: false})
184
+
185
+ KalibroGem::Entities::Processing.
186
+ expects(:request).once.
187
+ with(:last_processing, {:repository_id => repository.id}).
188
+ returns({processing: processing.to_hash})
189
+ end
190
+
191
+ it 'should return the last processing' do
192
+ response = KalibroGem::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
+ KalibroGem::Entities::Processing.
202
+ expects(:request).once.
203
+ with(:has_processing_after, {:repository_id => repository.id, :date => date}).
204
+ returns({exists: true})
205
+
206
+ KalibroGem::Entities::Processing.
207
+ expects(:request).once.
208
+ with(:first_processing_after, {: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 = KalibroGem::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
+ KalibroGem::Entities::Processing.
221
+ expects(:request).once.
222
+ with(:has_processing_after, {:repository_id => repository.id, :date => date}).
223
+ returns({exists: false})
224
+
225
+ KalibroGem::Entities::Processing.
226
+ expects(:request).once.
227
+ with(:has_processing_before, {:repository_id => repository.id, :date => date}).
228
+ returns({exists: true})
229
+
230
+ KalibroGem::Entities::Processing.
231
+ expects(:request).once.
232
+ with(:last_processing_before, {: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 = KalibroGem::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
+ KalibroGem::Entities::Processing.
245
+ expects(:request).once.
246
+ with(:has_processing_after, {:repository_id => repository.id, :date => date}).
247
+ returns({exists: false})
248
+
249
+ KalibroGem::Entities::Processing.
250
+ expects(:request).once.
251
+ with(:has_processing_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 = KalibroGem::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
+ KalibroGem::Entities::Processing.
265
+ expects(:request).once.
266
+ with(:last_ready_processing, {:repository_id => repository.id}).
267
+ returns({processing: processing.to_hash})
268
+ end
269
+
270
+ it 'should return a processing object' do
271
+ response = KalibroGem::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
+ KalibroGem::Entities::Processing.
279
+ expects(:request).once.
280
+ with(:first_processing, {:repository_id => repository.id}).
281
+ returns({processing: processing.to_hash})
282
+ end
283
+
284
+ it 'should return a processing object' do
285
+ response = KalibroGem::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
+ KalibroGem::Entities::Processing.
293
+ expects(:request).once.
294
+ with(:last_processing, {:repository_id => repository.id}).
295
+ returns({processing: processing.to_hash})
296
+ end
297
+
298
+ it 'should return a processing object' do
299
+ response = KalibroGem::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
+ KalibroGem::Entities::Processing.
307
+ expects(:request).once.
308
+ with(:first_processing_after, {: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 = KalibroGem::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
+ KalibroGem::Entities::Processing.
321
+ expects(:request).once.
322
+ with(:last_processing_before, {: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 = KalibroGem::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 KalibroGem
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 KalibroGem::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
+ KalibroGem::Entities::Project.
39
+ expects(:request).
40
+ with(:all_projects).
41
+ returns({:project => nil})
42
+ end
43
+
44
+ it 'should return nil' do
45
+ KalibroGem::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
+ KalibroGem::Entities::Project.
55
+ expects(:request).
56
+ with(:all_projects).
57
+ returns({:project => [project.to_hash, another_project.to_hash]})
58
+ end
59
+
60
+ it 'should return a list with projects' do
61
+ projects = KalibroGem::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 KalibroGem
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 KalibroGem::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