Sha256: 7a58e1a64715c60772377e0f33190c606be48be6b734a373f56818803f5ad168

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'test_helper'

class TestWeather < MiniTest::Unit::TestCase
  include WeatherReport

  def setup
    @id = Weather.request_cityid("東京")
    @weather = Weather.new(@id)
  end

  def test_initialize
    assert_raises ArgumentError do
      Weather.new
    end
    assert_instance_of Weather, Weather.new(@id)
  end

  def test_today
    assert_respond_to @weather, :today

    today = @weather.today
    assert_instance_of Day, today
  end

  def test_tomorrow
    assert_respond_to @weather, :tomorrow

    tomorrow = @weather.tomorrow
    assert_instance_of Day, tomorrow
  end

  def test_day_after_tomorrow
    assert_respond_to @weather, :day_after_tomorrow

    day_after_tomorrow = @weather.day_after_tomorrow
    assert_instance_of Day, day_after_tomorrow
  end

  def test_request_cityid
    assert_respond_to Weather, :request_cityid
    assert_equal "130010", Weather.request_cityid("東京")
    assert_equal "140010", Weather.request_cityid("横浜")
    assert_raises(WeatherReportError) do
      Weather.request_cityid(nil)
    end
  end

  def test_to_h
    assert_respond_to @weather, :to_h
    puts @weather.to_h
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
weather-report-0.2.1 test/weather-report/test_weather.rb
weather-report-0.2.0 test/weather-report/test_weather.rb