Add spec for binary data

This commit is contained in:
galfert 2012-11-02 13:07:59 +01:00
parent 39355ff0f2
commit fa6235cd1f
2 changed files with 23 additions and 1 deletions

BIN
spec/fixtures/rockrule.jpeg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -177,7 +177,6 @@ describe "App with Riak backend" do
end
it "delivers the data correctly" do
header "Authorization", "Bearer 123"
get "/jimmy/documents/jason"
last_response.body.must_equal '{"foo":"bar","unhosted":1}'
@ -185,6 +184,29 @@ describe "App with Riak backend" do
end
end
context "with binary data" do
before do
header "Content-Type", "image/jpeg; charset=binary"
filename = File.join(File.expand_path(File.dirname(__FILE__)), "fixtures", "rockrule.jpeg")
@image = File.open(filename, "r").read
put "/jimmy/documents/jaypeg", @image
end
it "uses the requested content type" do
get "/jimmy/documents/jaypeg"
last_response.status.must_equal 200
last_response.content_type.must_equal "image/jpeg; charset=binary"
end
it "delivers the data correctly" do
get "/jimmy/documents/jaypeg"
last_response.status.must_equal 200
last_response.body.must_equal @image
end
end
context "with escaped key" do
before do
put "/jimmy/documents/http%3A%2F%2F5apps.com", "super website"