{"action":"created","comment":{"url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/comments/51168785","id":51168785,"diff_hunk":"@@ -36,64 +36,66 @@\n \n   describe \".cache_key\" do\n     it \"returns string that includes zip code and date\" do\n-      key = WeatherMan.key_for(10000, DateTime.parse(\"October 1, 2015\"))\n+      key = WeatherMan.key_for(DateTime.parse(\"October 1, 2015\"), 10000)\n       expect(key).to include '10000'\n       expect(key).to include '2015-10-01'\n     end\n   end\n \n   describe \".outdoor_temp_for\" do\n-    it \"only pulls from the NOAA central park weather station\", :vcr do\n-      time = Time.zone.parse(\"Feb 20, 2015 at 8am\")\n-      response = {\n-        \"history\" => {\n-          \"observations\" => [\n-            {\n-              \"date\" => {\n-                \"hour\" => \"8\"\n-              },\n-              \"tempi\" => 30\n-            }\n-          ]\n-        }\n-      }\n+    let(:empty_response) { { \"history\" => { \"observations\" => [] } } }\n+    let(:obs_at_30) { { \"date\" => { \"hour\" => \"08\" }, \"tempi\" => 30 } }\n+    let(:obs_at_45) { { \"date\" => { \"hour\" => \"08\" }, \"tempi\" => 45 } }\n+    let(:response_at_30) { { \"history\" => { \"observations\" => [obs_at_30] } } }\n+    let(:response_at_45) { { \"history\" => { \"observations\" => [obs_at_45] } } }\n+    let(:eight_am) { Time.zone.parse(\"Feb 20, 2015 at 8am\") }\n+    let(:two_pm) { Time.zone.parse(\"Feb 20, 2015 at 2pm\") }\n+    let(:eight_pm) { Time.zone.parse(\"Feb 20, 2015 at 8pm\") }\n+    let(:time) { Time.zone.parse(\"March 1, 2015 at 8am\") }\n+    let(:location) { 'knyc' }\n+    let(:throttle) { 0 }\n \n+    it \"only pulls from the NOAA central park weather station\", :vcr do\n       expect(WeatherMan.api).to receive(:history_for).\n-        with(time, \"knyc\").and_return(response)\n-\n-      WeatherMan.outdoor_temp_for(\n-        time: time,\n-        location: 10004,\n-        throttle: 0\n-      )\n+        with(eight_am, \"knyc\").and_return(response_at_30)\n+      WeatherMan.outdoor_temp_for(eight_am, location, throttle)\n     end\n \n     it \"returns historical outdoor temperature\", :vcr do\n-      temperature = WeatherMan.outdoor_temp_for(\n-        time: Time.zone.parse(\"Feb 20, 2015 at 8am\"),\n-        location: 10004,\n-        throttle: 0\n-      )\n+      temperature = WeatherMan.outdoor_temp_for(eight_am, location, throttle)\n       expect(temperature).to eq 4\n-      temperature = WeatherMan.outdoor_temp_for(\n-        time: Time.zone.parse(\"Feb 20, 2015 at 2pm\"),\n-        location: 10004,\n-        throttle: 0\n-      )\n+      temperature = WeatherMan.outdoor_temp_for(two_pm, location, throttle)\n       expect(temperature).to eq 19\n-      temperature = WeatherMan.outdoor_temp_for(\n-        time: Time.zone.parse(\"Feb 20, 2015 at 8pm\"),\n-        location: 10004,\n-        throttle: 0\n-      )\n+      temperature = WeatherMan.outdoor_temp_for(eight_pm, location, throttle)\n       expect(temperature).to eq 15\n     end\n+\n+    it \"caches responses\" do\n+      allow(WeatherMan.api).to receive(:history_for).and_return(response_at_30)\n+      temp = WeatherMan.outdoor_temp_for(time, 'knyc', 0)\n+      expect(temp).to eq 30\n+\n+      allow(WeatherMan.api).to receive(:history_for).and_return(response_at_45)\n+      temp = WeatherMan.outdoor_temp_for(time, 'knyc', 0)\n+      expect(temp).to eq 30\n+    end\n+\n+    it \"does not cache responses with no observations\" do\n+      allow(WeatherMan.api).to receive(:history_for).and_return(empty_response)\n+      temperature = WeatherMan.outdoor_temp_for(time, 'knyc', 0)","path":"spec/services/weather_man_spec.rb","position":113,"original_position":113,"commit_id":"f7685bad8dcbb6a5c797c7206511c66a7e93d3d1","original_commit_id":"f7685bad8dcbb6a5c797c7206511c66a7e93d3d1","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.","created_at":"2016-01-28T18:57:26Z","updated_at":"2016-01-28T18:57:26Z","html_url":"https://github.com/heatseeknyc/heatseeknyc/pull/82#discussion_r51168785","pull_request_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/82","_links":{"self":{"href":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/comments/51168785"},"html":{"href":"https://github.com/heatseeknyc/heatseeknyc/pull/82#discussion_r51168785"},"pull_request":{"href":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/82"}}},"pull_request":{"url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/82","id":57548212,"html_url":"https://github.com/heatseeknyc/heatseeknyc/pull/82","diff_url":"https://github.com/heatseeknyc/heatseeknyc/pull/82.diff","patch_url":"https://github.com/heatseeknyc/heatseeknyc/pull/82.patch","issue_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues/82","number":82,"state":"open","locked":false,"title":"Refactor WeatherMan and prevent caching nil","user":{"login":"williamcodes","id":4542879,"avatar_url":"https://avatars.githubusercontent.com/u/4542879?v=3","gravatar_id":"","url":"https://api.github.com/users/williamcodes","html_url":"https://github.com/williamcodes","followers_url":"https://api.github.com/users/williamcodes/followers","following_url":"https://api.github.com/users/williamcodes/following{/other_user}","gists_url":"https://api.github.com/users/williamcodes/gists{/gist_id}","starred_url":"https://api.github.com/users/williamcodes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williamcodes/subscriptions","organizations_url":"https://api.github.com/users/williamcodes/orgs","repos_url":"https://api.github.com/users/williamcodes/repos","events_url":"https://api.github.com/users/williamcodes/events{/privacy}","received_events_url":"https://api.github.com/users/williamcodes/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-28T18:57:23Z","updated_at":"2016-01-28T18:57:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2af51345018f44a0527f8c310902311a003e5d95","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/82/commits","review_comments_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/82/comments","review_comment_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues/82/comments","statuses_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/statuses/f7685bad8dcbb6a5c797c7206511c66a7e93d3d1","head":{"label":"heatseeknyc:no-nil-cache","ref":"no-nil-cache","sha":"f7685bad8dcbb6a5c797c7206511c66a7e93d3d1","user":{"login":"heatseeknyc","id":7570070,"avatar_url":"https://avatars.githubusercontent.com/u/7570070?v=3","gravatar_id":"","url":"https://api.github.com/users/heatseeknyc","html_url":"https://github.com/heatseeknyc","followers_url":"https://api.github.com/users/heatseeknyc/followers","following_url":"https://api.github.com/users/heatseeknyc/following{/other_user}","gists_url":"https://api.github.com/users/heatseeknyc/gists{/gist_id}","starred_url":"https://api.github.com/users/heatseeknyc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heatseeknyc/subscriptions","organizations_url":"https://api.github.com/users/heatseeknyc/orgs","repos_url":"https://api.github.com/users/heatseeknyc/repos","events_url":"https://api.github.com/users/heatseeknyc/events{/privacy}","received_events_url":"https://api.github.com/users/heatseeknyc/received_events","type":"Organization","site_admin":false},"repo":{"id":17613188,"name":"heatseeknyc","full_name":"heatseeknyc/heatseeknyc","owner":{"login":"heatseeknyc","id":7570070,"avatar_url":"https://avatars.githubusercontent.com/u/7570070?v=3","gravatar_id":"","url":"https://api.github.com/users/heatseeknyc","html_url":"https://github.com/heatseeknyc","followers_url":"https://api.github.com/users/heatseeknyc/followers","following_url":"https://api.github.com/users/heatseeknyc/following{/other_user}","gists_url":"https://api.github.com/users/heatseeknyc/gists{/gist_id}","starred_url":"https://api.github.com/users/heatseeknyc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heatseeknyc/subscriptions","organizations_url":"https://api.github.com/users/heatseeknyc/orgs","repos_url":"https://api.github.com/users/heatseeknyc/repos","events_url":"https://api.github.com/users/heatseeknyc/events{/privacy}","received_events_url":"https://api.github.com/users/heatseeknyc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/heatseeknyc/heatseeknyc","description":"HeatSeekNYC -- a web-enabled hardware platform to detect heating violations in NYC","fork":false,"url":"https://api.github.com/repos/heatseeknyc/heatseeknyc","forks_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/forks","keys_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/teams","hooks_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/hooks","issue_events_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues/events{/number}","events_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/events","assignees_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/assignees{/user}","branches_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/branches{/branch}","tags_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/tags","blobs_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/refs{/sha}","trees_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/statuses/{sha}","languages_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/languages","stargazers_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/stargazers","contributors_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/contributors","subscribers_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/subscribers","subscription_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/subscription","commits_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/commits{/sha}","git_commits_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/commits{/sha}","comments_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/comments{/number}","issue_comment_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues/comments{/number}","contents_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/contents/{+path}","compare_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/merges","archive_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/downloads","issues_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues{/number}","pulls_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls{/number}","milestones_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/milestones{/number}","notifications_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/labels{/name}","releases_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/releases{/id}","deployments_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/deployments","created_at":"2014-03-11T00:18:22Z","updated_at":"2016-01-25T01:17:13Z","pushed_at":"2016-01-28T18:57:24Z","git_url":"git://github.com/heatseeknyc/heatseeknyc.git","ssh_url":"git@github.com:heatseeknyc/heatseeknyc.git","clone_url":"https://github.com/heatseeknyc/heatseeknyc.git","svn_url":"https://github.com/heatseeknyc/heatseeknyc","homepage":"http://heatseeknyc.com/","size":123990,"stargazers_count":12,"watchers_count":12,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":40,"forks":11,"open_issues":40,"watchers":12,"default_branch":"master"}},"base":{"label":"heatseeknyc:master","ref":"master","sha":"41d75abafddc8a645caccd0000a3eca91b4f2af1","user":{"login":"heatseeknyc","id":7570070,"avatar_url":"https://avatars.githubusercontent.com/u/7570070?v=3","gravatar_id":"","url":"https://api.github.com/users/heatseeknyc","html_url":"https://github.com/heatseeknyc","followers_url":"https://api.github.com/users/heatseeknyc/followers","following_url":"https://api.github.com/users/heatseeknyc/following{/other_user}","gists_url":"https://api.github.com/users/heatseeknyc/gists{/gist_id}","starred_url":"https://api.github.com/users/heatseeknyc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heatseeknyc/subscriptions","organizations_url":"https://api.github.com/users/heatseeknyc/orgs","repos_url":"https://api.github.com/users/heatseeknyc/repos","events_url":"https://api.github.com/users/heatseeknyc/events{/privacy}","received_events_url":"https://api.github.com/users/heatseeknyc/received_events","type":"Organization","site_admin":false},"repo":{"id":17613188,"name":"heatseeknyc","full_name":"heatseeknyc/heatseeknyc","owner":{"login":"heatseeknyc","id":7570070,"avatar_url":"https://avatars.githubusercontent.com/u/7570070?v=3","gravatar_id":"","url":"https://api.github.com/users/heatseeknyc","html_url":"https://github.com/heatseeknyc","followers_url":"https://api.github.com/users/heatseeknyc/followers","following_url":"https://api.github.com/users/heatseeknyc/following{/other_user}","gists_url":"https://api.github.com/users/heatseeknyc/gists{/gist_id}","starred_url":"https://api.github.com/users/heatseeknyc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heatseeknyc/subscriptions","organizations_url":"https://api.github.com/users/heatseeknyc/orgs","repos_url":"https://api.github.com/users/heatseeknyc/repos","events_url":"https://api.github.com/users/heatseeknyc/events{/privacy}","received_events_url":"https://api.github.com/users/heatseeknyc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/heatseeknyc/heatseeknyc","description":"HeatSeekNYC -- a web-enabled hardware platform to detect heating violations in NYC","fork":false,"url":"https://api.github.com/repos/heatseeknyc/heatseeknyc","forks_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/forks","keys_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/teams","hooks_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/hooks","issue_events_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues/events{/number}","events_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/events","assignees_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/assignees{/user}","branches_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/branches{/branch}","tags_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/tags","blobs_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/refs{/sha}","trees_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/statuses/{sha}","languages_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/languages","stargazers_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/stargazers","contributors_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/contributors","subscribers_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/subscribers","subscription_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/subscription","commits_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/commits{/sha}","git_commits_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/git/commits{/sha}","comments_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/comments{/number}","issue_comment_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues/comments{/number}","contents_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/contents/{+path}","compare_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/merges","archive_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/downloads","issues_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues{/number}","pulls_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls{/number}","milestones_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/milestones{/number}","notifications_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/labels{/name}","releases_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/releases{/id}","deployments_url":"https://api.github.com/repos/heatseeknyc/heatseeknyc/deployments","created_at":"2014-03-11T00:18:22Z","updated_at":"2016-01-25T01:17:13Z","pushed_at":"2016-01-28T18:57:24Z","git_url":"git://github.com/heatseeknyc/heatseeknyc.git","ssh_url":"git@github.com:heatseeknyc/heatseeknyc.git","clone_url":"https://github.com/heatseeknyc/heatseeknyc.git","svn_url":"https://github.com/heatseeknyc/heatseeknyc","homepage":"http://heatseeknyc.com/","size":123990,"stargazers_count":12,"watchers_count":12,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":40,"forks":11,"open_issues":40,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/82"},"html":{"href":"https://github.com/heatseeknyc/heatseeknyc/pull/82"},"issue":{"href":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues/82"},"comments":{"href":"https://api.github.com/repos/heatseeknyc/heatseeknyc/issues/82/comments"},"review_comments":{"href":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/82/comments"},"review_comment":{"href":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/heatseeknyc/heatseeknyc/pulls/82/commits"},"statuses":{"href":"https://api.github.com/repos/heatseeknyc/heatseeknyc/statuses/f7685bad8dcbb6a5c797c7206511c66a7e93d3d1"}}}}