Skip to content

Instantly share code, notes, and snippets.

@tra38
Created February 6, 2016 17:02
Show Gist options
  • Save tra38/f990c15e07dd3aeb0411 to your computer and use it in GitHub Desktop.
Save tra38/f990c15e07dd3aeb0411 to your computer and use it in GitHub Desktop.
Cool Tests
require_relative '../request'
require 'stringio'
RSpec.describe "Request" do
before do
mock_server = StringIO.new
#begin-pseudocode:
#Get server to output the following string with each line
# "GET / HTTP/1.1\r\n","Host: localhost:2000\r\n","Connection: keep-alive\r\n","Cache-Control: max-age=0\r\n","Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\n","Upgrade-Insecure-Requests: 1\r\n","User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36\r\n","Accept-Encoding: gzip, deflate, sdch\r\n","Accept-Language: en-US,en;q=0.8\r\n","\r\n"
#end-pseudocode
request = Request.new(mock_server)
end
it "extracts out the uri successfully" do
expect(request.uri).to eq("GET / HTTP/1.1")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment