kalibro_gem 0.0.1.rc9 → 0.0.1.rc10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98324243147f112a11c973aff84d4379d6223207
4
- data.tar.gz: a1246a5e641e80c207e1d7df671f18a5e8b03946
3
+ metadata.gz: b74a2dd28b6faf6f01029dab0d3f6816c75b8f04
4
+ data.tar.gz: 77223e018fd676454c43ec7684754968b73e4147
5
5
  SHA512:
6
- metadata.gz: 7f907be250a925f385eb5ed28e5abd9ea178f347c250245df5ee8e695f168ff3b20099cab403565ccdd8b69c703546045a07af8b888e29eaf076b3cfb26e33bf
7
- data.tar.gz: 5686b1aa2beff3402d7c9d6e1c49ba2cdd2db7d04f96a2f2e4cd068c4473f747bd3756cd3dfa3f6bf32cbb531f36f7e6ca6ec67596a0c47518043840c835a70a
6
+ metadata.gz: 1346e136af91f908fed3e995d81d86036ef53ecf5a58715e2487180e602975d90822a707d64d65d7e18bed44aa3264f1a22c617ff37b02e5fd2b0c1f69c7972c
7
+ data.tar.gz: 4ec72af2c75b49ca60e6fc850db59f36adbfc82a5321812d979562dc2de2c863ec9ceb4292579bdc81ed638e6d93aa1c70e325d47a35dc6b52b50e2512d6e026
@@ -0,0 +1,14 @@
1
+ Feature: Range listing
2
+ In order to be able to get all the ranges
3
+ As a developer
4
+ I want to see all the ranges
5
+
6
+ @kalibro_restart
7
+ Scenario: When there are ranges
8
+ Given I have a configuration with name "Java"
9
+ And I have a reading group with name "Group"
10
+ And I have a metric configuration within the given configuration
11
+ And I have a reading within the given reading group
12
+ And I have a range within the given reading
13
+ When I ask for all the ranges
14
+ Then I should not get an empty list
@@ -0,0 +1,13 @@
1
+ Feature: Exists
2
+ In order to be able to have ranges
3
+ As a developer
4
+ I want to find wich range exists
5
+
6
+ @kalibro_restart
7
+ Scenario: find a valid range
8
+ Given I have a configuration with name "Java"
9
+ And I have a reading group with name "Group"
10
+ And I have a metric configuration within the given configuration
11
+ And I have a reading within the given reading group
12
+ And I have a range within the given reading
13
+ Then the range should exist
@@ -0,0 +1,14 @@
1
+ Feature: Find
2
+ In order to be able to have ranges
3
+ As a developer
4
+ I want to find ranges
5
+
6
+ @kalibro_restart
7
+ Scenario: find a valid range
8
+ Given I have a configuration with name "Java"
9
+ And I have a reading group with name "Group"
10
+ And I have a metric configuration within the given configuration
11
+ And I have a reading within the given reading group
12
+ And I have a range within the given reading
13
+ When I search a range with the same id of the given range
14
+ Then it should return the same range as the given one
@@ -0,0 +1,13 @@
1
+ Feature: Reading listing
2
+ In order to be able to visualize readings
3
+ As a developer
4
+ I want to see all the readings on the service
5
+
6
+ @kalibro_restart
7
+ Scenario: With existing reading group reading
8
+ Given I have a reading group with name "Kalibro"
9
+ And the given reading group has the following readings:
10
+ | label | grade | color |
11
+ | "Awesome" | 10 | 3333FF |
12
+ When I ask for all the readings
13
+ Then the response should contain the given reading
@@ -0,0 +1,13 @@
1
+ Feature: Reading listing
2
+ In order to be able to check know if a reading still exists
3
+ As a developer
4
+ I want to check that on the service
5
+
6
+ @kalibro_restart
7
+ Scenario: With existing reading group reading
8
+ Given I have a reading group with name "RG"
9
+ And the given reading group has the following readings:
10
+ | label | grade | color |
11
+ | "Awesome" | 10 | 3333FF |
12
+ When I ask to check if the given reading exists
13
+ Then I should get true
@@ -23,10 +23,22 @@ When(/^I ask ranges of the given metric configuration$/) do
23
23
  @response = KalibroGem::Entities::Range.ranges_of @metric_configuration.id
