Sha256: ac8da207d681a2b2ccd504d739cb5628390326c18ee1137764775d896e815eb6

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)

# The CocoaPods namespace
#
module CLAide
  describe Command::Plugins::Search do
    extend SpecHelper::PluginsStubs
    extend SpecHelper::PluginsSearchCommand

    before do
      UI_OUT.reopen
    end

    it 'registers itself' do
      Command.parse(%w(plugins search)).
        should.be.instance_of Command::Plugins::Search
    end

    #--- Validation

    it 'should require a non-empty query' do
      @command = search_command
      should.raise(CLAide::Help) do
        @command.validate!
      end.message.should.match(/A search query is required./)
    end

    it 'should require a valid RegExp as query' do
      @command = search_command('[invalid')
      should.raise(CLAide::Help) do
        @command.validate!
      end.message.should.match(/A valid regular expression is required./)
    end

    #--- Output printing

    it 'should filter plugins only by name without full search' do
      stub_plugins_json_request
      @command = search_command('search')
      @command.run
      UI_OUT.string.should.not.include('-> CLAide Fake Gem')
      UI_OUT.string.should.include('-> CLAide Searchable Fake Gem')
      UI_OUT.string.should.not.include('-> Bacon')
    end

    it 'should filter plugins by name, author, description with full search' do
      stub_plugins_json_request
      @command = search_command('--full', 'search')
      @command.run
      UI_OUT.string.should.include('-> CLAide Fake Gem')
      UI_OUT.string.should.include('-> CLAide Searchable Fake Gem')
      UI_OUT.string.should.not.include('-> Bacon')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
claide-plugins-0.9.2 spec/command/plugins/search_spec.rb
claide-plugins-0.9.1 spec/command/plugins/search_spec.rb
claide-plugins-0.9.0 spec/command/plugins/search_spec.rb