require 'rubygems' require 'test/unit' require 'mechanize' require "yahoo-weather" require 'weather_in_poland' class TestAPI < Test::Unit::TestCase def setup @weather = WeatherInPoland.new @response = @weather.find_city end def test_find_city location = 'Pomorskie, Gdynia' correct_city = 'Gdynia' correct_code = 493421 assert @response assert_equal(correct_city, @weather.city) assert_equal(correct_code, @weather.code) end def test_get_weather @data = @weather.get_weather(@weather.code) assert_not_nil(@data) end def test_wind_direction @data = @weather.get_weather(@weather.code) direction = get_wind_direction(@data) assert_not_nil direction end def test_get_image @data = @weather.get_weather(@weather.code) assert_not_nil(@data.condition.code) assert_not_nil(@data.astronomy.sunrise) assert_not_nil(@data.astronomy.sunset) end end