Permalink
Browse files

Update test to use YoutubeVideoClientMock

  • Loading branch information...
edgenard committed May 13, 2018
1 parent 7551b8d commit d6f75bf874a2b295e1b7b5fe8b1c754d48b7c7e3
Showing with 12 additions and 6 deletions.
  1. +12 −6 refactoring_external_service/youtube_video_list_spec.rb
@@ -10,19 +10,25 @@ def videos
[{'youtubeID' => 'blahblahblah', 'views' => 3, 'monthlyViews' => 3}]
end
end

def test_video_list_returns_video_list
video_service = VideoService.new(video_repo: VideoRepoMock.new)
video_array = [{'youtubeID' => 'blahblahblah', 'views' => 3, 'monthlyViews' => 3}]
youtube_response = {'items' =>
[

class YoutubeVideoClientMock
def get_video_stats(ids=:NotGiven)

This comment has been minimized.

@medwards1771

medwards1771 May 15, 2018

Collaborator

What is (ids=:NotGiven) doing? Can you break down that code?

{'items' =>
[
{
'id' =>'blahblahblah',
'statistics' => {'viewCount' => '3'},
'snippet' => {'publishedAt' => (Date.today - 30).to_s }
}
]
}
end
end

def test_video_list_returns_video_list
video_service = VideoService.new(video_repo: VideoRepoMock.new)
video_array = [{'youtubeID' => 'blahblahblah', 'views' => 3, 'monthlyViews' => 3}]
youtube_response = YoutubeVideoClientMock.new.get_video_stats()
video_json = JSON.generate(video_array)
video_service.stub(:get_youtube_stats_on_videos, youtube_response) do
result = JSON.parse(video_service.video_list)

0 comments on commit d6f75bf

Please sign in to comment.