Sha256: 06e2d519679b2cecc4bac26f02af0c35e056571b22e7250213ceee68c661e0f0
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require 'spec_helper' describe UndergroundWeather::ApiCall do before do @api_key = 'apikey' @feature = 'forecast' @query = '19106' @uw = UndergroundWeather::ApiCall.new(@api_key, @feature, @query) end it "can be initialized with api_key, forecast, and query" do @uw.must_be_instance_of(UndergroundWeather::ApiCall) end it "should not have an error if no call has been made" do @uw.error.must_equal(false) end it "should have an error if http response code is not 200" do http_response = mock() http_response.expects(:code).returns('404') Net::HTTP.stubs(:get_response).returns(http_response) @uw.get! @uw.error.must_equal(true) end it "should not have an error if http response code is 200" do http_response = mock() http_response.expects(:code).returns('200') http_response.expects(:body).returns({}) Net::HTTP.stubs(:get_response).returns(http_response) @uw.get! @uw.error.must_equal(false) end it "should return correct url" do @uw.url.to_s.must_equal(URI.parse("http://api.wunderground.com/api/apikey/forecast/q/19106.json").to_s) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
undergroundweather-0.0.3 | spec/undergroundweather/api_call_spec.rb |