Sha256: 9f951ada6616c6e9aba70a9951896fdb1c1d008bf9f8d5485cbce3ac2ef69f3f
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
require 'spec_helper' describe OpenWeatherAPI::API do describe 'When fetching current weather' do let(:api) { OpenWeatherAPI::API.new( api_key: ENV['OPEN_WEATHER_API_KEY'], default_language: 'es', default_country_code: 'es' ) } it 'should retrieve data by city name' do expect(api.current(city: 'Santa Cruz de Tenerife')[:cod].to_i).to eq(200) end it 'should retrieve data by city id' do expect(api.current(id: 6360638)[:cod].to_i).to eq(200) end it 'should retrieve data by cities ids' do response = api.current(id: [6360638, 2511401]) expect(response[:cod].to_i).not_to be >= 400 end it 'should retrieve data by geolocation' do expect(api.current(lon: -16.20302, lat: 28.53924)[:cod].to_i).to eq(200) end it 'should retrieve data by zipcode' do expect(api.current(zipcode: 38190)[:cod].to_i).to eq(200) end it 'should retrieve data by bounding box' do expect(api.current(rectangle: { topleft: { lat: -16.3319, lon: 28.5046 }, bottomright: { lat: -16.1972, lon: 28.4400}, zoom: 10 })[:cod].to_i).to eq(200) end it 'should retrieve data by circle' do expect(api.current(circle: { lat: -16.3319, lon: 28.5046 }, cities_count: 2)[:cod].to_i).to eq(200) end it 'works with a given block' do json1, json2 = nil json1 = api.current(city: 'Santa Cruz de Tenerife') { |json| json2 = json } expect(json1).to eq(json2) end it 'works with xml format' do expect(api.current(city: 'Santa Cruz de Tenerife', mode: :xml)).not_to be_nil end it 'works with html format' do expect(api.current(city: 'Santa Cruz de Tenerife', mode: :html)).not_to be_nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
open-weather-api-0.0.6 | spec/current_weather_spec.rb |
open-weather-api-0.0.5 | spec/current_weather_spec.rb |