kalibro_gatekeeper_client 0.0.1.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) 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 +29 -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/all.feature +14 -0
  42. data/features/range/exists.feature +13 -0
  43. data/features/range/find.feature +14 -0
  44. data/features/range/ranges_of.feature +22 -0
  45. data/features/range/save.feature +14 -0
  46. data/features/reading/all.feature +13 -0
  47. data/features/reading/exists.feature +13 -0
  48. data/features/reading/find.feature +11 -0
  49. data/features/reading/readings_of.feature +11 -0
  50. data/features/reading_group/all.feature +10 -0
  51. data/features/repository/all.feature +14 -0
  52. data/features/repository/cancel_processing.feature +14 -0
  53. data/features/repository/exists.feature +14 -0
  54. data/features/repository/find.feature +14 -0
  55. data/features/repository/of.feature +15 -0
  56. data/features/repository/process.feature +16 -0
  57. data/features/repository/types.feature +9 -0
  58. data/features/step_definitions/base_tool_steps.rb +28 -0
  59. data/features/step_definitions/configuration_steps.rb +11 -0
  60. data/features/step_definitions/metric_configuration_steps.rb +52 -0
  61. data/features/step_definitions/metric_result_steps.rb +29 -0
  62. data/features/step_definitions/metric_steps.rb +3 -0
  63. data/features/step_definitions/module_result_steps.rb +30 -0
  64. data/features/step_definitions/processing_steps.rb +91 -0
  65. data/features/step_definitions/project_steps.rb +48 -0
  66. data/features/step_definitions/range_steps.rb +68 -0
  67. data/features/step_definitions/reading_group_steps.rb +19 -0
  68. data/features/step_definitions/reading_steps.rb +39 -0
  69. data/features/step_definitions/repository_steps.rb +61 -0
  70. data/features/support/env.rb +25 -0
  71. data/features/support/kalibro_cucumber_helpers.yml.sample +10 -0
  72. data/kalibro_gatekeeper_client.gemspec +49 -0
  73. data/lib/kalibro_gatekeeper_client/entities/base_tool.rb +55 -0
  74. data/lib/kalibro_gatekeeper_client/entities/configuration.rb +34 -0
  75. data/lib/kalibro_gatekeeper_client/entities/date_metric_result.rb +39 -0
  76. data/lib/kalibro_gatekeeper_client/entities/date_module_result.rb +39 -0
  77. data/lib/kalibro_gatekeeper_client/entities/metric.rb +21 -0
  78. data/lib/kalibro_gatekeeper_client/entities/metric_configuration.rb +76 -0
  79. data/lib/kalibro_gatekeeper_client/entities/metric_configuration_snapshot.rb +57 -0
  80. data/lib/kalibro_gatekeeper_client/entities/metric_result.rb +72 -0
  81. data/lib/kalibro_gatekeeper_client/entities/model.rb +174 -0
  82. data/lib/kalibro_gatekeeper_client/entities/module.rb +27 -0
  83. data/lib/kalibro_gatekeeper_client/entities/module_result.rb +75 -0
  84. data/lib/kalibro_gatekeeper_client/entities/process_time.rb +31 -0
  85. data/lib/kalibro_gatekeeper_client/entities/processing.rb +113 -0
  86. data/lib/kalibro_gatekeeper_client/entities/project.rb +35 -0
  87. data/lib/kalibro_gatekeeper_client/entities/range.rb +100 -0
  88. data/lib/kalibro_gatekeeper_client/entities/range_snapshot.rb +37 -0
  89. data/lib/kalibro_gatekeeper_client/entities/reading.rb +67 -0
  90. data/lib/kalibro_gatekeeper_client/entities/reading_group.rb +44 -0
  91. data/lib/kalibro_gatekeeper_client/entities/repository.rb +89 -0
  92. data/lib/kalibro_gatekeeper_client/entities/repository_observer.rb +50 -0
  93. data/lib/kalibro_gatekeeper_client/entities/stack_trace_element.rb +31 -0
  94. data/lib/kalibro_gatekeeper_client/entities/throwable.rb +42 -0
  95. data/lib/kalibro_gatekeeper_client/entities.rb +37 -0
  96. data/lib/kalibro_gatekeeper_client/errors/record_not_found.rb +22 -0
  97. data/lib/kalibro_gatekeeper_client/errors/standard.rb +24 -0
  98. data/lib/kalibro_gatekeeper_client/errors.rb +18 -0
  99. data/lib/kalibro_gatekeeper_client/helpers/aggregation_options.rb +25 -0
  100. data/lib/kalibro_gatekeeper_client/helpers/hash_converters.rb +48 -0
  101. data/lib/kalibro_gatekeeper_client/helpers/request_methods.rb +47 -0
  102. data/lib/kalibro_gatekeeper_client/helpers/xml_converters.rb +20 -0
  103. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/configuration.rb +39 -0
  104. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/hooks.rb +56 -0
  105. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/delete_all_kalibro_entries.sh +23 -0
  106. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/prepare_kalibro_query_file.sh +38 -0
  107. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/put_kalibro_on_test_mode.sh +39 -0
  108. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/return_kalibro_from_test_mode.sh +26 -0
  109. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers.rb +40 -0
  110. data/lib/kalibro_gatekeeper_client/version.rb +19 -0
  111. data/lib/kalibro_gatekeeper_client.rb +61 -0
  112. data/lib/rake/test_task.rb +57 -0
  113. data/spec/entities/base_tool_spec.rb +168 -0
  114. data/spec/entities/configuration_spec.rb +61 -0
  115. data/spec/entities/date_metric_result_spec.rb +62 -0
  116. data/spec/entities/date_module_result_spec.rb +61 -0
  117. data/spec/entities/metric_configuration_snapshot_spec.rb +107 -0
  118. data/spec/entities/metric_configuration_spec.rb +173 -0
  119. data/spec/entities/metric_result_spec.rb +188 -0
  120. data/spec/entities/metric_spec.rb +47 -0
  121. data/spec/entities/model_spec.rb +322 -0
  122. data/spec/entities/module_result_spec.rb +163 -0
  123. data/spec/entities/process_time_spec.rb +33 -0
  124. data/spec/entities/processing_spec.rb +334 -0
  125. data/spec/entities/project_spec.rb +68 -0
  126. data/spec/entities/range_snapshot_spec.rb +50 -0
  127. data/spec/entities/range_spec.rb +225 -0
  128. data/spec/entities/reading_group_spec.rb +90 -0
  129. data/spec/entities/reading_spec.rb +148 -0
  130. data/spec/entities/repository_observer_spec.rb +123 -0
  131. data/spec/entities/repository_spec.rb +191 -0
  132. data/spec/entities/stack_trace_element_spec.rb +26 -0
  133. data/spec/entities/throwable_spec.rb +51 -0
  134. data/spec/factories/base_tools.rb +31 -0
  135. data/spec/factories/configurations.rb +29 -0
  136. data/spec/factories/date_metric_results.rb +28 -0
  137. data/spec/factories/date_module_results.rb +22 -0
  138. data/spec/factories/metric_configurations.rb +28 -0
  139. data/spec/factories/metric_configurations_snapshot.rb +26 -0
  140. data/spec/factories/metric_results.rb +24 -0
  141. data/spec/factories/metrics.rb +35 -0
  142. data/spec/factories/models.rb +20 -0
  143. data/spec/factories/module_results.rb +33 -0
  144. data/spec/factories/modules.rb +22 -0
  145. data/spec/factories/process_times.rb +27 -0
  146. data/spec/factories/processings.rb +25 -0
  147. data/spec/factories/projects.rb +29 -0
  148. data/spec/factories/ranges.rb +35 -0
  149. data/spec/factories/ranges_snapshot.rb +26 -0
  150. data/spec/factories/reading_groups.rb +23 -0
  151. data/spec/factories/readings.rb +25 -0
  152. data/spec/factories/repositories.rb +34 -0
  153. data/spec/factories/repository_observers.rb +24 -0
  154. data/spec/factories/stack_trace_elements.rb +24 -0
  155. data/spec/factories/throwables.rb +23 -0
  156. data/spec/helpers/aggregation_options_spec.rb +31 -0
  157. data/spec/helpers/hash_converters_spec.rb +111 -0
  158. data/spec/helpers/xml_converters_spec.rb +64 -0
  159. data/spec/kalibro_entities_spec.rb +108 -0
  160. data/spec/savon/fixtures/config.yml +1 -0
  161. data/spec/savon/fixtures/invalid_config.yml +2 -0
  162. data/spec/savon/fixtures/project/does_not_exists.xml +1 -0
  163. data/spec/savon/savon_test_helper.rb +14 -0
  164. data/spec/spec_helper.rb +56 -0
  165. metadata +466 -0
