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

Commit

Permalink
Update test to use YoutubeVideoClientMock
Browse files Browse the repository at this point in the history
  • Loading branch information
edgenard committed May 13, 2018
1 parent 7551b8d commit d6f75bf
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions refactoring_external_service/youtube_video_list_spec.rb
Expand Up @@ -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.

Copy link
@medwards1771

medwards1771 May 15, 2018

Contributor

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)
Expand Down

0 comments on commit d6f75bf

Please sign in to comment.