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

Added tests for Reel::Request #227

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions spec/reel/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,11 @@ def test_chunked_response(request, client)
it "returns friendlier inspect output" do
with_socket_pair do |client, peer|
connection = Reel::Connection.new(peer)
client << ExampleRequest.new.to_s
example_request = ExampleRequest.new
client << example_request.to_s
request = connection.request

expect(request.inspect).to eq '#<Reel::Request GET / HTTP/1.1 @headers={"Host"=>"www.example.com", "Connection"=>"keep-alive", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.78 S", "Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Encoding"=>"gzip,deflate,sdch", "Accept-Language"=>"en-US,en;q=0.8", "Accept-Charset"=>"ISO-8859-1,utf-8;q=0.7,*;q=0.3"}>'
expect(request.inspect).to eq example_request.inspect_method
end
end

Expand Down
4 changes: 4 additions & 0 deletions spec/support/example_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ def to_s
@headers.map { |k, v| "#{k}: #{v}" }.join("\r\n") << "\r\n\r\n" <<
(@body ? @body : '')
end

def inspect_method
Copy link
Member Author

Choose a reason for hiding this comment

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

I think I could do better with naming this stub. Do you have any suggestions?

"#<Reel::Request #{@method} #{path} HTTP/#{version} @headers=#{@headers}>"
end
end