24
24
  end
25
25
 
26
+ When(/^I ask for all the ranges$/) do
27
+ @response = KalibroGem::Entities::Range.all
28
+ end
29
+
30
+ When(/^I search a range with the same id of the given range$/) do
31
+ @found_range = KalibroGem::Entities::Range.find(@range.id.to_i)
32
+ end
33
+
26
34
  Then(/^I should get an empty list$/) do
27
35
  @response.should eq([])
28
36
  end
29
37
 
38
+ Then(/^I should not get an empty list$/) do
39
+ @response.should_not eq([])
40
+ end
41
+
30
42
  Then(/^I should get a list with the given range$/) do
31
43
  @response.size.should eq(1)
32
44
  @response.first.comments.should eq(@range.comments)
@@ -38,4 +50,12 @@ end
38
50
 
39
51
  Then(/^the id of the given range should be set$/) do
40
52
  @range.id.should_not eq(0)
53
+ end
54
+
55
+ Then(/^it should return the same range as the given one$/) do
56
+ @found_range == @range
57
+ end
58
+
59
+ Then(/^the range should exist$/) do
60
+ KalibroGem::Entities::Range.exists?(@range.id)
41
61
  end
@@ -1,7 +1,19 @@
1
+ Given(/^the given reading group has the following readings:$/) do |table|
2
+ hash = table.hashes.first
3
+ hash[:group_id] = @reading_group.id
4
+ hash[:id] = nil
5
+
6
+ @reading = FactoryGirl.create(:reading, hash)
7
+ end
8
+
1
9
  Given(/^I have a reading within the given reading group$/) do
2
10
  @reading = FactoryGirl.create(:reading, {id: nil, group_id: @reading_group.id})
3
11
  end
4
12
 
13
+ When(/^I ask for all the readings$/) do
14
+ @all_readings = KalibroGem::Entities::Reading.all
15
+ end
16
+
5
17
  When(/^I ask for a reading with the same id of the given reading$/) do
6
18
  @found_reading = KalibroGem::Entities::Reading.find @reading.id
7
19
  end
@@ -10,6 +22,10 @@ When(/^I ask for the readings of the given reading group$/) do
10
22
  @found_readings = KalibroGem::Entities::Reading.readings_of @reading_group.id
11
23
  end
12
24
 
25
+ When(/^I ask to check if the given reading exists$/) do
26
+ @response = KalibroGem::Entities::Reading.exists?(@reading.id)
27
+ end
28
+
13
29
  Then(/^I should get the given reading$/) do
14
30
  @found_reading == @reading
15
31
  end
@@ -18,3 +34,6 @@ Then(/^I should get a list with the given reading$/) do
18
34
  @found_readings.first == @reading
19
35
  end
20
36
 
37
+ Then(/^the response should contain the given reading$/) do
38
+ @all_readings.first == @reading
39
+ end
data/kalibro_gem.gemspec CHANGED
@@ -43,6 +43,6 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency "factory_girl", "~> 4.3.0"
44
44
  spec.add_development_dependency 'coveralls'
45
45
 
46
- spec.add_dependency "savon", "~> 2.3.2"
47
- spec.add_dependency "activesupport", "~> 4.0.1"
46
+ spec.add_dependency "savon", "~> 2.3.3"
47
+ spec.add_dependency "activesupport", "~> 4.0.2"
48
48
  end
@@ -70,6 +70,37 @@ module KalibroGem
70
70
  @reading ||= KalibroGem::Entities::Reading.find(reading_id)
71
71
  @reading
72
72
  end
