kalibro_gem 0.0.1.rc7
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/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +21 -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/ranges_of.feature +22 -0
- data/features/range/save.feature +32 -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 +41 -0
- data/features/step_definitions/reading_group_steps.rb +19 -0
- data/features/step_definitions/reading_steps.rb +20 -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_gem.gemspec +48 -0
- data/lib/kalibro_gem.rb +61 -0
- data/lib/kalibro_gem/entities.rb +37 -0
- data/lib/kalibro_gem/entities/base_tool.rb +54 -0
- data/lib/kalibro_gem/entities/configuration.rb +33 -0
- data/lib/kalibro_gem/entities/date_metric_result.rb +39 -0
- data/lib/kalibro_gem/entities/date_module_result.rb +39 -0
- data/lib/kalibro_gem/entities/metric.rb +21 -0
- data/lib/kalibro_gem/entities/metric_configuration.rb +70 -0
- data/lib/kalibro_gem/entities/metric_configuration_snapshot.rb +57 -0
- data/lib/kalibro_gem/entities/metric_result.rb +74 -0
- data/lib/kalibro_gem/entities/model.rb +162 -0
- data/lib/kalibro_gem/entities/module.rb +27 -0
- data/lib/kalibro_gem/entities/module_result.rb +77 -0
- data/lib/kalibro_gem/entities/process_time.rb +31 -0
- data/lib/kalibro_gem/entities/processing.rb +113 -0
- data/lib/kalibro_gem/entities/project.rb +34 -0
- data/lib/kalibro_gem/entities/range.rb +75 -0
- data/lib/kalibro_gem/entities/range_snapshot.rb +37 -0
- data/lib/kalibro_gem/entities/reading.rb +51 -0
- data/lib/kalibro_gem/entities/reading_group.rb +43 -0
- data/lib/kalibro_gem/entities/repository.rb +86 -0
- data/lib/kalibro_gem/entities/repository_observer.rb +50 -0
- data/lib/kalibro_gem/entities/stack_trace_element.rb +31 -0
- data/lib/kalibro_gem/entities/throwable.rb +42 -0
- data/lib/kalibro_gem/errors.rb +18 -0
- data/lib/kalibro_gem/errors/record_not_found.rb +22 -0
- data/lib/kalibro_gem/errors/standard.rb +24 -0
- data/lib/kalibro_gem/helpers/aggregation_options.rb +25 -0
- data/lib/kalibro_gem/helpers/hash_converters.rb +48 -0
- data/lib/kalibro_gem/helpers/request_methods.rb +47 -0
- data/lib/kalibro_gem/helpers/xml_converters.rb +20 -0
- data/lib/kalibro_gem/kalibro_cucumber_helpers.rb +40 -0
- data/lib/kalibro_gem/kalibro_cucumber_helpers/configuration.rb +39 -0
- data/lib/kalibro_gem/kalibro_cucumber_helpers/hooks.rb +50 -0
- data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/delete_all_kalibro_entries.sh +23 -0
- data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/prepare_kalibro_query_file.sh +38 -0
- data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/put_kalibro_on_test_mode.sh +35 -0
- data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/return_kalibro_from_test_mode.sh +26 -0
- data/lib/kalibro_gem/version.rb +19 -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 +149 -0
- data/spec/entities/metric_result_spec.rb +201 -0
- data/spec/entities/metric_spec.rb +47 -0
- data/spec/entities/model_spec.rb +275 -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 +181 -0
- data/spec/entities/reading_group_spec.rb +90 -0
- data/spec/entities/reading_spec.rb +106 -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 +30 -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 +60 -0
- metadata +463 -0
@@ -0,0 +1,181 @@
|
|
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::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
|
+
subject { FactoryGirl.build(:range) }
|
62
|
+
let(:reading) { FactoryGirl.build(:reading) }
|
63
|
+
|
64
|
+
before :each do
|
65
|
+
KalibroGem::Entities::Reading.
|
66
|
+
expects(:find).
|
67
|
+
with(subject.reading_id).
|
68
|
+
returns(reading)
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'label' do
|
72
|
+
it 'should get the label of the reading' do
|
73
|
+
subject.label.should eq(reading.label)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'grade' do
|
78
|
+
it 'should get the grade of the reading' do
|
79
|
+
subject.grade.should eq(reading.grade)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'color' do
|
84
|
+
it 'should get the color of the reading' do
|
85
|
+
subject.color.should eq(reading.color)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'ranges_of' do
|
91
|
+
let(:metric_configuration) { FactoryGirl.build(:metric_configuration) }
|
92
|
+
|
93
|
+
context 'when does not exists the asked range' do
|
94
|
+
before :each do
|
95
|
+
KalibroGem::Entities::Range.
|
96
|
+
expects(:request).
|
97
|
+
with(:ranges_of, {metric_configuration_id: metric_configuration.id}).
|
98
|
+
returns({range: nil})
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should return a list with the ranges' do
|
102
|
+
KalibroGem::Entities::Range.ranges_of(metric_configuration.id).should eq([])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when exist only one range for the given metric configuration' do
|
107
|
+
before :each do
|
108
|
+
KalibroGem::Entities::Range.
|
109
|
+
expects(:request).
|
110
|
+
with(:ranges_of, {metric_configuration_id: metric_configuration.id}).
|
111
|
+
returns({range: subject.to_hash})
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should return a list with the range' do
|
115
|
+
KalibroGem::Entities::Range.ranges_of(metric_configuration.id).
|
116
|
+
first.beginning.should eq(subject.beginning)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'when exists many ranges for the given metric configuration' do
|
121
|
+
let(:another_range) { FactoryGirl.build(:another_range) }
|
122
|
+
|
123
|
+
before :each do
|
124
|
+
KalibroGem::Entities::Range.
|
125
|
+
expects(:request).
|
126
|
+
with(:ranges_of, {metric_configuration_id: metric_configuration.id}).
|
127
|
+
returns({range: [subject.to_hash, another_range.to_hash]})
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should return a list with the ranges' do
|
131
|
+
ranges = KalibroGem::Entities::Range.ranges_of(metric_configuration.id)
|
132
|
+
ranges.first.comments.should eq(subject.comments)
|
133
|
+
ranges.last.comments.should eq(another_range.comments)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe 'save' do
|
139
|
+
let(:metric_configuration) { FactoryGirl.build(:metric_configuration) }
|
140
|
+
|
141
|
+
context 'when kalibro does not save' do
|
142
|
+
before :each do
|
143
|
+
any_error_message = ""
|
144
|
+
any_code = rand(Time.now.to_i)
|
145
|
+
|
146
|
+
KalibroGem::Entities::Range.
|
147
|
+
expects(:request).
|
148
|
+
with(:save_range, {:range => subject.to_hash, :metric_configuration_id => metric_configuration.id}).
|
149
|
+
raises(Savon::SOAPFault.new(any_error_message, any_code))
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'should returns false' do
|
153
|
+
subject.save(metric_configuration.id).should eq(false)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should set the error on kalibro_errors attribute' do
|
157
|
+
subject.save(metric_configuration.id)
|
158
|
+
subject.kalibro_errors.should_not eq([])
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'when kalibro saves the range' do
|
163
|
+
let(:new_id) { rand(Time.now.to_i) }
|
164
|
+
before :each do
|
165
|
+
KalibroGem::Entities::Range.
|
166
|
+
expects(:request).
|
167
|
+
with(:save_range, {:range => subject.to_hash, :metric_configuration_id => metric_configuration.id}).
|
168
|
+
returns({range_id: new_id})
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should returns true' do
|
172
|
+
subject.save(metric_configuration.id).should eq(true)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should set the id attribute' do
|
176
|
+
subject.save(metric_configuration.id)
|
177
|
+
subject.id.should eq(new_id)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -0,0 +1,90 @@
|
|
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::ReadingGroup do
|
20
|
+
describe "id=" do
|
21
|
+
subject { FactoryGirl.build(:reading_group) }
|
22
|
+
|
23
|
+
it 'should set the id attribute values as an integer' do
|
24
|
+
subject.id = "222"
|
25
|
+
subject.id.should eq(222)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'all' do
|
30
|
+
context 'with no reading_groups' do
|
31
|
+
before :each do
|
32
|
+
KalibroGem::Entities::ReadingGroup.
|
33
|
+
expects(:request).
|
34
|
+
with(:all_reading_groups).
|
35
|
+
returns({:reading_group => nil})
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should return nil' do
|
39
|
+
KalibroGem::Entities::ReadingGroup.all.should be_empty
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with many reading_groups' do
|
44
|
+
let(:reading_group) { FactoryGirl.build(:reading_group) }
|
45
|
+
before :each do
|
46
|
+
KalibroGem::Entities::ReadingGroup.
|
47
|
+
expects(:request).
|
48
|
+
with(:all_reading_groups).
|
49
|
+
returns({:reading_group => [reading_group.to_hash, reading_group.to_hash]})
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should return nil' do
|
53
|
+
reading_groups = KalibroGem::Entities::ReadingGroup.all
|
54
|
+
|
55
|
+
reading_groups.first.name.should eq(reading_group.name)
|
56
|
+
reading_groups.last.name.should eq(reading_group.name)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# The only purpose of this test is to cover the overrided destroy_params private method
|
62
|
+
describe 'destroy' do
|
63
|
+
context 'when it gets successfully destroyed' do
|
64
|
+
before :each do
|
65
|
+
subject.expects(:id).at_least_once.returns(42)
|
66
|
+
KalibroGem::Entities::ReadingGroup.
|
67
|
+
expects(:request).
|
68
|
+
with(:delete_reading_group,{:group_id => subject.id})
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should remain with the errors array empty' do
|
72
|
+
subject.destroy
|
73
|
+
subject.kalibro_errors.should be_empty
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# The only purpose of this test is to cover the overrided id_params private method
|
79
|
+
describe 'exists?' do
|
80
|
+
context 'with an inexistent id' do
|
81
|
+
it 'should return false' do
|
82
|
+
KalibroGem::Entities::ReadingGroup.
|
83
|
+
expects(:request).
|
84
|
+
with(:reading_group_exists,{:group_id=>0}).
|
85
|
+
returns({:exists => false})
|
86
|
+
KalibroGem::Entities::ReadingGroup.exists?(0)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,106 @@
|
|
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::Reading do
|
20
|
+
describe "id=" do
|
21
|
+
it 'should set the id attribute as an integer' do
|
22
|
+
subject.id = "44"
|
23
|
+
subject.id.should 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
|
+
subject.grade.should eq(44.7)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'static methods' do
|
35
|
+
let(:reading) { FactoryGirl.build(:reading) }
|
36
|
+
|
37
|
+
describe 'find' do
|
38
|
+
context 'when the reading exists' do
|
39
|
+
before :each do
|
40
|
+
KalibroGem::Entities::Reading.
|
41
|
+
expects(:request).
|
42
|
+
with(:get_reading, {:reading_id => reading.id}).
|
43
|
+
returns({:reading => reading.to_hash})
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should return a reading object' do
|
47
|
+
response = KalibroGem::Entities::Reading.find reading.id
|
48
|
+
response.label.should eq(reading.label)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when the reading doesn't exists" do
|
53
|
+
before :each do
|
54
|
+
any_code = rand(Time.now.to_i)
|
55
|
+
any_error_message = ""
|
56
|
+
|
57
|
+
KalibroGem::Entities::Reading.
|
58
|
+
expects(:request).
|
59
|
+
with(:get_reading, {:reading_id => reading.id}).
|
60
|
+
raises(Savon::SOAPFault.new(any_error_message, any_code))
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should return a reading object' do
|
64
|
+
expect {KalibroGem::Entities::Reading.find(reading.id) }.
|
65
|
+
to raise_error(KalibroGem::Errors::RecordNotFound)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'readings_of' do
|
71
|
+
let(:reading_group) { FactoryGirl.build(:reading_group) }
|
72
|
+
|
73
|
+
before do
|
74
|
+
KalibroGem::Entities::Reading.
|
75
|
+
expects(:request).
|
76
|
+
with(:readings_of, {:group_id => reading_group.id}).
|
77
|
+
returns({:reading => [reading.to_hash, reading.to_hash]})
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should returns a list of readings that belongs to the given reading group' do
|
81
|
+
response = KalibroGem::Entities::Reading.readings_of reading_group.id
|
82
|
+
response.first.label.should eq(reading.label)
|
83
|
+
response.last.label.should eq(reading.label)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# The only purpose of this test is to cover the overrided save_params method
|
89
|
+
describe 'save' do
|
90
|
+
let(:reading) { FactoryGirl.build(:reading, {id: nil, group_id: FactoryGirl.build(:reading_group).id}) }
|
91
|
+
let(:reading_id) { 73 }
|
92
|
+
|
93
|
+
before :each do
|
94
|
+
KalibroGem::Entities::Reading.
|
95
|
+
expects(:request).
|
96
|
+
with(:save_reading, {reading: reading.to_hash, group_id: reading.group_id}).
|
97
|
+
returns({:reading_id => reading_id})
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should make a request to save model with id and return true without errors' do
|
101
|
+
reading.save.should be(true)
|
102
|
+
reading.id.should eq(reading_id)
|
103
|
+
reading.kalibro_errors.should be_empty
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,123 @@
|
|
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::RepositoryObserver do
|
20
|
+
describe 'id=' do
|
21
|
+
it 'should set the value of the attribute id' do
|
22
|
+
subject.id = 42
|
23
|
+
subject.id.should eq(42)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'all' do
|
28
|
+
context 'with no repository observers' do
|
29
|
+
before :each do
|
30
|
+
KalibroGem::Entities::RepositoryObserver.
|
31
|
+
expects(:request).
|
32
|
+
with(:all_repository_observers).
|
33
|
+
returns({:repository_observer => nil})
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should return nil' do
|
37
|
+
KalibroGem::Entities::RepositoryObserver.all.should be_empty
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with many repository observers' do
|
42
|
+
let(:repository_observer) { FactoryGirl.build(:repository_observer) }
|
43
|
+
before :each do
|
44
|
+
KalibroGem::Entities::RepositoryObserver.
|
45
|
+
expects(:request).
|
46
|
+
with(:all_repository_observers).
|
47
|
+
returns({:repository_observer => [repository_observer.to_hash, repository_observer.to_hash]})
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should return the two elements' do
|
51
|
+
repository_observers = KalibroGem::Entities::RepositoryObserver.all
|
52
|
+
repository_observers.size.should eq(2)
|
53
|
+
repository_observers.first.name.should eq(repository_observer.to_hash[:name])
|
54
|
+
repository_observers.last.name.should eq(repository_observer.to_hash[:name])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# FIXME: the index of the second parameter of the request of repository_observers of will be altered someday.
|
60
|
+
describe 'repository_observers_of' do
|
61
|
+
context 'with no repository observers' do
|
62
|
+
let(:repository_without_observers) { FactoryGirl.build(:repository).to_hash }
|
63
|
+
before :each do
|
64
|
+
KalibroGem::Entities::RepositoryObserver.expects(:request).
|
65
|
+
with(:repository_observers_of, {:repository_observer_id => repository_without_observers[:id]}).
|
66
|
+
returns({:repository_observer => []})
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should get an empty array' do
|
70
|
+
KalibroGem::Entities::RepositoryObserver.
|
71
|
+
repository_observers_of(repository_without_observers[:id]).should eq []
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with many repository observers' do
|
76
|
+
let(:repository) { FactoryGirl.build(:repository) }
|
77
|
+
let(:repository_observer) { FactoryGirl.build(:repository_observer) }
|
78
|
+
|
79
|
+
before :each do
|
80
|
+
KalibroGem::Entities::RepositoryObserver.expects(:request).
|
81
|
+
with(:repository_observers_of, {:repository_observer_id => repository.id}).
|
82
|
+
returns({:repository_observer => [repository_observer.to_hash, repository_observer.to_hash]})
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should return the two elements' do
|
86
|
+
repository_observers = KalibroGem::Entities::RepositoryObserver.
|
87
|
+
repository_observers_of(repository.id)
|
88
|
+
|
89
|
+
repository_observers.size.should eq(2)
|
90
|
+
repository_observers.first.name.should eq(repository_observer.name)
|
91
|
+
repository_observers.last.name.should eq(repository_observer.name)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'id=' do
|
97
|
+
it 'should set the value of the attribute id' do
|
98
|
+
subject.id = 65
|
99
|
+
subject.id.should eq(65)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe 'repository_id=' do
|
104
|
+
it 'should set the value of the attribute repository_id' do
|
105
|
+
subject.repository_id = 91
|
106
|
+
subject.repository_id.should eq(91)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'name=' do
|
111
|
+
it 'should set the value of the attribute name' do
|
112
|
+
subject.name = 'William'
|
113
|
+
subject.name.should eq('William')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'email=' do
|
118
|
+
it 'should set the value of the attribute email' do
|
119
|
+
subject.email = 'william@email.com'
|
120
|
+
subject.email.should eq('william@email.com')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|