kalibro_gem 0.0.1.rc17 → 0.0.1.rc18

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: 24f925dbbaf13c9a84e2b7b122548edf45c5b40e
4
- data.tar.gz: c09a1d431de84a771d80026d67b329fcf0468ada
3
+ metadata.gz: b08d40ee1a65aa9776e0424662e0783c9c804db3
4
+ data.tar.gz: 8093846611b9be8e0cc3c89c0a209db0370647d7
5
5
  SHA512:
6
- metadata.gz: 262a79e487e79243e6e97866ef0ae14d14aafddaccec6b86d542e2ee4eecccf295d878ceb0bcc1290cc558da0726540a33d0cf78d44263779bdbcc8405bfad25
7
- data.tar.gz: 61528adbf75d240b0cc0e7867b238bf10e532ad6eaf18c060ba1495d63aa06edf1d47add4d5cadc7c338acd076ccb334041b5802539cb7c3db186ae58292f625
6
+ metadata.gz: 3892c2cb2c3921a85c305b50b4aca72eab468f1fdde4a0c58e2c9ecafc4d6fb9eb0a9dfd61cf66a16e9ac21678b399ee519802e33042a86b445529e03133f3d1
7
+ data.tar.gz: 5fd585c3f90c3e8fc47162d0551707b9a3f5ac040827cec5b3880507b51d4c41ae6d7e397e5460582e5728f447a79f8ff5925bb1ea68bd3c854a1b0ce906a6f0
@@ -17,8 +17,7 @@ Feature: Save
17
17
  Scenario: When there is not a metric configuration
18
18
  Given I have a reading group with name "Group"
19
19
  And I have a reading within the given reading group
20
- And I have an unsaved range within the given reading
21
- When I ask to save the given range with an inexistent metric configuration
20
+ When I try to save a range with an inexistent metric configuration
22
21
  Then I should get an error in range kalibro errors attribute
23
22
 
24
23
  @kalibro_restart
@@ -1,6 +1,6 @@
1
1
  Given(/^I have a range within the given reading$/) do
2
- @range = FactoryGirl.build(:range, {id: nil, reading_id: @reading.id})
3
- @range.save @metric_configuration.id
2
+ @range = FactoryGirl.build(:range, {id: nil, reading_id: @reading.id, metric_configuration_id: @metric_configuration.id})
3
+ @range.save
4
4
  end
5
5
 
6
6
  Given(/^I have an unsaved range$/) do
@@ -8,21 +8,28 @@ Given(/^I have an unsaved range$/) do
8
8
  end
9
9
 
10
10
  Given(/^I have an unsaved range within the given reading$/) do
11
- @range = FactoryGirl.build(:range, {id: nil, reading_id: @reading.id})
11
+ @range = FactoryGirl.build(:range, {id: nil, reading_id: @reading.id, metric_configuration_id: @metric_configuration.id})
12
12
  end
13
13
 
14
14
  When(/^I ask to save the given range$/) do
15
- @range.save @metric_configuration.id
15
+ @range.save
16
16
  end
17
17
 
18
18
  When(/^I ask to save the given range with an inexistent metric configuration$/) do
19
- @range.save rand(Time.now.to_i)
19
+ @range.metric_configuration_id = rand(Time.now.to_i)
20
+ @range.save
20
21
  end
21
22
 
22
23
  When(/^I ask ranges of the given metric configuration$/) do
23
24
  @response = KalibroGem::Entities::Range.ranges_of @metric_configuration.id
24
25
  end
25
26
 
27
+ When(/^I try to save a range with an inexistent metric configuration$/) do
28
+ @range = FactoryGirl.build(:range, {id: nil, reading_id: @reading.id})
29
+ @range.metric_configuration_id = rand(Time.now.to_i)
30
+ @range.save
31
+ end
32
+
26
33
  When(/^I ask for all the ranges$/) do
27
34
  @response = KalibroGem::Entities::Range.all
28
35
  end
@@ -49,7 +56,7 @@ Then(/^I should get an error in range kalibro errors attribute$/) do
49
56
  end
50
57
 
51
58
  Then(/^the id of the given range should be set$/) do
52
- @range.id.should_not eq(0)
59
+ @range.id.should_not eq(0)
53
60
  end
54
61
 
55
62
  Then(/^it should return the same range as the given one$/) do
@@ -20,7 +20,7 @@ module KalibroGem
20
20
  module Entities
21
21
  class Range < Model
22
22
 
23
- attr_accessor :id, :beginning, :end, :reading_id, :comments
23
+ attr_accessor :id, :beginning, :end, :reading_id, :comments, :metric_configuration_id
24
24
 
25
25
  def id=(value)
26
26
  @id = value.to_i
@@ -54,23 +54,6 @@ module KalibroGem
54
54
  self.create_objects_array_from_hash request(:ranges_of, {metric_configuration_id: metric_configuration_id} )[:range]
55
55
  end
56
56
 
57
- def save(metric_configuration_id)
58
- begin
59
- @id = self.class.request(:save_range, {:range => self.to_hash, :metric_configuration_id => metric_configuration_id})[:range_id]
60
- true
61
- rescue Exception => exception
62
- add_error exception
63
- false
64
- end
65
- end
66
-
67
- private
68
-
69
- def reading
70
- @reading ||= KalibroGem::Entities::Reading.find(reading_id)
71
- @reading
72
- end
73
-
74
57
  def self.all
75
58
  metric_configurations = []
76
59
  ranges = []
@@ -101,6 +84,17 @@ module KalibroGem
101
84
  return false
102
85
  end
103
86
  end
87
+
88
+ private
89
+
90
+ def save_params
91
+ {:range => self.to_hash, :metric_configuration_id => self.metric_configuration_id}
92
+ end
93
+
94
+ def reading
95
+ @reading ||= KalibroGem::Entities::Reading.find(reading_id)
96
+ @reading
97
+ end
104
98
  end
105
99
  end
106
- end
100
+ end
@@ -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.rc17"
18
+ VERSION = "0.0.1.rc18"
19
19
  end
@@ -134,47 +134,20 @@ describe KalibroGem::Entities::Range do
134
134
  end
135
135
  end
136
136
 
137
+ # The only purpose of this test is to cover the overrided save_params method
137
138
  describe 'save' do
138
- let(:metric_configuration) { FactoryGirl.build(:metric_configuration) }
139
-
140
- context 'when kalibro does not save' do
141
- before :each do
142
- any_error_message = ""
143
- any_code = rand(Time.now.to_i)
144
-
145
- KalibroGem::Entities::Range.
146
- expects(:request).
147
- with(:save_range, {:range => subject.to_hash, :metric_configuration_id => metric_configuration.id}).
148
- raises(Savon::SOAPFault.new(any_error_message, any_code))
149
- end
150
-
151
- it 'should returns false' do
152
- subject.save(metric_configuration.id).should eq(false)
153
- end
139
+ subject {FactoryGirl.build(:range, {id: nil})}
154
140
 
155
- it 'should set the error on kalibro_errors attribute' do
156
- subject.save(metric_configuration.id)
157
- subject.kalibro_errors.should_not eq([])
158
- end
141
+ before :each do
142
+ KalibroGem::Entities::Range.
143
+ expects(:request).
144
+ with(:save_range, {:range => subject.to_hash, :metric_configuration_id => subject.metric_configuration_id}).
145
+ returns({:range_id => 2})
159
146
  end
160
147
 
161
- context 'when kalibro saves the range' do
162
- let(:new_id) { rand(Time.now.to_i) }
163
- before :each do
164
- KalibroGem::Entities::Range.
165
- expects(:request).
166
- with(:save_range, {:range => subject.to_hash, :metric_configuration_id => metric_configuration.id}).
167
- returns({range_id: new_id})
168
- end
169
-
170
- it 'should returns true' do
171
- subject.save(metric_configuration.id).should eq(true)
172
- end
173
-
174
- it 'should set the id attribute' do
175
- subject.save(metric_configuration.id)
176
- subject.id.should eq(new_id)
177
- end
148
+ it 'should make a request to save model with id and return true without errors' do
149
+ subject.save.should be(true)
150
+ subject.kalibro_errors.should be_empty
178
151
  end
179
152
  end
180
153
 
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.rc17
4
+ version: 0.0.1.rc18
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-02-10 00:00:00.000000000 Z
18
+ date: 2014-02-19 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bundler