Sha256: d8cf6ff75f1c5f72cddf84795f8ac76fc906952f0b8d26ae58132c8df8f46fa5

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

include GemSearch

RSpec.describe Commands::Run do
  describe '#call' do
    before do
      allow(options).to receive(:arguments).and_return([query])
      allow(options).to receive(:detail?).and_return(false)
      allow(options).to receive(:[]).with('sort')
      stub_request_search(query, 1, dummy_search_result)
      stub_request_search_no_result_with_page(query, 2)
    end
    let(:query) { 'factory_girl' }
    let(:options) { double('options') }

    context 'without sort option' do
      it 'called Executor#search without sort option' do
        expect_any_instance_of(Executor).to receive(:search).with(query, default_opts).once
        Commands::Run.new(options).call
      end
    end

    context 'with sort option' do
      before { allow(@options).to receive(:sort).and_return('a') }
      it 'called Executor#search with sort option' do
        expect_any_instance_of(Executor).to receive(:search).with(query, default_opts(sort: 'downloads')).once
        Commands::Run.new(options).call
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gem-search-0.1.7 spec/commands/run_spec.rb