Permalink
Browse files

Add another test case for when video has been published for less than…

… 30 days
  • Loading branch information...
edgenard committed May 13, 2018
1 parent 72de92f commit 1d38b335042b941f385c47a7db8e14af43aea2bb
Showing with 21 additions and 0 deletions.
  1. +21 −0 refactoring_external_service/youtube_video_list_spec.rb
@@ -49,4 +49,25 @@ def test_when_views_unchanged_for_one_month
assert_in_delta(expected[0]['monthlyViews'], actual[0]['monthlyViews'], 0.1)
end

def test_when_one_day_has_passed

This comment has been minimized.

@medwards1771

medwards1771 May 15, 2018

Collaborator

I see you're breaking your test contexts into "x" # of days that have passed now... What's that about?! What did you discover?

video_repo_response = [{'youtubeID' => 'blahblahblah', 'views' => 0, 'monthlyViews' => 0}]
youtube_client_response = {'items' =>
[
{
'id' =>'blahblahblah',
'statistics' => {'viewCount' => '3'},
'snippet' => {'publishedAt' => (Date.today - 29).to_s }
}
]
}
video_service = VideoService.new(
video_repo: VideoRepoStub.new(video_repo_response),
video_client: YoutubeVideoClientStub.new(youtube_client_response)
)
actual = JSON.parse(video_service.video_list)
assert_equal(3, actual[0]['views'])
# I'm making an assumption here that when the video has been out less than 30 days,
# the monthlyViews should be just the total views
assert_equal(3, actual[0]['monthlyViews'])
end
end

0 comments on commit 1d38b33

Please sign in to comment.