Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Integration test

  • Loading branch information...
commit 5ce5f740e1c4126de13b6d529bf9c4f352d1d9d2 1 parent de44b8e
Greg authored
Showing with 57 additions and 0 deletions.
  1. +57 −0 test/integration/go_fish_test.rb
View
57 test/integration/go_fish_test.rb
@@ -0,0 +1,57 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class GoFishTest < Test::Unit::TestCase
+
+ def setup
+ end
+
+ def teardown
+ end
+
+ def test_fish_today_pop_eq_0
+ install_weather_service_uri_mocks(0)
+ assert_positive_response GoFish.fish_today?
+ end
+
+ def test_fish_today_pop_eq_100
+ install_weather_service_uri_mocks(100)
+ assert_negative_response GoFish.fish_today?
+ end
+
+ def test_fish_today_pop_eq_25
+ pop = 25
+ install_weather_service_uri_mocks(pop)
+ assert_positive_response GoFish.fish_today?
+ end
+
+ def test_fish_today_pop_eq_26
+ pop = 26
+ install_weather_service_uri_mocks(pop)
+ assert_negative_response GoFish.fish_today?
+ end
+
+private
+
+ def assert_positive_response(response)
+ assert_equal GoFish.positive_response, response
+ end
+
+ def assert_negative_response(response)
+ assert_equal GoFish.negative_response, response
+ end
+
+ def install_weather_service_uri_mocks(pop)
+ uri = mock()
+ xml = weather_forecast_xml(pop)
+ URI.expects(:parse).returns(uri)
+ uri.expects(:read).returns(xml)
+ end
+
+ def weather_forecast_xml(pop)
+ xml_file = File.open(File.join(File.dirname(__FILE__), '..', 'fixtures', 'noaa_weather.xml.erb'), 'r')
+ xml_str = ERB.new(xml_file.read, 0, "%<>").result binding
+ xml_file.close
+ xml_str
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.