haml_interceptor 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/TODO.md CHANGED
@@ -1 +0,0 @@
1
- * Recursively parse JSON bodies for HTML to Hamlize
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{haml_interceptor}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Scofield"]
@@ -7,7 +7,11 @@ class HamlInterceptor
7
7
 
8
8
  def call(env)
9
9
  status, headers, resp = @app.call(env)
10
- body = resp.body.respond_to?(:join) ? resp.body.join : resp.body
10
+ body = if resp.respond_to?(:body)
11
+ resp.body.respond_to?(:join) ? resp.body.join : resp.body
12
+ else
13
+ resp
14
+ end
11
15
 
12
16
  if js_response?(env, headers)
13
17
  body = parse(body)
@@ -12,6 +12,9 @@ class SampleApp
12
12
  elsif request.path == '/json'
13
13
  content_type = 'application/javascript'
14
14
  body = JSON.generate({:name => 'Boneshaker', :markup => '<h1>Boneshaker</h1><div id="author"><p>by Cherie Priest</p></div>'})
15
+ elsif request.path == '/empty'
16
+ content_type = 'text/html'
17
+ body = []
15
18
  end
16
19
 
17
20
  return Rack::Response.new(body, 200, {'Content-Type' => content_type}).finish
@@ -38,4 +38,10 @@ HAML
38
38
  assert_equal JSON.parse('{"name":"Boneshaker\n", "markup":"%h1 Boneshaker\n#author\n %p by Cherie Priest\n"}'),
39
39
  JSON.parse(last_response.body)
40
40
  end
41
+
42
+ def test_it_should_handle_empty_bodies
43
+ assert_nothing_raised do
44
+ get '/empty'
45
+ end
46
+ end
41
47
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: haml_interceptor
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.0
5
+ version: 0.4.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Scofield
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- hash: -1031114291824803886
152
+ hash: 3461632714940041838
153
153
  segments:
154
154
  - 0
155
155
  version: "0"