spec/git_trend/cli_spec.rb in git-trend-0.0.7 vs spec/git_trend/cli_spec.rb in git-trend-0.0.8
- old
+ new
@@ -22,11 +22,11 @@
describe 'with -l option' do
context 'with ruby' do
before do
stub_request_get("trending?l=#{language}")
end
- let(:language) {'ruby'}
+ let(:language) { 'ruby' }
it 'display daily ranking by language' do
res = <<-'EOS'.unindent
|No. Name Lang Star Fork
|--- ---------------------------------------- ---------- ------ -----
@@ -54,19 +54,19 @@
| 22 svenfuchs/rails-i18n Ruby 0 1
| 23 Homebrew/homebrew-php Ruby 0 1
| 24 sferik/twitter Ruby 0 1
| 25 rightscale/rightscale_cookbooks Ruby 0 1
EOS
- expect { @cli.invoke(:list, [], {language: language}) }.to output(res).to_stdout
+ expect { @cli.invoke(:list, [], language: language) }.to output(res).to_stdout
end
end
context 'with objective-c++ (including + sign)' do
before do
- stub_request_get("trending?l=objective-c%2B%2B")
+ stub_request_get('trending?l=objective-c%2B%2B')
end
- let(:language) {'objective-c++'}
+ let(:language) { 'objective-c++' }
it 'display daily ranking by language' do
res = <<-'EOS'.unindent
|No. Name Lang Star Fork
|--- ---------------------------------------- ------------- ------ -----
@@ -94,21 +94,21 @@
| 22 hbang/TypeStatus Objective-C++ 0 0
| 23 trentbrooks/ofxCoreMotion Objective-C++ 0 0
| 24 Yonsm/CeleWare Objective-C++ 0 0
| 25 ccrma/miniAudicle Objective-C++ 0 0
EOS
- expect { @cli.invoke(:list, [], {language: language}) }.to output(res).to_stdout
+ expect { @cli.invoke(:list, [], language: language) }.to output(res).to_stdout
end
end
end
describe 'with -s option' do
context 'with weekly' do
before do
stub_request_get("trending?since=#{since}")
end
- let(:since) {'weekly'}
+ let(:since) { 'weekly' }
it 'display daily ranking since weekly' do
res = <<-'EOS'.unindent
|No. Name Lang Star Fork
|--- -------------------------------------------------- ------------ ------ -----
@@ -136,19 +136,19 @@
| 22 twbs/bootstrap CSS 290 189
| 23 angular/angular.js JavaScript 268 194
| 24 mbostock/d3 JavaScript 307 113
| 25 maxpow4h/swiftz Swift 350 20
EOS
- expect { @cli.invoke(:list, [], {since: since}) }.to output(res).to_stdout
+ expect { @cli.invoke(:list, [], since: since) }.to output(res).to_stdout
end
end
context 'with monthly' do
before do
stub_request_get("trending?since=#{since}")
end
- let(:since) {'monthly'}
+ let(:since) { 'monthly' }
it 'display daily ranking since monthly' do
res = <<-'EOS'.unindent
|No. Name Lang Star Fork
|--- -------------------------------------------------- ------------ ------ -----
@@ -176,11 +176,11 @@
| 22 austinzheng/swift-2048 Swift 1083 218
| 23 dotcloud/docker Go 1057 269
| 24 julianshapiro/velocity JavaScript 1081 71
| 25 babun/babun Shell 1068 46
EOS
- expect { @cli.invoke(:list, [], {since: since}) }.to output(res).to_stdout
+ expect { @cli.invoke(:list, [], since: since) }.to output(res).to_stdout
end
end
end
describe 'with -d option' do
@@ -190,11 +190,11 @@
ENV['LINES'] = nil
end
context 'terminal width is enough' do
before do
- stub_request_get("trending")
+ stub_request_get('trending')
ENV['COLUMNS'] = '140'
ENV['LINES'] = '40'
end
it 'display daily ranking with description' do
@@ -225,34 +225,34 @@
| 22 mentionapp/mntpulltoreact Objective-C 46 1 One gesture, many actions. An evolution of Pull to Refre...
| 23 mikepenz/AboutLibraries Java 45 0 AboutLibraries is a library to offer some information of...
| 24 PistonDevelopers/piston-workspace Shell 45 0 Git submodules of Piston projects
| 25 maxpow4h/swiftz Swift 43 1 Functional programming in Swift
EOS
- expect { @cli.invoke(:list, [], {description: 'description'}) }.to output(res).to_stdout
+ expect { @cli.invoke(:list, [], description: 'description') }.to output(res).to_stdout
end
end
-
+
context 'terminal width is tiny' do
before do
- stub_request_get("trending")
+ stub_request_get('trending')
ENV['COLUMNS'] = '100' # 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: 'description') }.to output(dummy_result_no_options).to_stdout
end
end
end
describe 'with -l and -s option' do
context 'with ruby and weekly' do
before do
stub_request_get("trending?l=#{language}&since=#{since}")
end
- let(:language) {'ruby'}
- let(:since) {'weekly'}
+ let(:language) { 'ruby' }
+ let(:since) { 'weekly' }
it 'display daily ranking since weekly' do
res = <<-'EOS'.unindent
|No. Name Lang Star Fork
|--- ---------------------------------------- ---------- ------ -----
@@ -280,11 +280,11 @@
| 22 nickjj/orats Ruby 46 2
| 23 chrishunt/desktop Ruby 39 3
| 24 chloerei/campo Ruby 35 9
| 25 jordansissel/fpm Ruby 35 4
EOS
- expect { @cli.invoke(:list, [], {language: language, since: since}) }.to output(res).to_stdout
+ expect { @cli.invoke(:list, [], language: language, since: since) }.to output(res).to_stdout
end
end
end
end
@@ -490,49 +490,50 @@
end
end
end
private
- def stub_request_get(stub_url)
- url = Scraper::BASE_HOST.dup
- url << "/#{stub_url}" if stub_url
- uri = URI.parse(url)
- stub_request(:get, uri).
- to_return(
- :status => 200,
- :headers => {content_type: 'text/html'},
- :body => load_http_stub(stub_url))
- end
+ def stub_request_get(stub_url)
+ url = Scraper::BASE_HOST.dup
+ url << "/#{stub_url}" if stub_url
+ uri = URI.parse(url)
- def dummy_result_no_options
- <<-'EOS'.unindent
- |No. Name Lang Star Fork
- |--- -------------------------------------------------- ------------ ------ -----
- | 1 prat0318/json_resume Ruby 264 15
- | 2 andlabs/ui Go 185 8
- | 3 jessepollak/card CSS 174 9
- | 4 fullstackio/FlappySwift Swift 148 44
- | 5 grant/swift-cheat-sheet 153 13
- | 6 Flolagale/mailin Python 155 3
- | 7 numbbbbb/the-swift-programming-language-in-chinese JavaScript 120 31
- | 8 hippyvm/hippyvm PHP 113 1
- | 9 neovim/neovim C 83 8
- | 10 hiphopapp/hiphop CoffeeScript 77 8
- | 11 interagent/http-api-design 78 4
- | 12 austinzheng/swift-2048 Swift 69 16
- | 13 mdznr/What-s-New Objective-C 72 2
- | 14 daneden/animate.css CSS 65 6
- | 15 davidmerfield/randomColor JavaScript 66 3
- | 16 dawn/dawn Ruby 62 2
- | 17 greatfire/wiki 54 9
- | 18 swift-jp/swift-guide CSS 45 9
- | 19 addyosmani/psi JavaScript 49 0
- | 20 mtford90/silk Python 47 0
- | 21 agaue/agaue Go 47 0
- | 22 mentionapp/mntpulltoreact Objective-C 46 1
- | 23 mikepenz/AboutLibraries Java 45 0
- | 24 PistonDevelopers/piston-workspace Shell 45 0
- | 25 maxpow4h/swiftz Swift 43 1
- EOS
- end
+ stub_request(:get, uri)
+ .to_return(
+ status: 200,
+ headers: { content_type: 'text/html' },
+ body: load_http_stub(stub_url))
+ end
+
+ def dummy_result_no_options
+ <<-'EOS'.unindent
+ |No. Name Lang Star Fork
+ |--- -------------------------------------------------- ------------ ------ -----
+ | 1 prat0318/json_resume Ruby 264 15
+ | 2 andlabs/ui Go 185 8
+ | 3 jessepollak/card CSS 174 9
+ | 4 fullstackio/FlappySwift Swift 148 44
+ | 5 grant/swift-cheat-sheet 153 13
+ | 6 Flolagale/mailin Python 155 3
+ | 7 numbbbbb/the-swift-programming-language-in-chinese JavaScript 120 31
+ | 8 hippyvm/hippyvm PHP 113 1
+ | 9 neovim/neovim C 83 8
+ | 10 hiphopapp/hiphop CoffeeScript 77 8
+ | 11 interagent/http-api-design 78 4
+ | 12 austinzheng/swift-2048 Swift 69 16
+ | 13 mdznr/What-s-New Objective-C 72 2
+ | 14 daneden/animate.css CSS 65 6
+ | 15 davidmerfield/randomColor JavaScript 66 3
+ | 16 dawn/dawn Ruby 62 2
+ | 17 greatfire/wiki 54 9
+ | 18 swift-jp/swift-guide CSS 45 9
+ | 19 addyosmani/psi JavaScript 49 0
+ | 20 mtford90/silk Python 47 0
+ | 21 agaue/agaue Go 47 0
+ | 22 mentionapp/mntpulltoreact Objective-C 46 1
+ | 23 mikepenz/AboutLibraries Java 45 0
+ | 24 PistonDevelopers/piston-workspace Shell 45 0
+ | 25 maxpow4h/swiftz Swift 43 1
+ EOS
+ end
end