diff --git a/refactoring_external_service/youtube_video_list_spec.rb b/refactoring_external_service/youtube_video_list_spec.rb index 4357d21..973b101 100644 --- a/refactoring_external_service/youtube_video_list_spec.rb +++ b/refactoring_external_service/youtube_video_list_spec.rb @@ -10,12 +10,11 @@ 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) + {'items' => + [ { 'id' =>'blahblahblah', 'statistics' => {'viewCount' => '3'}, @@ -23,6 +22,13 @@ def test_video_list_returns_video_list } ] } + 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)