Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

TestApp /download uses :to_path, Rake::Lint workaround

  • Loading branch information...
commit 8f6170a855931ecb84d90d801f5c7f891ac784ff 1 parent 21a89d5
@dekellum authored
Showing with 23 additions and 8 deletions.
  1. +1 −2  spec/fishwife_spec.rb
  2. +17 −0 spec/spec_helper.rb
  3. +5 −6 spec/test_app.rb
View
3  spec/fishwife_spec.rb
@@ -50,6 +50,7 @@ def post(path, params = nil, headers = {}, body = nil)
after(:all) do
@server.stop
+ @server.join
end
it "returns 200 OK" do
@@ -134,8 +135,6 @@ def post(path, params = nil, headers = {}, body = nil)
response = get("/download")
response.code.should == "200"
response['Content-Type'].should == 'image/png'
- response['Content-Disposition'].should ==
- 'attachment; filename=reddit-icon.png'
checksum = Digest::MD5.hexdigest(response.body)
checksum.should == '8da4b60a9bbe205d4d3699985470627e'
end
View
17 spec/spec_helper.rb
@@ -31,3 +31,20 @@
require 'fishwife'
Thread.abort_on_exception = true
+
+# Adjust Rack::Lint to not interfere with File body.to_path
+class Rack::Lint
+
+ def respond_to?( mth )
+ if mth == :to_path
+ @body.respond_to?( :to_path )
+ else
+ super
+ end
+ end
+
+ def to_path
+ @body.to_path
+ end
+
+end
View
11 spec/test_app.rb
@@ -104,12 +104,11 @@ def pull(request)
end
def download(request)
- file = File.new('spec/data/reddit-icon.png', 'r')
- response = Rack::Response.new(file)
- response['Content-Type'] = 'image/png'
- response['Content-Disposition'] =
- 'attachment; filename=reddit-icon.png'
- response.finish
+ file = File.new( File.dirname( __FILE__ ) + "/data/reddit-icon.png" )
+ def file.to_path
+ path
+ end
+ [ 200, { "Content-Type" => "image/png" }, file ]
end
def upload(request)
Please sign in to comment.
Something went wrong with that request. Please try again.