Skip to content

Commit

Permalink
Merge pull request #56 from jamsi/master
Browse files Browse the repository at this point in the history
Fixed issue with weather test in a different timezone
  • Loading branch information
justinweiss committed Sep 2, 2018
2 parents 6b6ae6a + 9abfe17 commit a050b79
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -4,6 +4,7 @@ rvm:
# - 1.9.3
- 2.0
- 2.1
- 2.2.4
# - jruby-18mode # JRuby in 1.8 mode
# - jruby-19mode # JRuby in 1.9 mode
# - rbx-18mode
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Expand Up @@ -39,7 +39,7 @@ GEM
test-unit (3.1.5)
power_assert
tilt (1.4.1)
time-warp (1.0.8)
time-warp (1.0.15)
twss (0.0.5)
classifier (= 1.3.1)
webmock (1.6.4)
Expand All @@ -66,4 +66,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
1.11.2
1.13.1
2 changes: 2 additions & 0 deletions README.rdoc
@@ -1,3 +1,5 @@
{<img src="https://travis-ci.org/justinweiss/robut.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/justinweiss/robut]

= Robut

The friendly plugin-enabled HipChat bot.
Expand Down
3 changes: 3 additions & 0 deletions Rakefile
Expand Up @@ -25,3 +25,6 @@ Rake::RDocTask.new do |rd|
rd.rdoc_dir = 'doc'
end

task :console do
exec "irb -r robut -I ./lib"
end
2 changes: 1 addition & 1 deletion lib/robut/plugin/weather.rb
Expand Up @@ -18,7 +18,7 @@ def usage
"#{at_nick} weather <location> Tuesday - returns the weather for <location> Tuesday"
]
end

def handle(time, sender_nick, message)
# ignore messages that don't end in ?
return unless message[message.length - 1, 1] == "?"
Expand Down
51 changes: 50 additions & 1 deletion test/fixtures/seattle.xml
@@ -1 +1,50 @@
<?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><forecast_information><city data="Seattle, WA"/><postal_code data="Seattle"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2011-05-23"/><current_date_time data="2011-05-23 22:52:57 +0000"/><unit_system data="US"/></forecast_information><current_conditions><condition data="Mostly Cloudy"/><temp_f data="58"/><temp_c data="14"/><humidity data="Humidity: 45%"/><icon data="/ig/images/weather/mostly_cloudy.gif"/><wind_condition data="Wind: E at 7 mph"/></current_conditions><forecast_conditions><day_of_week data="Mon"/><low data="48"/><high data="59"/><icon data="/ig/images/weather/partly_cloudy.gif"/><condition data="Partly Cloudy"/></forecast_conditions><forecast_conditions><day_of_week data="Tue"/><low data="51"/><high data="67"/><icon data="/ig/images/weather/partly_cloudy.gif"/><condition data="Partly Cloudy"/></forecast_conditions><forecast_conditions><day_of_week data="Wed"/><low data="49"/><high data="61"/><icon data="/ig/images/weather/rain.gif"/><condition data="Showers"/></forecast_conditions><forecast_conditions><day_of_week data="Thu"/><low data="49"/><high data="57"/><icon data="/ig/images/weather/rain.gif"/><condition data="Showers"/></forecast_conditions></weather></xml_api_reply>
<?xml version="1.0" encoding="UTF-8"?>
<xml_api_reply version="1">
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
<forecast_information>
<city data="Seattle, WA" />
<postal_code data="Seattle" />
<latitude_e6 data="" />
<longitude_e6 data="" />
<forecast_date data="2011-05-23" />
<current_date_time data="2011-05-23 22:52:57 +0000" />
<unit_system data="US" />
</forecast_information>
<current_conditions>
<condition data="Mostly Cloudy" />
<temp_f data="58" />
<temp_c data="14" />
<humidity data="Humidity: 45%" />
<icon data="/ig/images/weather/mostly_cloudy.gif" />
<wind_condition data="Wind: E at 7 mph" />
</current_conditions>
<forecast_conditions>
<day_of_week data="Mon" />
<low data="48" />
<high data="59" />
<icon data="/ig/images/weather/partly_cloudy.gif" />
<condition data="Partly Cloudy" />
</forecast_conditions>
<forecast_conditions>
<day_of_week data="Tue" />
<low data="51" />
<high data="67" />
<icon data="/ig/images/weather/partly_cloudy.gif" />
<condition data="Partly Cloudy" />
</forecast_conditions>
<forecast_conditions>
<day_of_week data="Wed" />
<low data="49" />
<high data="61" />
<icon data="/ig/images/weather/rain.gif" />
<condition data="Showers" />
</forecast_conditions>
<forecast_conditions>
<day_of_week data="Thu" />
<low data="49" />
<high data="57" />
<icon data="/ig/images/weather/rain.gif" />
<condition data="Showers" />
</forecast_conditions>
</weather>
</xml_api_reply>
6 changes: 3 additions & 3 deletions test/unit/plugin/weather_test.rb
Expand Up @@ -51,7 +51,7 @@ def test_no_question_mark
def test_handle_day
stub_request(:any, "http://www.google.com/ig/api?weather=Seattle").to_return(:body => File.open(File.expand_path("../../../fixtures/seattle.xml", __FILE__), "r").read)

pretend_now_is(2011,"may",23,17) do
pretend_now_is(Time.parse("2011/05/23 17:00")) do
@plugin.handle(Time.now, "John", "Seattle weather tuesday?")
assert_equal( ["Forecast for Seattle, WA on Tue: Partly Cloudy, High: 67F, Low: 51F"], @plugin.reply_to.replies )
end
Expand All @@ -60,7 +60,7 @@ def test_handle_day
def test_handle_tomorrow
stub_request(:any, "http://www.google.com/ig/api?weather=Seattle").to_return(:body => File.open(File.expand_path("../../../fixtures/seattle.xml", __FILE__), "r").read)

pretend_now_is(2011,"may",23,17) do
pretend_now_is(Time.parse("2011/05/23 17:00")) do
@plugin.handle(Time.now, "John", "Seattle weather tomorrow?")
assert_equal( ["Forecast for Seattle, WA on Tue: Partly Cloudy, High: 67F, Low: 51F"], @plugin.reply_to.replies )
end
Expand All @@ -69,7 +69,7 @@ def test_handle_tomorrow
def test_handle_today
stub_request(:any, "http://www.google.com/ig/api?weather=Seattle").to_return(:body => File.open(File.expand_path("../../../fixtures/seattle.xml", __FILE__), "r").read)

pretend_now_is(2011,"may",23,17) do
pretend_now_is(Time.parse("2011/05/23 17:00")) do
@plugin.handle(Time.now, "John", "Seattle weather today?")
assert_equal( ["Forecast for Seattle, WA on Mon: Partly Cloudy, High: 59F, Low: 48F"], @plugin.reply_to.replies )
end
Expand Down

0 comments on commit a050b79

Please sign in to comment.