sinatra-rest-helpers 0.5.1 → 0.5.2

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.1
1
+ 0.5.2
@@ -58,6 +58,8 @@ module Sinatra
58
58
  halt 400, "Input data size must not be empty and must not exceed #{options[:limit]} bytes." if (options[:limit] && input_data.length > options[:limit]) || input_data.length == 0
59
59
  parser_selector.select(mime_type).load(input_data)
60
60
  end
61
+ rescue StandardError => e
62
+ halt 400, "#{e.class.name}: #{e.message}"
61
63
  end
62
64
 
63
65
  def compute_etag(*args) # :nodoc:
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra-rest-helpers}
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
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{2009-10-22}
12
+ s.date = %q{2009-10-30}
13
13
  s.description = %q{A set of helpers for sinatra apps that expose REST resources.}
14
14
  s.email = %q{cyril.rohr@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -134,6 +134,15 @@ describe "SinatraRestHelpers" do
134
134
  app.should_receive(:halt).with(400, /must provide a Content-Type HTTP header/)
135
135
  app.test_parse_input_data!(parser_selector)
136
136
  end
137
+ it "should return 400 if the request's body is not parseable" do
138
+ require 'json'
139
+ parser_selector = mock("parser_selector")
140
+ request = mock("request", :env => {'rack.input' => StringIO.new('{"foo": bar"}'), 'CONTENT_TYPE' => 'application/json'})
141
+ app = App.new(request)
142
+ parser_selector.should_receive(:select).with('application/json').and_return(JSON)
143
+ app.should_receive(:halt).with(400, /unexpected token at '\{"foo": bar"\}'/)
144
+ app.test_parse_input_data!(parser_selector)
145
+ end
137
146
  end
138
147
 
139
148
  describe ":compute_etag" 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.1
4
+ version: 0.5.2
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: 2009-10-22 00:00:00 +02:00
12
+ date: 2009-10-30 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15