Skip to content

Instantly share code, notes, and snippets.

@craftninja
Created May 6, 2014 19:42
Show Gist options
  • Save craftninja/836c7d3598be02103a9a to your computer and use it in GitHub Desktop.
Save craftninja/836c7d3598be02103a9a to your computer and use it in GitHub Desktop.
Warmups - parsing http - first pomodoro (finishup)
require 'faraday'
require 'json'
class HttpResponse
def initialize(url)
@response = Faraday.get url
end
def headers
@response.body
end
end
hr = HttpResponse
hr.headers
require_relative '../lib/http_response'
require 'rspec'
describe 'HttpResponse' do
it 'returns a hash of headers' do
url='http://api.openweathermap.org/data/2.5/weather?q=Denver&units=imperial'
http_response = HttpResponse.new(url)
expect(url.class).to eq(String)
headers = http_response.headers
expect(headers.class).to eq(Hash)
expect(headers.keys.first).to eq(String)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment