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

Commit d6f75bf

Browse files
committed
Update test to use YoutubeVideoClientMock
1 parent 7551b8d commit d6f75bf

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

refactoring_external_service/youtube_video_list_spec.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@ def videos
1010
[{'youtubeID' => 'blahblahblah', 'views' => 3, 'monthlyViews' => 3}]
1111
end
1212
end
13-
14-
def test_video_list_returns_video_list
15-
video_service = VideoService.new(video_repo: VideoRepoMock.new)
16-
video_array = [{'youtubeID' => 'blahblahblah', 'views' => 3, 'monthlyViews' => 3}]
17-
youtube_response = {'items' =>
18-
[
13+
14+
class YoutubeVideoClientMock
15+
def get_video_stats(ids=:NotGiven)
16+
{'items' =>
17+
[
1918
{
2019
'id' =>'blahblahblah',
2120
'statistics' => {'viewCount' => '3'},
2221
'snippet' => {'publishedAt' => (Date.today - 30).to_s }
2322
}
2423
]
2524
}
25+
end
26+
end
27+
28+
def test_video_list_returns_video_list
29+
video_service = VideoService.new(video_repo: VideoRepoMock.new)
30+
video_array = [{'youtubeID' => 'blahblahblah', 'views' => 3, 'monthlyViews' => 3}]
31+
youtube_response = YoutubeVideoClientMock.new.get_video_stats()
2632
video_json = JSON.generate(video_array)
2733
video_service.stub(:get_youtube_stats_on_videos, youtube_response) do
2834
result = JSON.parse(video_service.video_list)

0 commit comments

Comments
 (0)