restfully 0.5.8 → 0.5.9
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.
- data/CHANGELOG +3 -0
- data/VERSION +1 -1
- data/lib/restfully.rb +1 -1
- data/lib/restfully/resource.rb +1 -1
- data/restfully.gemspec +2 -2
- data/spec/resource_spec.rb +31 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.9
|
data/lib/restfully.rb
CHANGED
data/lib/restfully/resource.rb
CHANGED
@@ -172,7 +172,7 @@ module Restfully
|
|
172
172
|
# => ['GET', 'POST']
|
173
173
|
#
|
174
174
|
def http_methods
|
175
|
-
reload if executed_requests['GET'].nil? || executed_requests['GET']['headers'].nil?
|
175
|
+
reload if executed_requests['GET'].nil? || executed_requests['GET']['headers'].nil? || executed_requests['GET']['headers'].empty?
|
176
176
|
(executed_requests['GET']['headers']['Allow'] || "GET").split(/,\s*/)
|
177
177
|
end
|
178
178
|
|
data/restfully.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{restfully}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Cyril Rohr"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-31}
|
13
13
|
s.default_executable = %q{restfully}
|
14
14
|
s.description = %q{Experimental code for auto-generation of wrappers on top of RESTful APIs that follow HATEOAS principles and provide OPTIONS methods and/or Allow headers.}
|
15
15
|
s.email = %q{cyril.rohr@gmail.com}
|
data/spec/resource_spec.rb
CHANGED
@@ -286,4 +286,35 @@ describe Resource do
|
|
286
286
|
@resource.delete(:query => {:q => 'v'}, :headers => {'Accept' => 'application/json'}).should be_true
|
287
287
|
end
|
288
288
|
end
|
289
|
+
|
290
|
+
describe "supported http methodes" do
|
291
|
+
before do
|
292
|
+
@resource = Resource.new(@uri, @session = mock("session", :logger => @logger))
|
293
|
+
end
|
294
|
+
it "should reload if a GET request has not been executed before" do
|
295
|
+
@resource.should_receive(:executed_requests).ordered.and_return({})
|
296
|
+
@resource.should_receive(:reload).ordered
|
297
|
+
@resource.should_receive(:executed_requests).ordered.and_return({
|
298
|
+
'GET' => {'body' => "xxx", "headers" => {'Allow' => 'POST, PUT'}}
|
299
|
+
})
|
300
|
+
@resource.http_methods.should == ['POST','PUT']
|
301
|
+
end
|
302
|
+
it "should reload if the headers are empty" do
|
303
|
+
@resource.should_receive(:executed_requests).exactly(3).ordered.and_return({
|
304
|
+
'GET' => {'body' => "xxx", "headers" => {}}
|
305
|
+
})
|
306
|
+
@resource.should_receive(:reload).ordered
|
307
|
+
@resource.should_receive(:executed_requests).once.ordered.and_return({
|
308
|
+
'GET' => {'body' => "xxx", "headers" => {'Allow' => 'POST, PUT'}}
|
309
|
+
})
|
310
|
+
@resource.http_methods.should == ['POST','PUT']
|
311
|
+
end
|
312
|
+
it "should not reload if the headers are not empty" do
|
313
|
+
@resource.should_receive(:executed_requests).exactly(4).and_return({
|
314
|
+
'GET' => {'body' => "xxx", "headers" => {'Allow' => 'POST, PUT'}}
|
315
|
+
})
|
316
|
+
@resource.should_not_receive(:reload)
|
317
|
+
@resource.http_methods.should == ['POST','PUT']
|
318
|
+
end
|
319
|
+
end
|
289
320
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restfully
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Rohr
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-31 00:00:00 +02:00
|
13
13
|
default_executable: restfully
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|