73
+
74
+ def self.all
75
+ metric_configurations = []
76
+ ranges = []
77
+ configurations = Configuration.all
78
+
79
+ configurations.each do |config|
80
+ metric_configurations.concat(MetricConfiguration.metric_configurations_of(config.id))
81
+ end
82
+
83
+ metric_configurations.each do |metric_config|
84
+ ranges.concat(self.ranges_of(metric_config.id))
85
+ end
86
+
87
+ return ranges
88
+ end
89
+
90
+ def self.find(id)
91
+ self.all.each do |range|
92
+ return range if range.id == id
93
+ end
94
+ raise KalibroGem::Errors::RecordNotFound
95
+ end
96
+
97
+ def self.exists?(id)
98
+ begin
99
+ return true unless self.find(id).nil?
100
+ rescue KalibroGem::Errors::RecordNotFound
101
+ return false
102
+ end
103
+ end
73
104
  end
74
105
  end
75
106
  end
@@ -47,10 +47,17 @@ module KalibroGem
47
47
  reading_groups.each do |reading_group|
48
48
  readings.concat(readings_of(reading_group.id))
49
49
  end
50
-
51
50
  return readings
52
51
  end
53
52
 
53
+ def self.exists?(id)
54
+ begin
55
+ return true unless find(id).nil?
56
+ rescue KalibroGem::Errors::RecordNotFound
57
+ return false
58
+ end
59
+ end
60
+
54
61
  private
55
62
 
56
63
  def save_params
@@ -15,5 +15,5 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  module KalibroGem
18
- VERSION = "0.0.1.rc9"
18
+ VERSION = "0.0.1.rc10"
19
19
  end
@@ -58,7 +58,6 @@ describe KalibroGem::Entities::Range do
58
58
  end
59
59
 
60
60
  describe 'getting reading attribute' do
61
- subject { FactoryGirl.build(:range) }
62
61
  let(:reading) { FactoryGirl.build(:reading) }
63
62
 
64
63
  before :each do
@@ -178,4 +177,76 @@ describe KalibroGem::Entities::Range do
178
177
  end
179
178
  end
180
179
  end
180
+
181
+ describe 'exists?' do
182
+ context 'when the range exists' do
183
+ before :each do
184
+ KalibroGem::Entities::Range.expects(:find).with(subject.id).returns(subject)
185
+ end
186
+
187
+ it 'should return true' do
188
+ KalibroGem::Entities::Range.exists?(subject.id).should be_true
189
+ end
190
+ end
191
+
192
+ context 'when the range does not exists' do
193
+ before :each do
194
+ KalibroGem::Entities::Range.expects(:find).with(subject.id).raises(KalibroGem::Errors::RecordNotFound)
195
+ end
196
+
197
+ it 'should return false' do
198
+ KalibroGem::Entities::Range.exists?(subject.id).should be_false
199
+ end
200
+ end
201
+ end
202
+
203
+ describe 'find' do
204
+ context 'when the range exists' do
205
+ before :each do
206
+ KalibroGem::Entities::Range.
207
+ expects(:all).
208
+ returns([subject])
209
+ end
210
+
211
+ it 'should return the range' do
212
+ KalibroGem::Entities::Range.find(subject.id).should eq(subject)
213
+ end
214
+ end
215
+
216
+ context "when the range doesn't exists" do
217
+ before :each do
218
+ KalibroGem::Entities::Range.
219
+ expects(:all).
220
+ returns([FactoryGirl.build(:another_range)])
221
+ end
222
+
223
+ it 'should raise a RecordNotFound error' do
224
+ expect { KalibroGem::Entities::Range.find(subject.id) }.
225
+ to raise_error(KalibroGem::Errors::RecordNotFound)
226
+ end
227
+ end
228
+ end
229
+
230
+ describe 'all' do
231
+ let(:configuration) { FactoryGirl.build(:configuration) }
232
+ let(:metric_configuration) { FactoryGirl.build(:metric_configuration) }
233
+
234
+ before :each do
235
+ KalibroGem::Entities::Configuration.
236
+ expects(:all).
237
+ returns([configuration])
238
+ KalibroGem::Entities::MetricConfiguration.
239
+ expects(:metric_configurations_of).
240
+ with(configuration.id).
241
+ returns([metric_configuration])
242
+ KalibroGem::Entities::Range.
243
+ expects(:ranges_of).
244
+ with(metric_configuration.id).
245
+ returns([subject])
246
+ end
247
+
248
+ it 'should list all the ranges' do
249
+ KalibroGem::Entities::Range.all.should include(subject)
250
+ end
251
+ end
181
252
  end
