sinatra-rest-helpers 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -38,8 +38,9 @@ module Sinatra
38
38
  if selected_format.nil?
39
39
  halt 406, supported_formats.map{|f|
40
40
  output = f["type"]
41
- output += ";level=#{f["level"]}" if f.has_key?("level")
42
- }.join(", ")
41
+ output.concat(";level=#{f["level"]}") if f.has_key?("level")
42
+ output
43
+ }.join(",")
43
44
  else
44
45
  response.headers['Content-Type'] = "#{selected_format["type"]}#{selected_format["level"].nil? ? "" : ";level=#{selected_format["level"]}"}"
45
46
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra-rest-helpers}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
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"]
@@ -31,10 +31,13 @@ describe "SinatraRestHelpers" do
31
31
  end
32
32
  describe ":provides" do
33
33
  it "should throw a 406 if the client requested only unsupported formats" do
34
- request = mock("request", :accept => ["application/json"])
34
+ mime :json, 'application/json'
35
+ mime :xml, 'application/xml'
36
+ mime :object_json, 'application/vnd.com.example.Object+json;level=1'
37
+ request = mock("request", :accept => ["text/plain"])
35
38
  app = App.new(request)
36
- app.should_receive(:halt).with(406, "")
37
- app.test_provides!(:json)
39
+ app.should_receive(:halt).with(406, "application/json,application/xml,application/vnd.com.example.Object+json;level=1")
40
+ app.test_provides!(:json, :xml, :object_json)
38
41
  end
39
42
  it "should not throw a 406 if the client requested a supported format" do
40
43
  request = mock("request", :accept => ["application/json"])
@@ -54,7 +57,7 @@ describe "SinatraRestHelpers" do
54
57
  it "should not accept a request with a type level lower than what is supported" do
55
58
  request = mock("request", :accept => ["application/json;level=1"])
56
59
  app = App.new(request)
57
- app.should_receive(:halt).with(406, "application/json;level=3, application/json;level=2")
60
+ app.should_receive(:halt).with(406, "application/json;level=3,application/json;level=2")
58
61
  app.test_provides!("application/json;level=3", "application/json;level=2")
59
62
  end
60
63
  it "should accept a request having a supported mime type, but with no level" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-rest-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Rohr