@@ -0,0 +1,90 @@
1
+ # This file is part of KalibroGatekeeperClient
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'spec_helper'
18
+
19
+ describe KalibroGatekeeperClient::Entities::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
+ KalibroGatekeeperClient::Entities::ReadingGroup.
33
+ expects(:request).
34
+ with('all', {}, :get).
35
+ returns({'reading_groups' => nil}.to_json)
36
+ end
37
+
38
+ it 'should return nil' do
39
+ KalibroGatekeeperClient::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
+ KalibroGatekeeperClient::Entities::ReadingGroup.
47
+ expects(:request).
48
+ with('all', {}, :get).
49
+ returns({'reading_groups' => [reading_group.to_hash, reading_group.to_hash]}.to_json)
50
+ end
51
+
52
+ it 'should return nil' do
53
+ reading_groups = KalibroGatekeeperClient::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
+ KalibroGatekeeperClient::Entities::ReadingGroup.
67
+ expects(:request).
68
+ with('destroy',{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
+ KalibroGatekeeperClient::Entities::ReadingGroup.
83
+ expects(:request).
84
+ with('exists',{id: 0}).
85
+ returns({'exists' => false})
86
+ KalibroGatekeeperClient::Entities::ReadingGroup.exists?(0)
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,148 @@
1
+ # This file is part of KalibroGatekeeperClient
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'spec_helper'
18
+
19
+ describe KalibroGatekeeperClient::Entities::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
+ KalibroGatekeeperClient::Entities::Reading.
41
+ expects(:request).
42
+ with('get', {id: reading.id}).
43
+ returns(reading.to_hash)
44
+ end
45
+
46
+ it 'should return a reading object' do
47
+ response = KalibroGatekeeperClient::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
+ KalibroGatekeeperClient::Entities::Reading.
58
+ expects(:request).
59
+ with('get', {id: reading.id}).
60
+ returns({'error' => 'Error'})
61
+ end
62
+
63
+ it 'should return a reading object' do
64
+ expect {KalibroGatekeeperClient::Entities::Reading.find(reading.id) }.
65
+ to raise_error(KalibroGatekeeperClient::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
+ KalibroGatekeeperClient::Entities::Reading.
75
+ expects(:request).
76
+ with('of', {reading_group_id: reading_group.id}).
77
+ returns({'readings' => [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 = KalibroGatekeeperClient::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
+
87
+ describe 'all' do
88
+ let(:reading_group) { FactoryGirl.build(:reading_group) }
89
+
90
+ before :each do
91
+ KalibroGatekeeperClient::Entities::ReadingGroup.
92
+ expects(:all).
93
+ returns([reading_group])
94
+ KalibroGatekeeperClient::Entities::Reading.
95
+ expects(:readings_of).
96
+ with(reading_group.id).
97
+ returns([subject])
98
+ end
99
+
100
+ it 'should list all the readings' do
101
+ KalibroGatekeeperClient::Entities::Reading.all.should include(subject)
102
+ end
103
+ end
104
+ end
105
+
106
+ # The only purpose of this test is to cover the overrided save_params method
107
+ describe 'save' do
108
+ let(:reading) { FactoryGirl.build(:reading, {id: nil, group_id: FactoryGirl.build(:reading_group).id}) }
109
+ let(:reading_id) { 73 }
110
+
111
+ before :each do
112
+ KalibroGatekeeperClient::Entities::Reading.
113
+ expects(:request).
114
+ with('save', {reading: reading.to_hash, reading_group_id: reading.group_id}).
115
+ returns({'id' => reading_id})
116
+ end
117
+
118
+ it 'should make a request to save model with id and return true without errors' do
119
+ reading.save.should be(true)
120
+ reading.id.should eq(reading_id)
121
+ reading.kalibro_errors.should be_empty
122
+ end
123
+ end
124
+
125
+ describe 'exists?' do
126
+ subject {FactoryGirl.build(:reading)}
127
+
128
+ context 'when the reading exists' do
129
+ before :each do
130
+ KalibroGatekeeperClient::Entities::Reading.expects(:find).with(subject.id).returns(subject)
131
+ end
132
+
133
+ it 'should return true' do
134
+ KalibroGatekeeperClient::Entities::Reading.exists?(subject.id).should be_true
135
+ end
136
+ end
137
+
138
+ context 'when the reading does not exists' do
139
+ before :each do
140
+ KalibroGatekeeperClient::Entities::Reading.expects(:find).with(subject.id).raises(KalibroGatekeeperClient::Errors::RecordNotFound)
141
+ end
142
+
143
+ it 'should return false' do
144
+ KalibroGatekeeperClient::Entities::Reading.exists?(subject.id).should be_false
145
+ end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,123 @@
1
+ # This file is part of KalibroGatekeeperClient
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'spec_helper'
18
+
19
+ describe KalibroGatekeeperClient::Entities::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
+ KalibroGatekeeperClient::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
+ KalibroGatekeeperClient::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
+ KalibroGatekeeperClient::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 = KalibroGatekeeperClient::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
+ KalibroGatekeeperClient::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
+ KalibroGatekeeperClient::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
+ KalibroGatekeeperClient::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 = KalibroGatekeeperClient::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
@@ -0,0 +1,191 @@
1
+ # This file is part of KalibroGatekeeperClient
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'spec_helper'
18
+
19
+ describe KalibroGatekeeperClient::Entities::Repository do
20
+ subject { FactoryGirl.build(:repository) }
21
+
22
+ describe 'repository_types' do
23
+ before :each do
24
+ KalibroGatekeeperClient::Entities::Repository.
25
+ expects(:request).
26
+ with('supported_types', {}, :get).
27
+ returns({'supported_types'=>["BAZAAR", "GIT", "MERCURIAL", "REMOTE_TARBALL", "REMOTE_ZIP"],
28
+ :"@xmlns:ns2"=>"http://service.kalibro.org/"})
29
+ end
30
+
31
+ it 'should return an array of repository types' do
32
+ KalibroGatekeeperClient::Entities::Repository.repository_types.should eq(["BAZAAR", "GIT", "MERCURIAL", "REMOTE_TARBALL", "REMOTE_ZIP"])
33
+ end
34
+ end
35
+
36
+ describe 'repositories_of' do
37
+ before :each do
38
+ KalibroGatekeeperClient::Entities::Repository.
39
+ expects(:request).
40
+ with('of', {project_id: 1}).
41
+ returns({'repositories' => [],
42
+ :"@xmlns:ns2"=>"http://service.kalibro.org/"})
43
+ end
44
+
45
+ it 'should return an array' do
46
+ KalibroGatekeeperClient::Entities::Repository.repositories_of(1).should be_an(Array)
47
+ end
48
+
49
+ it 'should set the repository_id' do
50
+ KalibroGatekeeperClient::Entities::Repository.repositories_of(1).each do |repository|
51
+ repository.project_id.should eq(1)
52
+ end
53
+ end
54
+ end
55
+
56
+ describe "id=" do
57
+ it 'should set the id attribute values as integer' do
58
+ subject.id = "222"
59
+ subject.id.should eq(222)
60
+ end
61
+ end
62
+
63
+ describe "process_period=" do
64
+ it 'should set the process_period attribute values as integer' do
65
+ subject.process_period = "222"
66
+ subject.process_period.should eq(222)
67
+ end
68
+ end
69
+
70
+ describe "configuration_id=" do
71
+ it 'should set the configuration_id attribute values as integer' do
72
+ subject.configuration_id = "222"
73
+ subject.configuration_id.should eq(222)
74
+ end
75
+ end
76
+
77
+ describe 'process' do
78
+ before :each do
79
+ KalibroGatekeeperClient::Entities::Repository.
80
+ expects(:request).
81
+ with('process', {id: subject.id})
82
+ end
83
+
84
+ it 'should call the request method' do
85
+ subject.process
86
+ end
87
+ end
88
+
89
+ describe 'cancel_processing_of_repository' do
90
+ before :each do
91
+ KalibroGatekeeperClient::Entities::Repository.
92
+ expects(:request).
93
+ with('cancel_process', {id: subject.id})
94
+ end
95
+
96
+ it 'should call the request method' do
97
+ subject.cancel_processing_of_repository
98
+ end
99
+ end
100
+
101
+ describe 'all' do
102
+ let(:project) { FactoryGirl.build(:project) }
103
+
104
+ before :each do
105
+ KalibroGatekeeperClient::Entities::Project.
106
+ expects(:all).
107
+ returns([project])
108
+ KalibroGatekeeperClient::Entities::Repository.
109
+ expects(:repositories_of).
110
+ with(project.id).
111
+ returns([subject])
112
+ end
113
+
114
+ it 'should list all the repositories' do
115
+ KalibroGatekeeperClient::Entities::Repository.all.should include(subject)
116
+ end
117
+ end
118
+
119
+ describe 'find' do
120
+ context 'when the repository exists' do
121
+ before :each do
122
+ KalibroGatekeeperClient::Entities::Repository.
123
+ expects(:all).
124
+ returns([subject])
125
+ end
126
+
127
+ it 'should return the repository' do
128
+ KalibroGatekeeperClient::Entities::Repository.find(subject.id).should eq(subject)
129
+ end
130
+ end
131
+
132
+ context "when the repository doesn't exists" do
133
+ before :each do
134
+ KalibroGatekeeperClient::Entities::Repository.
135
+ expects(:all).
136
+ returns([FactoryGirl.build(:another_repository)])
137
+ end
138
+
139
+ it 'should raise a RecordNotFound error' do
140
+ expect { KalibroGatekeeperClient::Entities::Repository.find(subject.id) }.
141
+ to raise_error(KalibroGatekeeperClient::Errors::RecordNotFound)
142
+ end
143
+ end
144
+ end
145
+
146
+ # The only purpose of this test is to cover the overrided save_params method
147
+ describe 'save' do
148
+ subject {FactoryGirl.build(:repository, {id: nil})}
149
+
150
+ before :each do
151
+ KalibroGatekeeperClient::Entities::Repository.
152
+ expects(:request).
153
+ with('save', {:repository => subject.to_hash, :project_id => 1}).
154
+ returns({'id' => 1})
155
+
156
+ KalibroGatekeeperClient::Entities::Repository.any_instance.
157
+ expects(:id=).
158
+ with(1).
159
+ returns(1)
160
+ end
161
+
162
+ it 'should make a request to save model with id and return true without errors' do
163
+ subject.save.should be(true)
164
+ subject.kalibro_errors.should be_empty
165
+ end
166
+ end
167
+
168
+ describe 'exists?' do
169
+ subject {FactoryGirl.build(:repository)}
170
+
171
+ context 'when the repository exists' do
172
+ before :each do
173
+ KalibroGatekeeperClient::Entities::Repository.expects(:find).with(subject.id).returns(subject)
174
+ end
175
+
176
+ it 'should return true' do
177
+ KalibroGatekeeperClient::Entities::Repository.exists?(subject.id).should be_true
178
+ end
179
+ end
180
+
181
+ context 'when the repository does not exists' do
182
+ before :each do
183
+ KalibroGatekeeperClient::Entities::Repository.expects(:find).with(subject.id).raises(KalibroGatekeeperClient::Errors::RecordNotFound)
184
+ end
185
+
186
+ it 'should return false' do
187
+ KalibroGatekeeperClient::Entities::Repository.exists?(subject.id).should be_false
188
+ end
189
+ end
190
+ end
191
+ end
@@ -0,0 +1,26 @@
1
+ # This file is part of KalibroGatekeeperClient
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'spec_helper'
18
+
19
+ describe KalibroGatekeeperClient::Entities::StackTraceElement do
20
+ describe 'line_number=' do
21
+ it 'should set the line_number' do
22
+ subject.line_number = 42
23
+ subject.line_number.should eq(42)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,51 @@
1
+ # This file is part of KalibroGatekeeperClient
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'spec_helper'
18
+
19
+ describe KalibroGatekeeperClient::Entities::Throwable do
20
+ let(:stack_trace_element) { FactoryGirl.build(:stack_trace_element) }
21
+
22
+ describe 'stack_trace_element=' do
23
+ it 'should set the stack trace element' do
24
+ subject.stack_trace_element = stack_trace_element.to_hash
25
+ subject.stack_trace_element.should eq([stack_trace_element])
26
+ end
27
+ end
28
+
29
+ describe 'stack_trace' do
30
+ it 'should return the stack trace element' do
31
+ subject.stack_trace_element = stack_trace_element.to_hash
32
+ subject.stack_trace.should eq([stack_trace_element])
33
+ end
34
+ end
35
+
36
+ describe 'stack_trace=' do
37
+ it 'should set the stack trace element' do
38
+ subject.stack_trace = [stack_trace_element]
39
+ subject.stack_trace_element.should eq([stack_trace_element])
40
+ end
41
+ end
42
+
43
+ describe 'cause=' do
44
+ let(:another_throwable) { FactoryGirl.build(:throwable) }
45
+
46
+ it 'should set the cause' do
47
+ subject.cause = another_throwable.to_hash
48
+ subject.cause.should eq(another_throwable)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,31 @@
1
+ # This file is part of KalibroGatekeeperClient
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ FactoryGirl.define do
18
+ factory :base_tool, class: KalibroGatekeeperClient::Entities::BaseTool do
19
+ name "Analizo"
20
+ description "Analizo is a suite of source code analysis tools."
21
+ collector_class_name "org.analizo.AnalizoMetricCollector"
22
+ supported_metric { [FactoryGirl.build(:metric), FactoryGirl.build(:metric)] }
23
+
24
+ trait :another_base_tool do
25
+ name "Avalio"
26
+ description "Avalio is another source code analyser that hasn't been developed yet."
27
+ end
28
+
29
+ factory :another_base_tool, traits: [:another_base_tool]
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ # This file is part of KalibroGatekeeperClient
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ FactoryGirl.define do
18
+ factory :configuration, class: KalibroGatekeeperClient::Entities::Configuration do
19
+ id 1
20
+ name "Java"
21
+ description "Code metrics for Java."
22
+ end
23
+
24
+ factory :another_configuration, class: KalibroGatekeeperClient::Entities::Configuration do
25
+ id 12
26
+ name "Perl"
27
+ description "Code metrics for Perl."
28
+ end
29
+ end