Permalink
Browse files

Get test with two months since published days to pass, assume fractio…

…nal views don't mean anything
  • Loading branch information...
edgenard committed May 13, 2018
1 parent 76fbc77 commit 53c30c03e3c7be9c1714482121e3a60f03c4b604
@@ -51,6 +51,6 @@ def video_list
def monthlyViews(views, publishing_date)
days_available = Date.today - Date.parse(publishing_date)
return views if days_available < 30
views * 365.0 / days_available / 12
(views * 365 / days_available / 12).to_i
end
end
@@ -46,7 +46,7 @@ def test_when_views_unchanged_for_one_month
expected = video_repo_response
assert_equal(expected[0]['youtubeID'], actual[0]['youtubeID'])
assert_equal(expected[0]['views'], actual[0]['views'])
assert_in_delta(expected[0]['monthlyViews'], actual[0]['monthlyViews'], 0.1)
assert_equal(expected[0]['monthlyViews'], actual[0]['monthlyViews'])
end

def test_when_less_than_thirty_days_have_passed
@@ -87,7 +87,9 @@ def test_when_sixty_days_have_passed_since_publishing
video_client: YoutubeVideoClientStub.new(youtube_client_response)
)
actual = JSON.parse(video_service.video_list)
assert_equal(10, actual[0]['views'])
assert_equal(5, actual[0]['monthlyViews'])
assert_equal(10, actual[0]['views'], 'Total Views')
# I'm making another assumption here that fractional views don't really count for anything

This comment has been minimized.

@medwards1771

medwards1771 May 15, 2018

Collaborator

Fair assumption

# So monthly views should always be integers.
assert_equal(5, actual[0]['monthlyViews'], 'Monthly Views')
end
end

0 comments on commit 53c30c0

Please sign in to comment.