@@ -121,4 +121,28 @@ describe KalibroGem::Entities::Reading do
121
121
  reading.kalibro_errors.should be_empty
122
122
  end
123
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
+ KalibroGem::Entities::Reading.expects(:find).with(subject.id).returns(subject)
131
+ end
132
+
133
+ it 'should return true' do
134
+ KalibroGem::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
+ KalibroGem::Entities::Reading.expects(:find).with(subject.id).raises(KalibroGem::Errors::RecordNotFound)
141
+ end
142
+
143
+ it 'should return false' do
144
+ KalibroGem::Entities::Reading.exists?(subject.id).should be_false
145
+ end
146
+ end
147
+ end
124
148
  end
@@ -16,6 +16,7 @@
16
16
 
17
17
  FactoryGirl.define do
18
18
  factory :range, class: KalibroGem::Entities::Range do
19
+ id 1
19
20
  beginning 1.1
20
21
  self.end 5.1
21
22
  reading_id 3
@@ -25,6 +26,10 @@ FactoryGirl.define do
25
26
  comments "Another Comment"
26
27
  end
27
28
 
28
- factory :another_range, traits: [:another_comment]
29
+ trait :another_id do
30
+ id 2
31
+ end
32
+
33
+ factory :another_range, traits: [:another_comment, :another_id]
29
34
  end
30
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kalibro_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.rc9
4
+ version: 0.0.1.rc10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Morais
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2014-01-06 00:00:00.000000000 Z
18
+ date: 2014-01-13 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bundler
@@ -135,28 +135,28 @@ dependencies:
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 2.3.2
138
+ version: 2.3.3
139
139
  type: :runtime
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 2.3.2
145
+ version: 2.3.3
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: activesupport
148
148
  requirement: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 4.0.1
152
+ version: 4.0.2
153
153
  type: :runtime
154
154
  prerelease: false
155
155
  version_requirements: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 4.0.1
159
+ version: 4.0.2
160
160
  description: KalibroGem is a Ruby gem intended to be an interface for Ruby applications
161
161
  who want to use the open source code analysis webservice Kalibro (http://gitorious.org/kalibro/kalibro).
162
162
  email:
@@ -211,8 +211,13 @@ files:
211
211
  - features/project/destroy.feature
212
212
  - features/project/exists.feature
213
213
  - features/project/find.feature
214
+ - features/range/all.feature
215
+ - features/range/exists.feature
216
+ - features/range/find.feature
214
217
  - features/range/ranges_of.feature
215
218
  - features/range/save.feature
219
+ - features/reading/all.feature
220
+ - features/reading/exists.feature
216
221
  - features/reading/find.feature
217
222
  - features/reading/readings_of.feature
218
223
  - features/reading_group/all.feature
@@ -383,8 +388,13 @@ test_files:
383
388
  - features/project/destroy.feature
384
389
  - features/project/exists.feature
385
390
  - features/project/find.feature
391
+ - features/range/all.feature
392
+ - features/range/exists.feature
393
+ - features/range/find.feature
386
394
  - features/range/ranges_of.feature
387
395
  - features/range/save.feature
396
+ - features/reading/all.feature
397
+ - features/reading/exists.feature
388
398
  - features/reading/find.feature
389
399
  - features/reading/readings_of.feature
390
400
  - features/reading_group/all.feature