restfully 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.5.9
2
+ * fixed bug in #http_methods that made a resource not removable unless force reloading it
3
+
1
4
  0.5.8
2
5
  * explicit dependency on 'json' >= 1.2.0
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.8
1
+ 0.5.9
@@ -14,7 +14,7 @@ require 'restfully/collection'
14
14
 
15
15
 
16
16
  module Restfully
17
- VERSION = "0.5.8"
17
+ VERSION = "0.5.9"
18
18
  class << self
19
19
  attr_accessor :adapter
20
20
  end
@@ -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
 
@@ -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"
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-29}
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}
@@ -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.8
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-29 00:00:00 +02:00
12
+ date: 2010-03-31 00:00:00 +02:00
13
13
  default_executable: restfully
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency