restfully 1.0.0.rc2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,11 +9,11 @@ describe Restfully::Collection do
9
9
  )
10
10
  @request = Restfully::HTTP::Request.new(
11
11
  @session, :get, "/grid5000/sites/rennes/jobs",
12
- :head => {'Accept' => 'application/vnd.grid5000+json'}
12
+ :head => {'Accept' => 'application/vnd.grid5000.collection+json'}
13
13
  )
14
14
  @response = Restfully::HTTP::Response.new(
15
15
  @session, 200, {
16
- 'Content-Type' => 'application/vnd.grid5000+json; charset=utf-8',
16
+ 'Content-Type' => 'application/vnd.grid5000.collection+json; charset=utf-8',
17
17
  'Allow' => 'GET,POST'
18
18
  }, fixture('grid5000-rennes-jobs.json')
19
19
  )
@@ -38,6 +38,7 @@ describe Restfully::Collection do
38
38
  items = []
39
39
  @resource.load.each{|i| items << i}
40
40
  items.all?{|i| i.kind_of?(Restfully::Resource)}.should be_true
41
+ @resource.should be_collection
41
42
  items[0].relationships.map(&:to_s).sort.should == ["parent", "self"]
42
43
  items[0]['uid'].should == 376505
43
44
  end
@@ -42,17 +42,15 @@ describe Restfully::Link do
42
42
  @media_type = mock(Restfully::MediaType::AbstractMediaType)
43
43
  end
44
44
 
45
- it "should not be valid if there is no type" do
45
+ it "should be valid even if there is no type" do
46
46
  link = Restfully::Link.new(@valid_attributes.merge(:type => ''))
47
- link.should_not be_valid
48
- link.errors.should == ["type cannot be blank"]
47
+ link.should be_valid
49
48
  end
50
49
 
51
- it "should not be valid if a media_type cannot be found" do
50
+ it "should be valid even if a media_type cannot be found" do
52
51
  Restfully::MediaType.catalog.clear
53
52
  link = Restfully::Link.new(@valid_attributes)
54
- link.should_not be_valid
55
- link.errors.should == ["cannot find a MediaType for type \"application/json\""]
53
+ link.should be_valid
56
54
  end
57
55
 
58
56
 
@@ -31,9 +31,9 @@ describe Restfully::MediaType do
31
31
  Restfully::MediaType.find("application/json").should == Restfully::MediaType::ApplicationJson
32
32
  end
33
33
 
34
- it "should find the corresponding media_type [application/vnd.grid5000+json]" do
34
+ it "should find the corresponding media_type [application/vnd.grid5000.collection+json]" do
35
35
  Restfully::MediaType.register Restfully::MediaType::Grid5000
36
- Restfully::MediaType.find('application/vnd.grid5000+json; charset=utf-8').should == Restfully::MediaType::Grid5000
36
+ Restfully::MediaType.find('application/vnd.grid5000.collection+json; charset=utf-8').should == Restfully::MediaType::Grid5000
37
37
  end
38
38
 
39
39
  it "should find the corresponding media_type from the less generic to the most generic [application/json]" do
@@ -11,7 +11,7 @@ describe Restfully::Resource do
11
11
  )
12
12
  @response = Restfully::HTTP::Response.new(
13
13
  @session, 200, {
14
- 'Content-Type' => 'application/vnd.grid5000+json; charset=utf-8',
14
+ 'Content-Type' => 'application/vnd.grid5000.item+json; charset=utf-8',
15
15
  'Allow' => 'GET'
16
16
  }, fixture('grid5000-rennes.json')
17
17
  )
@@ -41,9 +41,16 @@ describe Restfully::Resource do
41
41
  URI.parse("/grid5000/sites/rennes/clusters"),
42
42
  :head=>{"Accept"=>"application/vnd.grid5000+json"}
43
43
  ).and_return(association=mock(Restfully::Resource))
44
- association.should_receive(:load)
45
44
  @resource.clusters
46
45
  end
46
+ it "should load the requested association with the additional parameters" do
47
+ @session.should_receive(:get).once.with(
48
+ URI.parse("/grid5000/sites/rennes/clusters"),
49
+ :head=>{"Accept"=>"application/json", 'X-Thing' => 'value'},
50
+ :query => {"branch" => 'testing'}
51
+ ).and_return(association=mock(Restfully::Resource))
52
+ @resource.clusters(:query => {'branch' => "testing"}, :head => {'x-Thing' => 'value', :accept => 'application/json'})
53
+ end
47
54
  {:update => "PUT", :submit => "POST", :delete => "DELETE"}.each do |method, http_method|
