Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
Specs for responding with static files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Arcieri committed Sep 12, 2013
1 parent 3ea7e2f commit 8c66e4a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/reel/response_writer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'spec_helper'

describe Reel::Response::Writer do
let(:fixture_path) { File.expand_path("../../fixtures/example.txt", __FILE__) }
let(:expected_response) { "HTTP/1.1 200 OK\r\nContent-Length: 56\r\n\r\n#{File.read(fixture_path)}" }
it "streams static files" do
with_socket_pair do |socket, peer|
writer = described_class.new(socket)

File.open(fixture_path, 'r') do |file|
response = Reel::Response.new(:ok, {}, file)
writer.handle_response(response)
end

peer.readpartial(4096).should eq expected_response
end
end
end

1 comment on commit 8c66e4a

@digitalextremist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very helpful, thank you @tarcieri.

Please sign in to comment.