spec/git_trend/cli_spec.rb in git-trend-0.1.2 vs spec/git_trend/cli_spec.rb in git-trend-0.1.3

- old
+ new

@@ -3,31 +3,21 @@ include GitTrend RSpec.shared_examples_for 'since daily ranking' do it 'display daily ranking' do - expect { @cli.invoke(:list, [], since: since) }.to output(dummy_result_no_options).to_stdout + expect { @cli.invoke(:list, [], since: since, description: false) }.to output(dummy_result_without_description).to_stdout end end RSpec.describe GitTrend::CLI do describe '#list' do before do @cli = CLI.new end - context 'with no option' do - before do - stub_request_get('trending') - end - - it 'display daily ranking' do - expect { @cli.list }.to output(dummy_result_no_options).to_stdout - end - end - describe 'with -l option' do context 'with ruby' do before do stub_request_get("trending?l=#{language}") end @@ -61,11 +51,11 @@ | 22 digitaloceancloud/resource_kit Ruby 6 | 23 rapid7/metasploit-framework Ruby 5 | 24 tenderlove/the_metal Ruby 6 | 25 bbatsov/rubocop Ruby 5 EOS - expect { @cli.invoke(:list, [], language: language) }.to output(res).to_stdout + expect { @cli.invoke(:list, [], language: language, description: false) }.to output(res).to_stdout end end context 'with objective-c++ (including + sign)' do before do @@ -101,11 +91,11 @@ | 22 kseebaldt/deferred Objective-C++ 0 | 23 rbaumbach/Swizzlean Objective-C++ 0 | 24 Smartype/iOS_VPNPlugIn Objective-C++ 0 | 25 swift2js/swift2js Objective-C++ 0 EOS - expect { @cli.invoke(:list, [], language: language) }.to output(res).to_stdout + expect { @cli.invoke(:list, [], language: language, description: false) }.to output(res).to_stdout end end end describe 'with -s option' do @@ -151,11 +141,11 @@ | 22 google/web-starter-kit CSS 372 | 23 quasado/gravit JavaScript 365 | 24 meteor/meteor JavaScript 362 | 25 Netflix/Scumblr Ruby 305 EOS - expect { @cli.invoke(:list, [], since: since) }.to output(res).to_stdout + expect { @cli.invoke(:list, [], since: since, description: false) }.to output(res).to_stdout end end context 'with monthly' do let(:since) { 'monthly' } @@ -187,72 +177,47 @@ | 22 mbostock/d3 JavaScript 1008 | 23 VodkaBears/Vide JavaScript 1136 | 24 driftyco/ionic JavaScript 1007 | 25 fians/marka CSS 989 EOS - expect { @cli.invoke(:list, [], since: since) }.to output(res).to_stdout + expect { @cli.invoke(:list, [], since: since, description: false) }.to output(res).to_stdout end end end - describe 'with -d option' do - + describe 'with -d option (or with no option)' do after do ENV['COLUMNS'] = nil ENV['LINES'] = nil end - context 'terminal width is enough' do - before do - stub_request_get('trending') - ENV['COLUMNS'] = '140' - ENV['LINES'] = '40' + before do + stub_request_get('trending') + ENV['COLUMNS'] = '140' + ENV['LINES'] = '40' + end + + context 'with no option' do + it 'display daily ranking' do + expect { @cli.invoke(:list, []) }.to output(dummy_result_no_options).to_stdout end + end + context 'terminal width is enough' do it 'display daily ranking with description' do - res = <<-'EOS'.unindent - |No. Name Lang Star Description - |--- ------------------------------------------ ----------- ------ -------------------------------------------------------------------------- - | 1 gionkunz/chartist-js JavaScript 363 Simple responsive charts - | 2 kitematic/kitematic JavaScript 327 Simple Docker App management for Mac OS X. - | 3 tmux-plugins/tmux-resurrect Shell 217 Persists tmux environment across system restarts. - | 4 rxin/db-readings 210 Readings in Databases - | 5 daimajia/AndroidSwipeLayout Java 172 The Most Powerful Swipe Layout! - | 6 tylertreat/chan C 126 Pure C implementation of Go channels. - | 7 AllThingsSmitty/must-watch-css 93 A useful list of must-watch videos about CSS. - | 8 masayuki0812/c3 JavaScript 85 A D3-based reusable chart library - | 9 fouber/page-monitor JavaScript 74 capture webpage and diff the dom change with phantomjs - | 10 gogits/gogs Go 71 Gogs(Go Git Service) is a painless self-hosted Git Service written in G... - | 11 facebook/flux JavaScript 72 Application Architecture for Building User Interfaces - | 12 twbs/bootstrap CSS 55 The most popular front-end framework for developing responsive, mobile ... - | 13 luster-io/impulse JavaScript 68 Dynamics Physics Interactions for the Mobile Web - | 14 lawloretienne/QuickReturn Java 65 Showcases QuickReturn view as a header, footer, and both header and foo... - | 15 angular/angular.js JavaScript 53 HTML enhanced for web apps - | 16 wisk/medusa C 60 An open source interactive disassembler - | 17 ochococo/Design-Patterns-In-Swift Swift 60 Design Patterns implemented in Swift - | 18 cwRichardKim/RKSwipeBetweenViewControllers Objective-C 59 Swipe between ViewControllers like in the Spotify or Twitter app with a... - | 19 google/web-starter-kit CSS 59 Google Web Starter Kit (Beta) - | 20 syncthing/syncthing Go 49 Open Source Continuous File Synchronization - | 21 ruslanskorb/RSKImageCropper Objective-C 46 An image cropper for iOS like in the Contacts app with support for land... - | 22 kyze8439690/ResideLayout Java 44 An Android Layout which has a same function like https://github.com/rom... - | 23 ParsePlatform/f8DeveloperConferenceApp Java 41 - | 24 chriskiehl/Gooey Python 41 Turn (almost) any command line program into a full GUI application with... - | 25 discourse/discourse Ruby 41 A platform for community discussion. Free, open, simple. - EOS - expect { @cli.invoke(:list, [], description: 'description') }.to output(res).to_stdout + expect { @cli.invoke(:list, [], description: true) }.to output(dummy_result_no_options).to_stdout end end context 'terminal width is tiny' do before do - stub_request_get('trending') ENV['COLUMNS'] = '85' # it is not enough for description. ENV['LINES'] = '40' end it 'display daily ranking about the same as no option' do - expect { @cli.invoke(:list, [], description: 'description') }.to output(dummy_result_no_options).to_stdout + expect { @cli.invoke(:list, [], description: true) }.to output(dummy_result_without_description).to_stdout end end end describe 'with -l and -s option' do @@ -291,11 +256,11 @@ | 22 ruby/ruby Ruby 41 | 23 apotonick/paperdragon Ruby 46 | 24 junegunn/fzf Ruby 41 | 25 imathis/octopress Ruby 36 EOS - expect { @cli.invoke(:list, [], language: language, since: since) }.to output(res).to_stdout + expect { @cli.invoke(:list, [], language: language, since: since, description: false) }.to output(res).to_stdout end end end end @@ -533,11 +498,11 @@ status: 200, headers: { content_type: 'text/html' }, body: load_http_stub(stub_url)) end - def dummy_result_no_options + def dummy_result_without_description <<-'EOS'.unindent |No. Name Lang Star |--- ------------------------------------------ ----------- ------ | 1 gionkunz/chartist-js JavaScript 363 | 2 kitematic/kitematic JavaScript 327 @@ -562,8 +527,40 @@ | 21 ruslanskorb/RSKImageCropper Objective-C 46 | 22 kyze8439690/ResideLayout Java 44 | 23 ParsePlatform/f8DeveloperConferenceApp Java 41 | 24 chriskiehl/Gooey Python 41 | 25 discourse/discourse Ruby 41 + EOS + end + + def dummy_result_no_options + <<-'EOS'.unindent + |No. Name Lang Star Description + |--- ------------------------------------------ ----------- ------ -------------------------------------------------------------------------- + | 1 gionkunz/chartist-js JavaScript 363 Simple responsive charts + | 2 kitematic/kitematic JavaScript 327 Simple Docker App management for Mac OS X. + | 3 tmux-plugins/tmux-resurrect Shell 217 Persists tmux environment across system restarts. + | 4 rxin/db-readings 210 Readings in Databases + | 5 daimajia/AndroidSwipeLayout Java 172 The Most Powerful Swipe Layout! + | 6 tylertreat/chan C 126 Pure C implementation of Go channels. + | 7 AllThingsSmitty/must-watch-css 93 A useful list of must-watch videos about CSS. + | 8 masayuki0812/c3 JavaScript 85 A D3-based reusable chart library + | 9 fouber/page-monitor JavaScript 74 capture webpage and diff the dom change with phantomjs + | 10 gogits/gogs Go 71 Gogs(Go Git Service) is a painless self-hosted Git Service written in G... + | 11 facebook/flux JavaScript 72 Application Architecture for Building User Interfaces + | 12 twbs/bootstrap CSS 55 The most popular front-end framework for developing responsive, mobile ... + | 13 luster-io/impulse JavaScript 68 Dynamics Physics Interactions for the Mobile Web + | 14 lawloretienne/QuickReturn Java 65 Showcases QuickReturn view as a header, footer, and both header and foo... + | 15 angular/angular.js JavaScript 53 HTML enhanced for web apps + | 16 wisk/medusa C 60 An open source interactive disassembler + | 17 ochococo/Design-Patterns-In-Swift Swift 60 Design Patterns implemented in Swift + | 18 cwRichardKim/RKSwipeBetweenViewControllers Objective-C 59 Swipe between ViewControllers like in the Spotify or Twitter app with a... + | 19 google/web-starter-kit CSS 59 Google Web Starter Kit (Beta) + | 20 syncthing/syncthing Go 49 Open Source Continuous File Synchronization + | 21 ruslanskorb/RSKImageCropper Objective-C 46 An image cropper for iOS like in the Contacts app with support for land... + | 22 kyze8439690/ResideLayout Java 44 An Android Layout which has a same function like https://github.com/rom... + | 23 ParsePlatform/f8DeveloperConferenceApp Java 41 + | 24 chriskiehl/Gooey Python 41 Turn (almost) any command line program into a full GUI application with... + | 25 discourse/discourse Ruby 41 A platform for community discussion. Free, open, simple. EOS end end