48
55
  it "should get the Allowed HTTP methods when calling #{method.to_sym}" do
49
56
  @response.should_receive(:allow?).with(http_method).and_return(true)
@@ -75,7 +82,7 @@ describe Restfully::Resource do
75
82
  'some payload',
76
83
  :head => {
77
84
  'Content-Type' => 'text/plain',
78
- 'Origin-Content-Type' => "application/vnd.grid5000+json; charset=utf-8"
85
+ 'Origin-Content-Type' => "application/vnd.grid5000.item+json; charset=utf-8"
79
86
  },
80
87
  :query => {:k1 => 'v1'},
81
88
  :serialization => {}
@@ -93,7 +100,7 @@ describe Restfully::Resource do
93
100
  {:key => 'value'},
94
101
  :head => {
95
102
  'Content-Type' => 'text/plain',
96
- 'Origin-Content-Type' => "application/vnd.grid5000+json; charset=utf-8"
103
+ 'Origin-Content-Type' => "application/vnd.grid5000.item+json; charset=utf-8"
97
104
  },
98
105
  :query => {:k1 => 'v1'},
99
106
  :serialization => {}
metadata CHANGED
@@ -1,279 +1,213 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: restfully
3
- version: !ruby/object:Gem::Version
4
- hash: 15424049
5
- prerelease: 6
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- - rc
11
- - 2
12
- version: 1.0.0.rc2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
13
6
  platform: ruby
14
- authors:
7
+ authors:
15
8
  - Cyril Rohr
16
9
  autorequire:
17
10
  bindir: bin
18
11
  cert_chain: []
19
-
20
- date: 2011-11-04 00:00:00 +01:00
21
- default_executable:
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-15 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
24
15
  name: json
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2153394980 !ruby/object:Gem::Requirement
27
17
  none: false
28
- requirements:
18
+ requirements:
29
19
  - - ~>
30
- - !ruby/object:Gem::Version
31
- hash: 5
32
- segments:
33
- - 1
34
- - 5
35
- version: "1.5"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.5'
36
22
  type: :runtime
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: rest-client
40
23
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2153394980
25
+ - !ruby/object:Gem::Dependency
26
+ name: rest-client
27
+ requirement: &2153394520 !ruby/object:Gem::Requirement
42
28
  none: false
43
- requirements:
29
+ requirements:
44
30
  - - ~>
45
- - !ruby/object:Gem::Version
46
- hash: 3
47
- segments:
48
- - 1
49
- - 6
50
- version: "1.6"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.6'
51
33
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: rest-client-components
55
34
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2153394520
36
+ - !ruby/object:Gem::Dependency
37
+ name: rest-client-components
38
+ requirement: &2153394140 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
65
44
  type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: rack-cache
69
45
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2153394140
47
+ - !ruby/object:Gem::Dependency
48
+ name: rack-cache
49
+ requirement: &2153380360 !ruby/object:Gem::Requirement
71
50
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
79
55
  type: :runtime
80
- version_requirements: *id004
81
- - !ruby/object:Gem::Dependency
82
- name: backports
83
56
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *2153380360
58
+ - !ruby/object:Gem::Dependency
59
+ name: backports
60
+ requirement: &2153379940 !ruby/object:Gem::Requirement
85
61
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- hash: 3
90
- segments:
91
- - 0
92
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
93
66
  type: :runtime
94
- version_requirements: *id005
95
- - !ruby/object:Gem::Dependency
96
- name: addressable
97
67
  prerelease: false
98
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *2153379940
69
+ - !ruby/object:Gem::Dependency
70
+ name: addressable
71
+ requirement: &2153379460 !ruby/object:Gem::Requirement
99
72
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 3
104
- segments:
105
- - 0
106
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
107
77
  type: :runtime
108
- version_requirements: *id006
109
- - !ruby/object:Gem::Dependency
110
- name: ripl
111
78
  prerelease: false
112
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *2153379460
80
+ - !ruby/object:Gem::Dependency
81
+ name: ripl
82
+ requirement: &2153378800 !ruby/object:Gem::Requirement
113
83
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 3
118
- segments:
119
- - 0
120
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
121
88
  type: :runtime
