kalibro_client 3.0.1 → 4.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/metric_collector_details/find_by_name.feature +12 -4
- data/features/step_definitions/metric_collector_details_steps.rb +11 -7
- data/features/step_definitions/metric_configuration_steps.rb +2 -2
- data/features/step_definitions/module_result_steps.rb +1 -1
- data/features/support/env.rb +0 -3
- data/kalibro_client.gemspec +1 -0
- data/lib/kalibro_client.rb +4 -39
- data/lib/kalibro_client/entities/base.rb +12 -207
- data/lib/kalibro_client/entities/configurations/base.rb +3 -3
- data/lib/kalibro_client/entities/configurations/kalibro_configuration.rb +0 -4
- data/lib/kalibro_client/entities/configurations/metric_configuration.rb +1 -19
- data/lib/kalibro_client/entities/configurations/reading_group.rb +1 -5
- data/lib/kalibro_client/entities/miscellaneous/base.rb +4 -2
- data/lib/kalibro_client/entities/miscellaneous/metric.rb +0 -2
- data/lib/kalibro_client/entities/processor/base.rb +3 -3
- data/lib/kalibro_client/entities/processor/hotspot_metric_result.rb +1 -1
- data/lib/kalibro_client/entities/processor/metric_collector_details.rb +19 -7
- data/lib/kalibro_client/entities/processor/module_result.rb +0 -13
- data/lib/kalibro_client/entities/processor/project.rb +0 -4
- data/lib/kalibro_client/entities/processor/repository.rb +0 -4
- data/lib/kalibro_client/entities/processor/tree_metric_result.rb +1 -1
- data/lib/kalibro_client/errors.rb +1 -4
- data/lib/kalibro_client/kalibro_cucumber_helpers.rb +7 -36
- data/lib/kalibro_client/kalibro_cucumber_helpers/cleaner.rb +27 -0
- data/lib/kalibro_client/version.rb +1 -1
- data/spec/entities/base_spec.rb +17 -449
- data/spec/entities/configurations/kalibro_configuration_spec.rb +0 -35
- data/spec/entities/configurations/kalibro_range_spec.rb +3 -3
- data/spec/entities/configurations/metric_configuration_spec.rb +1 -58
- data/spec/entities/configurations/reading_group_spec.rb +0 -32
- data/spec/entities/configurations/reading_spec.rb +3 -3
- data/spec/entities/processor/metric_collector_details_spec.rb +46 -25
- data/spec/entities/processor/module_result_spec.rb +0 -41
- data/spec/entities/processor/project_spec.rb +1 -35
- data/spec/entities/processor/repository_spec.rb +1 -14
- data/spec/{savon/fixtures → fixtures}/config.yml +0 -0
- data/spec/{savon/fixtures → fixtures}/invalid_config.yml +0 -0
- data/spec/kalibro_cucumber_helpers/cleaner_spec.rb +32 -0
- metadata +26 -32
- data/lib/kalibro_client/errors/record_invalid.rb +0 -19
- data/lib/kalibro_client/errors/record_not_found.rb +0 -22
- data/lib/kalibro_client/errors/request_error.rb +0 -27
- data/lib/kalibro_client/errors/standard.rb +0 -24
- data/lib/kalibro_client/helpers/date_attributes.rb +0 -11
- data/lib/kalibro_client/helpers/hash_converters.rb +0 -48
- data/lib/kalibro_client/helpers/request_methods.rb +0 -64
- data/lib/kalibro_client/helpers/xml_converters.rb +0 -20
- data/lib/kalibro_client/kalibro_cucumber_helpers/configuration.rb +0 -30
- data/spec/errors/record_invalid_spec.rb +0 -45
- data/spec/helpers/date_attributes_spec.rb +0 -30
- data/spec/helpers/hash_converters_spec.rb +0 -120
- data/spec/helpers/xml_converters_spec.rb +0 -64
- data/spec/kalibro_entities_spec.rb +0 -112
- data/spec/savon/fixtures/project/does_not_exists.xml +0 -1
- data/spec/savon/savon_test_helper.rb +0 -14
@@ -24,41 +24,6 @@ describe KalibroClient::Entities::Configurations::KalibroConfiguration do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe 'all' do
|
28
|
-
context 'with no configurations' do
|
29
|
-
before :each do
|
30
|
-
KalibroClient::Entities::Configurations::KalibroConfiguration.
|
31
|
-
expects(:request).
|
32
|
-
with('', {}, :get).
|
33
|
-
returns({'kalibro_configurations' => []})
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'is expected to return nil' do
|
37
|
-
expect(KalibroClient::Entities::Configurations::KalibroConfiguration.all).to be_empty
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'with many configurations' do
|
42
|
-
let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) }
|
43
|
-
let(:another_kalibro_configuration) { FactoryGirl.build(:another_kalibro_configuration) }
|
44
|
-
|
45
|
-
before :each do
|
46
|
-
KalibroClient::Entities::Configurations::KalibroConfiguration.
|
47
|
-
expects(:request).
|
48
|
-
with('', {}, :get).
|
49
|
-
returns({'kalibro_configurations' => [kalibro_configuration.to_hash, another_kalibro_configuration.to_hash]})
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'is expected to return the two elements' do
|
53
|
-
kalibro_configurations = KalibroClient::Entities::Configurations::KalibroConfiguration.all
|
54
|
-
|
55
|
-
expect(kalibro_configurations.size).to eq(2)
|
56
|
-
expect(kalibro_configurations.first.name).to eq(kalibro_configuration.name)
|
57
|
-
expect(kalibro_configurations.last.name).to eq(another_kalibro_configuration.name)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
27
|
describe 'metric_configurations' do
|
63
28
|
context 'with no metric configurations' do
|
64
29
|
before :each do
|
@@ -123,7 +123,7 @@ describe KalibroClient::Entities::Configurations::KalibroRange do
|
|
123
123
|
before :each do
|
124
124
|
KalibroClient::Entities::Configurations::KalibroRange.
|
125
125
|
expects(:request).
|
126
|
-
with('', {:kalibro_range => subject.to_hash, :metric_configuration_id => subject.metric_configuration_id}, :post, "metric_configurations/#{subject.metric_configuration_id}").
|
126
|
+
with('', {:kalibro_range => subject.to_hash, :metric_configuration_id => subject.metric_configuration_id}, :post, "metric_configurations/#{subject.metric_configuration_id}", {}).
|
127
127
|
returns("kalibro_range" => { 'id' => 2, 'kalibro_errors' => []})
|
128
128
|
end
|
129
129
|
|
@@ -140,7 +140,7 @@ describe KalibroClient::Entities::Configurations::KalibroRange do
|
|
140
140
|
before :each do
|
141
141
|
KalibroClient::Entities::Configurations::KalibroRange.
|
142
142
|
expects(:request).
|
143
|
-
with(":id", {id: subject.id}, :delete, "metric_configurations/#{subject.metric_configuration_id}").returns({})
|
143
|
+
with(":id", {id: subject.id}, :delete, "metric_configurations/#{subject.metric_configuration_id}", {}).returns({})
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'should make a request to destroy' do
|
@@ -156,7 +156,7 @@ describe KalibroClient::Entities::Configurations::KalibroRange do
|
|
156
156
|
subject.end = "555"
|
157
157
|
KalibroClient::Entities::Configurations::KalibroRange.
|
158
158
|
expects(:request).
|
159
|
-
with(':id', {:kalibro_range => subject.to_hash, :id => subject.id}, :put, "metric_configurations/#{subject.metric_configuration_id}").
|
159
|
+
with(':id', {:kalibro_range => subject.to_hash, :id => subject.id}, :put, "metric_configurations/#{subject.metric_configuration_id}", {}).
|
160
160
|
returns("errors" => nil)
|
161
161
|
end
|
162
162
|
|
@@ -159,7 +159,7 @@ describe KalibroClient::Entities::Configurations::MetricConfiguration do
|
|
159
159
|
before :each do
|
160
160
|
KalibroClient::Entities::Configurations::MetricConfiguration.
|
161
161
|
expects(:request).
|
162
|
-
with('', {:metric_configuration => subject.to_hash, :kalibro_configuration_id => subject.kalibro_configuration_id}, :post, '').
|
162
|
+
with('', {:metric_configuration => subject.to_hash, :kalibro_configuration_id => subject.kalibro_configuration_id}, :post, '', {}).
|
163
163
|
returns("metric_configuration" => {'id' => 1, 'kalibro_errors' => []})
|
164
164
|
end
|
165
165
|
|
@@ -169,63 +169,6 @@ describe KalibroClient::Entities::Configurations::MetricConfiguration do
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
-
describe 'exists?' do
|
173
|
-
subject {FactoryGirl.build(:metric_configuration_with_id)}
|
174
|
-
|
175
|
-
context 'when the metric configuration exists' do
|
176
|
-
before :each do
|
177
|
-
KalibroClient::Entities::Configurations::MetricConfiguration.expects(:find).with(subject.id).returns(subject)
|
178
|
-
end
|
179
|
-
|
180
|
-
it 'should return true' do
|
181
|
-
expect(KalibroClient::Entities::Configurations::MetricConfiguration.exists?(subject.id)).to be_truthy
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
context 'when the metric configuration does not exist' do
|
186
|
-
before :each do
|
187
|
-
KalibroClient::Entities::Configurations::MetricConfiguration.expects(:find).with(subject.id).raises(KalibroClient::Errors::RecordNotFound)
|
188
|
-
end
|
189
|
-
|
190
|
-
it 'should return false' do
|
191
|
-
expect(KalibroClient::Entities::Configurations::MetricConfiguration.exists?(subject.id)).to be_falsey
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
describe 'find' do
|
197
|
-
let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
|
198
|
-
|
199
|
-
context 'with an existant MetricConfiguration' do
|
200
|
-
before :each do
|
201
|
-
KalibroClient::Entities::Configurations::MetricConfiguration.
|
202
|
-
expects(:request).
|
203
|
-
with(':id', {id: metric_configuration.id}, :get).
|
204
|
-
returns({'metric_configuration' => metric_configuration.to_hash})
|
205
|
-
end
|
206
|
-
|
207
|
-
it 'should return the metric_configuration' do
|
208
|
-
found_metric_configuration = KalibroClient::Entities::Configurations::MetricConfiguration.find(metric_configuration.id)
|
209
|
-
expect(found_metric_configuration.id).to eq(metric_configuration.id)
|
210
|
-
expect(found_metric_configuration.persisted).to be_truthy
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
context 'with an inexistant MetricConfiguration' do
|
215
|
-
before :each do
|
216
|
-
KalibroClient::Entities::Configurations::MetricConfiguration.
|
217
|
-
expects(:request).
|
218
|
-
with(':id', {id: metric_configuration.id}, :get).
|
219
|
-
raises(KalibroClient::Errors::RequestError)
|
220
|
-
end
|
221
|
-
|
222
|
-
it 'should raise the RecordNotFound error' do
|
223
|
-
expect {KalibroClient::Entities::Configurations::MetricConfiguration.find(metric_configuration.id)}.
|
224
|
-
to raise_error(KalibroClient::Errors::RecordNotFound)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
172
|
describe 'kalibro ranges' do
|
230
173
|
let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
|
231
174
|
let(:kalibro_range_1) { FactoryGirl.build(:range, metric_configuration_id: metric_configuration.id) }
|
@@ -26,38 +26,6 @@ describe KalibroClient::Entities::Configurations::ReadingGroup do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe 'all' do
|
30
|
-
context 'with no reading_groups' do
|
31
|
-
before :each do
|
32
|
-
KalibroClient::Entities::Configurations::ReadingGroup.
|
33
|
-
expects(:request).
|
34
|
-
with('', {}, :get).
|
35
|
-
returns({'reading_groups' => []})
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should return nil' do
|
39
|
-
expect(KalibroClient::Entities::Configurations::ReadingGroup.all).to be_empty
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with many reading_groups' do
|
44
|
-
let(:reading_group) { FactoryGirl.build(:reading_group_with_id) }
|
45
|
-
before :each do
|
46
|
-
KalibroClient::Entities::Configurations::ReadingGroup.
|
47
|
-
expects(:request).
|
48
|
-
with('', {}, :get).
|
49
|
-
returns({'reading_groups' => [reading_group.to_hash, reading_group.to_hash]})
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should return nil' do
|
53
|
-
reading_groups = KalibroClient::Entities::Configurations::ReadingGroup.all
|
54
|
-
|
55
|
-
expect(reading_groups.first.name).to eq(reading_group.name)
|
56
|
-
expect(reading_groups.last.name).to eq(reading_group.name)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
29
|
describe 'readings' do
|
62
30
|
let(:reading_group) { FactoryGirl.build(:reading_group_with_id) }
|
63
31
|
|
@@ -52,7 +52,7 @@ describe KalibroClient::Entities::Configurations::Reading do
|
|
52
52
|
before :each do
|
53
53
|
KalibroClient::Entities::Configurations::Reading.
|
54
54
|
expects(:request).
|
55
|
-
with('', {reading: reading.to_hash, reading_group_id: reading.reading_group_id}, :post, "reading_groups/#{reading.reading_group_id}").
|
55
|
+
with('', {reading: reading.to_hash, reading_group_id: reading.reading_group_id}, :post, "reading_groups/#{reading.reading_group_id}", {}).
|
56
56
|
returns("reading" => {'id' => reading_id, 'kalibro_errors' => []})
|
57
57
|
end
|
58
58
|
|
@@ -70,7 +70,7 @@ describe KalibroClient::Entities::Configurations::Reading do
|
|
70
70
|
before :each do
|
71
71
|
KalibroClient::Entities::Configurations::Reading.
|
72
72
|
expects(:request).
|
73
|
-
with(":id", {id: subject.id}, :delete, "reading_groups/#{subject.reading_group_id}").returns({})
|
73
|
+
with(":id", {id: subject.id}, :delete, "reading_groups/#{subject.reading_group_id}", {}).returns({})
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should make a request to destroy' do
|
@@ -85,7 +85,7 @@ describe KalibroClient::Entities::Configurations::Reading do
|
|
85
85
|
before :each do
|
86
86
|
KalibroClient::Entities::Configurations::Reading.
|
87
87
|
expects(:request).
|
88
|
-
with(":id", {reading: subject.to_hash, id: subject.id}, :put, "reading_groups/#{subject.reading_group_id}").returns({})
|
88
|
+
with(":id", {reading: subject.to_hash, id: subject.id}, :put, "reading_groups/#{subject.reading_group_id}", {}).returns({})
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should make a request to update' do
|
@@ -52,42 +52,37 @@ describe KalibroClient::Entities::Processor::MetricCollectorDetails do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe '
|
56
|
-
|
55
|
+
describe 'find_by_name' do
|
56
|
+
subject { FactoryGirl.build(:metric_collector_details) }
|
57
|
+
|
58
|
+
context 'with an inexistent name' do
|
57
59
|
before :each do
|
58
60
|
KalibroClient::Entities::Processor::MetricCollectorDetails.
|
59
|
-
expects(:
|
60
|
-
with(
|
61
|
-
|
61
|
+
expects(:find_by_name!).
|
62
|
+
with(subject.name).
|
63
|
+
raises(Likeno::Errors::RecordNotFound)
|
62
64
|
end
|
63
65
|
|
64
|
-
it '
|
65
|
-
expect(KalibroClient::Entities::Processor::MetricCollectorDetails.
|
66
|
+
it 'is expected to return nil' do
|
67
|
+
expect(KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(subject.name)).to be_nil
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
69
|
-
context 'with
|
70
|
-
let!(:metric_collector_details_hash) { FactoryGirl.attributes_for(:metric_collector_details) }
|
71
|
-
let!(:another_metric_collector_details_hash) { FactoryGirl.attributes_for(:another_metric_collector_details) }
|
72
|
-
|
71
|
+
context 'with an existent name' do
|
73
72
|
before :each do
|
74
73
|
KalibroClient::Entities::Processor::MetricCollectorDetails.
|
75
|
-
expects(:
|
76
|
-
with(
|
77
|
-
returns(
|
74
|
+
expects(:find_by_name!).
|
75
|
+
with(subject.name).
|
76
|
+
returns(subject)
|
78
77
|
end
|
79
78
|
|
80
|
-
it 'should return
|
81
|
-
|
82
|
-
|
83
|
-
expect(metric_collector_details.size).to eq(2)
|
84
|
-
expect(metric_collector_details.first.name).to eq(metric_collector_details_hash[:name])
|
85
|
-
expect(metric_collector_details.last.name).to eq(another_metric_collector_details_hash[:name])
|
79
|
+
it 'should return a metric_collector_details' do
|
80
|
+
expect(KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(subject.name).name).to eq(subject.name)
|
86
81
|
end
|
87
82
|
end
|
88
83
|
end
|
89
84
|
|
90
|
-
describe 'find_by_name' do
|
85
|
+
describe 'find_by_name!' do
|
91
86
|
subject { FactoryGirl.build(:metric_collector_details) }
|
92
87
|
|
93
88
|
context 'with an inexistent name' do
|
@@ -95,12 +90,12 @@ describe KalibroClient::Entities::Processor::MetricCollectorDetails do
|
|
95
90
|
KalibroClient::Entities::Processor::MetricCollectorDetails.
|
96
91
|
expects(:request).
|
97
92
|
with(:find, {name: subject.name}).
|
98
|
-
|
93
|
+
raises(Likeno::Errors::RecordNotFound)
|
99
94
|
end
|
100
95
|
|
101
96
|
it 'should raise a RecordNotFound error' do
|
102
|
-
expect { KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(subject.name)}.
|
103
|
-
to raise_error(
|
97
|
+
expect { KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name!(subject.name)}.
|
98
|
+
to raise_error(Likeno::Errors::RecordNotFound)
|
104
99
|
end
|
105
100
|
end
|
106
101
|
|
@@ -108,7 +103,7 @@ describe KalibroClient::Entities::Processor::MetricCollectorDetails do
|
|
108
103
|
before :each do
|
109
104
|
KalibroClient::Entities::Processor::MetricCollectorDetails.
|
110
105
|
expects(:request).
|
111
|
-
with(:find,{name: subject.name}).
|
106
|
+
with(:find, {name: subject.name}).
|
112
107
|
returns({"metric_collector_details" => subject.to_hash({except: ["supported_metrics"]})})
|
113
108
|
end
|
114
109
|
|
@@ -146,6 +141,19 @@ describe KalibroClient::Entities::Processor::MetricCollectorDetails do
|
|
146
141
|
end
|
147
142
|
end
|
148
143
|
|
144
|
+
describe 'find_metric_by_name!' do
|
145
|
+
subject { FactoryGirl.build(:metric_collector_details) }
|
146
|
+
let(:metric) { subject.supported_metrics["loc"] }
|
147
|
+
|
148
|
+
it 'should return nil with an inexistent name' do
|
149
|
+
expect { subject.find_metric_by_name!("fake name") }.to raise_error(Likeno::Errors::RecordNotFound)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'should return a metric with an existent name' do
|
153
|
+
expect(subject.find_metric_by_name!(metric.name)).to eq(metric)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
149
157
|
describe 'find_metric_by_code' do
|
150
158
|
subject { FactoryGirl.build(:metric_collector_details) }
|
151
159
|
let(:metric) { subject.supported_metrics["loc"] }
|
@@ -158,4 +166,17 @@ describe KalibroClient::Entities::Processor::MetricCollectorDetails do
|
|
158
166
|
expect(subject.find_metric_by_code(metric.code)).to eq(metric)
|
159
167
|
end
|
160
168
|
end
|
169
|
+
|
170
|
+
describe 'find_metric_by_code!' do
|
171
|
+
subject { FactoryGirl.build(:metric_collector_details) }
|
172
|
+
let(:metric) { subject.supported_metrics["loc"] }
|
173
|
+
|
174
|
+
it 'should return nil with an inexistent code' do
|
175
|
+
expect{subject.find_metric_by_code!("fake code")}.to raise_error(Likeno::Errors::RecordNotFound)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should return a metric with an existent code' do
|
179
|
+
expect(subject.find_metric_by_code!(metric.code)).to eq(metric)
|
180
|
+
end
|
181
|
+
end
|
161
182
|
end
|
@@ -223,45 +223,4 @@ describe KalibroClient::Entities::Processor::ModuleResult do
|
|
223
223
|
expect(subject.processing).to eq(processing)
|
224
224
|
end
|
225
225
|
end
|
226
|
-
|
227
|
-
describe 'find' do
|
228
|
-
let(:id) { 1 }
|
229
|
-
|
230
|
-
context 'when the ModuleResult exists' do
|
231
|
-
let!(:module_result) { FactoryGirl.build(:module_result) }
|
232
|
-
before :each do
|
233
|
-
KalibroClient::Entities::Base.expects(:find).with(id).returns(module_result)
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'is expected to return the found module result' do
|
237
|
-
expect(described_class.find(id)).to eq(module_result)
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
context 'when the ModuleResult does not exist' do
|
242
|
-
before :each do
|
243
|
-
response = mock('response')
|
244
|
-
response.expects(:status).at_least_once.returns(422)
|
245
|
-
|
246
|
-
KalibroClient::Entities::Base.expects(:find).with(id).raises(KalibroClient::Errors::RequestError.new(response: response))
|
247
|
-
end
|
248
|
-
|
249
|
-
it 'is expected to raise a RecordNotFound error' do
|
250
|
-
expect { described_class.find(id) }.to raise_error(KalibroClient::Errors::RecordNotFound)
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
context 'when there is an unexpected server error' do
|
255
|
-
before :each do
|
256
|
-
response = mock('response')
|
257
|
-
response.expects(:status).at_least_once.returns(500)
|
258
|
-
|
259
|
-
KalibroClient::Entities::Base.expects(:find).with(id).raises(KalibroClient::Errors::RequestError.new(response: response))
|
260
|
-
end
|
261
|
-
|
262
|
-
it 'is expected to raise a RequestError' do
|
263
|
-
expect { described_class.find(id) }.to raise_error(KalibroClient::Errors::RequestError)
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
226
|
end
|
@@ -31,40 +31,6 @@ describe KalibroClient::Entities::Processor::Project do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe 'all' do
|
35
|
-
context 'with no projects' do
|
36
|
-
before :each do
|
37
|
-
KalibroClient::Entities::Processor::Project.
|
38
|
-
expects(:request).
|
39
|
-
with('', {}, :get).
|
40
|
-
returns({"projects" => []})
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should return nil' do
|
44
|
-
expect(KalibroClient::Entities::Processor::Project.all).to be_empty
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'with many projects' do
|
49
|
-
let(:project) { FactoryGirl.build(:project) }
|
50
|
-
let(:another_project) { FactoryGirl.build(:another_project) }
|
51
|
-
|
52
|
-
before :each do
|
53
|
-
KalibroClient::Entities::Processor::Project.
|
54
|
-
expects(:request).
|
55
|
-
with('', {}, :get).
|
56
|
-
returns({"projects" => [project.to_hash, another_project.to_hash]})
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should return a list with projects' do
|
60
|
-
projects = KalibroClient::Entities::Processor::Project.all
|
61
|
-
|
62
|
-
expect(projects.first.name).to eq(project.name)
|
63
|
-
expect(projects.last.name).to eq(another_project.name)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
34
|
describe 'repositories' do
|
69
35
|
let(:project) { FactoryGirl.build(:project) }
|
70
36
|
let(:repository) { FactoryGirl.build(:repository) }
|
@@ -102,7 +68,7 @@ describe KalibroClient::Entities::Processor::Project do
|
|
102
68
|
before :each do
|
103
69
|
KalibroClient::Entities::Processor::Project.
|
104
70
|
expects(:request).
|
105
|
-
with(':id', {project: {"name" => "Another Name", "description" => subject.description, "id" => subject.id.to_s}, id: subject.id}, :put, '').
|
71
|
+
with(':id', {project: {"name" => "Another Name", "description" => subject.description, "id" => subject.id.to_s}, id: subject.id}, :put, '', {}).
|
106
72
|
returns({"project" => {"id" => subject.id, "name" => "Another Name", "kalibro_errors" => []}})
|
107
73
|
end
|
108
74
|
|
@@ -99,19 +99,6 @@ describe KalibroClient::Entities::Processor::Repository do
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
describe 'all' do
|
103
|
-
before :each do
|
104
|
-
KalibroClient::Entities::Processor::Repository.
|
105
|
-
expects(:request).
|
106
|
-
with("", {}, :get).
|
107
|
-
returns({'repositories' => [subject.to_hash]})
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should list all the repositories' do
|
111
|
-
expect(KalibroClient::Entities::Processor::Repository.all).to include(subject)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
102
|
# The only purpose of this test is to cover the overrided save_params method
|
116
103
|
describe 'save' do
|
117
104
|
subject {FactoryGirl.build(:repository)}
|
@@ -119,7 +106,7 @@ describe KalibroClient::Entities::Processor::Repository do
|
|
119
106
|
before :each do
|
120
107
|
KalibroClient::Entities::Processor::Repository.
|
121
108
|
expects(:request).
|
122
|
-
with('', {:repository => subject.to_hash, :project_id => 1}, :post, '').
|
109
|
+
with('', {:repository => subject.to_hash, :project_id => 1}, :post, '', {}).
|
123
110
|
returns("repository" => {'id' => 1, 'kalibro_errors' => []})
|
124
111
|
|
125
112
|
KalibroClient::Entities::Processor::Repository.any_instance.
|