Created
May 6, 2014 19:42
-
-
Save craftninja/836c7d3598be02103a9a to your computer and use it in GitHub Desktop.
Warmups - parsing http - first pomodoro (finishup)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
require 'json' | |
class HttpResponse | |
def initialize(url) | |
@response = Faraday.get url | |
end | |
def headers | |
@response.body | |
end | |
end | |
hr = HttpResponse | |
hr.headers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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