122
- version_requirements: *id007
123
- - !ruby/object:Gem::Dependency
124
- name: ripl-multi_line
125
89
  prerelease: false
126
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *2153378800
91
+ - !ruby/object:Gem::Dependency
92
+ name: ripl-multi_line
93
+ requirement: &2153378180 !ruby/object:Gem::Requirement
127
94
  none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 3
132
- segments:
133
- - 0
134
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
135
99
  type: :runtime
136
- version_requirements: *id008
137
- - !ruby/object:Gem::Dependency
138
- name: ripl-color_streams
139
100
  prerelease: false
140
- requirement: &id009 !ruby/object:Gem::Requirement
101
+ version_requirements: *2153378180
102
+ - !ruby/object:Gem::Dependency
103
+ name: ripl-color_streams
104
+ requirement: &2153377500 !ruby/object:Gem::Requirement
141
105
  none: false
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- hash: 3
146
- segments:
147
- - 0
148
- version: "0"
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
149
110
  type: :runtime
150
- version_requirements: *id009
151
- - !ruby/object:Gem::Dependency
152
- name: ripl-short_errors
153
111
  prerelease: false
154
- requirement: &id010 !ruby/object:Gem::Requirement
112
+ version_requirements: *2153377500
113
+ - !ruby/object:Gem::Dependency
114
+ name: ripl-short_errors
115
+ requirement: &2153377080 !ruby/object:Gem::Requirement
155
116
  none: false
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- hash: 3
160
- segments:
161
- - 0
162
- version: "0"
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
163
121
  type: :runtime
164
- version_requirements: *id010
165
- - !ruby/object:Gem::Dependency
166
- name: ripl-play
167
122
  prerelease: false
168
- requirement: &id011 !ruby/object:Gem::Requirement
123
+ version_requirements: *2153377080
124
+ - !ruby/object:Gem::Dependency
125
+ name: ripl-play
126
+ requirement: &2153376580 !ruby/object:Gem::Requirement
169
127
  none: false
170
- requirements:
128
+ requirements:
171
129
  - - ~>
172
- - !ruby/object:Gem::Version
173
- hash: 21
174
- segments:
175
- - 0
176
- - 2
177
- - 1
130
+ - !ruby/object:Gem::Version
178
131
  version: 0.2.1
179
132
  type: :runtime
180
- version_requirements: *id011
181
- - !ruby/object:Gem::Dependency
182
- name: rb-readline
183
133
  prerelease: false
184
- requirement: &id012 !ruby/object:Gem::Requirement
134
+ version_requirements: *2153376580
135
+ - !ruby/object:Gem::Dependency
136
+ name: rb-readline
137
+ requirement: &2153376160 !ruby/object:Gem::Requirement
185
138
  none: false
186
- requirements:
187
- - - ">="
188
- - !ruby/object:Gem::Version
189
- hash: 3
190
- segments:
191
- - 0
192
- version: "0"
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
193
143
  type: :runtime
194
- version_requirements: *id012
195
- - !ruby/object:Gem::Dependency
196
- name: rake
197
144
  prerelease: false
198
- requirement: &id013 !ruby/object:Gem::Requirement
145
+ version_requirements: *2153376160
146
+ - !ruby/object:Gem::Dependency
147
+ name: rake
148
+ requirement: &2153375600 !ruby/object:Gem::Requirement
199
149
  none: false
200
- requirements:
150
+ requirements:
201
151
  - - ~>
202
- - !ruby/object:Gem::Version
203
- hash: 27
204
- segments:
205
- - 0
206
- - 8
207
- version: "0.8"
152
+ - !ruby/object:Gem::Version
153
+ version: '0.8'
208
154
  type: :development
209
- version_requirements: *id013
210
- - !ruby/object:Gem::Dependency
211
- name: rspec
212
155
  prerelease: false
213
- requirement: &id014 !ruby/object:Gem::Requirement
156
+ version_requirements: *2153375600
157
+ - !ruby/object:Gem::Dependency
158
+ name: rspec
159
+ requirement: &2153375100 !ruby/object:Gem::Requirement
214
160
  none: false
215
- requirements:
161
+ requirements:
216
162
  - - ~>
217
- - !ruby/object:Gem::Version
218
- hash: 7
219
- segments:
220
- - 2
221
- version: "2"
163
+ - !ruby/object:Gem::Version
164
+ version: '2'
222
165
  type: :development
223
- version_requirements: *id014
224
- - !ruby/object:Gem::Dependency
225
- name: webmock
226
166
  prerelease: false
