spec/git_trend/cli_spec.rb in git-trend-0.0.9 vs spec/git_trend/cli_spec.rb in git-trend-0.1.0

- old
+ new

@@ -1,9 +1,16 @@ # encoding: utf-8 require 'spec_helper' 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 + end +end + RSpec.describe GitTrend::CLI do describe '#list' do before do @cli = CLI.new @@ -100,16 +107,24 @@ end end end describe 'with -s option' do + before { stub_request_get("trending?since=#{since}") } + + context 'with no option' do + let(:since) { '' } + it_behaves_like 'since daily ranking' + end + + context 'with daily' do + let(:since) { 'daily' } + it_behaves_like 'since daily ranking' + end + context 'with weekly' do - before do - stub_request_get("trending?since=#{since}") - end let(:since) { 'weekly' } - it 'display daily ranking since weekly' do res = <<-'EOS'.unindent |No. Name Lang Star Fork |--- -------------------------------------------------- ------------ ------ ----- | 1 numbbbbb/the-swift-programming-language-in-chinese JavaScript 2495 679 @@ -141,14 +156,10 @@ 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' } - it 'display daily ranking since monthly' do res = <<-'EOS'.unindent |No. Name Lang Star Fork |--- -------------------------------------------------- ------------ ------ ----- | 1 fullstackio/FlappySwift Swift 5753 1530