This repository was archived by the owner on Apr 24, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
refactoring_external_service Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments