Skip to content

Commit e140c4d

Browse files
dileepnandanamcoderhs
authored andcommitted
specs for weather history
1 parent 9444c1c commit e140c4d

File tree

7 files changed

+347
-0
lines changed

7 files changed

+347
-0
lines changed

spec/fixtures/cassettes/api/history_city_id_invalid.yml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/cassettes/api/history_city_id_valid.yml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/cassettes/api/history_city_invalid.yml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/cassettes/api/history_city_valid.yml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/cassettes/api/history_geocode_invalid.yml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/cassettes/api/history_geocode_valid.yml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/open_weather/api_spec.rb

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,68 @@
266266
end
267267
end
268268
end
269+
270+
271+
272+
273+
274+
275+
276+
277+
278+
279+
280+
281+
282+
283+
284+
describe 'Open weather History API' do
285+
context '.city' do
286+
it 'return current weather for cochi' do
287+
response = VCR.use_cassette('api/history_city_valid') do
288+
OpenWeather::History.city('Cochin, In')
289+
end
290+
response['cod'].should eq('200')
291+
292+
end
293+
294+
it 'returns error if the city is invalid' do
295+
response = VCR.use_cassette('api/history_city_invalid') do
296+
OpenWeather::History.city('Cochiiiiiin, In')
297+
end
298+
response['error'].should eq('404')
299+
end
300+
end
301+
302+
context '.city_id' do
303+
it 'return current weather for city id of cochi' do
304+
response = VCR.use_cassette('api/history_city_id_valid') do
305+
OpenWeather::History.city_id('1273874')
306+
end
307+
response['cod'].should eq('200')
308+
end
309+
310+
it 'returns error if the city id is invalid' do
311+
response = VCR.use_cassette('api/history_city_id_invalid') do
312+
OpenWeather::History.city('invalidid')
313+
end
314+
response['error'].should eq('404')
315+
end
316+
end
317+
318+
context '.geocode' do
319+
it 'return current weather for geocode of cochi' do
320+
response = VCR.use_cassette('api/history_geocode_valid') do
321+
OpenWeather::History.geocode('9.94', '76.26')
322+
end
323+
response['cod'].should eq('200')
324+
end
325+
326+
it 'returns error if the geocode is invalid' do
327+
response = VCR.use_cassette('api/history_geocode_invalid') do
328+
OpenWeather::History.geocode('181', '181')
329+
end
330+
response['error'].should eq('404')
331+
end
332+
end
333+
end

0 commit comments

Comments
 (0)