Sha256: 391125e602d8aef2429dacd08875858edec841295834ece4f52ec3c55cefd6c4

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

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

class TestWeatherReport < 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_includes(today, "date")
    assert_includes(today, "telop")
    assert_includes(today, "temperature")
  end

  def test_tomorrow
    assert_respond_to @weather, :tomorrow

    tomorrow = @weather.tomorrow
    assert_includes(tomorrow, "date")
    assert_includes(tomorrow, "telop")
    assert_includes(tomorrow, "temperature")
  end

  def test_day_after_tomorrow
    assert_respond_to @weather, :day_after_tomorrow

    day_after_tomorrow = @weather.day_after_tomorrow
    assert_includes(day_after_tomorrow, "date")
    assert_includes(day_after_tomorrow, "telop")
    assert_includes(day_after_tomorrow, "temperature")
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
weather-report-0.0.1 test/test_weather-report.rb