Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
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 1d38b33
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions refactoring_external_service/youtube_video_list_spec.rb
Expand Up @@ -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.

Copy link
@medwards1771

medwards1771 May 15, 2018

Contributor

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.