227
- requirement: &id015 !ruby/object:Gem::Requirement
167
+ version_requirements: *2153375100
168
+ - !ruby/object:Gem::Dependency
169
+ name: webmock
170
+ requirement: &2153374720 !ruby/object:Gem::Requirement
228
171
  none: false
229
- requirements:
230
- - - ">="
231
- - !ruby/object:Gem::Version
232
- hash: 3
233
- segments:
234
- - 0
235
- version: "0"
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
236
176
  type: :development
237
- version_requirements: *id015
238
- - !ruby/object:Gem::Dependency
239
- name: autotest
240
177
  prerelease: false
241
- requirement: &id016 !ruby/object:Gem::Requirement
178
+ version_requirements: *2153374720
179
+ - !ruby/object:Gem::Dependency
180
+ name: autotest
181
+ requirement: &2153374260 !ruby/object:Gem::Requirement
242
182
  none: false
243
- requirements:
244
- - - ">="
245
- - !ruby/object:Gem::Version
246
- hash: 3
247
- segments:
248
- - 0
249
- version: "0"
183
+ requirements:
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
250
187
  type: :development
251
- version_requirements: *id016
252
- - !ruby/object:Gem::Dependency
253
- name: autotest-growl
254
188
  prerelease: false
255
- requirement: &id017 !ruby/object:Gem::Requirement
189
+ version_requirements: *2153374260
190
+ - !ruby/object:Gem::Dependency
191
+ name: autotest-growl
192
+ requirement: &2153373840 !ruby/object:Gem::Requirement
256
193
  none: false
257
- requirements:
258
- - - ">="
259
- - !ruby/object:Gem::Version
260
- hash: 3
261
- segments:
262
- - 0
263
- version: "0"
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
264
198
  type: :development
265
- version_requirements: *id017
199
+ prerelease: false
200
+ version_requirements: *2153373840
266
201
  description: Consume RESTful APIs effortlessly
267
- email:
202
+ email:
268
203
  - cyril.rohr@gmail.com
269
- executables:
204
+ executables:
270
205
  - restfully
271
206
  extensions: []
272
-
273
- extra_rdoc_files:
207
+ extra_rdoc_files:
274
208
  - LICENSE
275
209
  - README.md
276
- files:
210
+ files:
277
211
  - bin/restfully
278
212
  - lib/restfully/collection.rb
279
213
  - lib/restfully/configuration.rb
@@ -325,43 +259,32 @@ files:
325
259
  - Rakefile
326
260
  - LICENSE
327
261
  - README.md
328
- has_rdoc: true
329
262
  homepage: http://github.com/crohr/restfully
330
263
  licenses: []
331
-
332
264
  post_install_message:
333
- rdoc_options:
265
+ rdoc_options:
334
266
  - --charset=UTF-8
335
- require_paths:
267
+ require_paths:
336
268
  - lib
337
- required_ruby_version: !ruby/object:Gem::Requirement
269
+ required_ruby_version: !ruby/object:Gem::Requirement
338
270
  none: false
339
- requirements:
340
- - - ">="
341
- - !ruby/object:Gem::Version
342
- hash: 31
343
- segments:
344
- - 1
345
- - 8
346
- version: "1.8"
347
- required_rubygems_version: !ruby/object:Gem::Requirement
271
+ requirements:
272
+ - - ! '>='
273
+ - !ruby/object:Gem::Version
274
+ version: '1.8'
275
+ required_rubygems_version: !ruby/object:Gem::Requirement
348
276
  none: false
349
- requirements:
350
- - - ">="
351
- - !ruby/object:Gem::Version
352
- hash: 9
353
- segments:
354
- - 1
355
- - 3
356
- version: "1.3"
277
+ requirements:
278
+ - - ! '>='
279
+ - !ruby/object:Gem::Version
280
+ version: '1.3'
357
281
  requirements: []
358
-
359
282
  rubyforge_project:
360
- rubygems_version: 1.6.2
283
+ rubygems_version: 1.8.11
361
284
  signing_key:
362
285
  specification_version: 3
363
286
  summary: Consume RESTful APIs effortlessly
364
- test_files:
287
+ test_files:
365
288
  - spec/fixtures/bonfire-collection-with-fragments.xml
366
289
  - spec/fixtures/bonfire-compute-existing.xml
367
290
  - spec/fixtures/bonfire-empty-collection.xml