Sha256: 3a09c8bdce3f6711b0000240701762d99faca7910df0c3b17d10e3e5866fb2bd

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

require 'fedux_org/stdlib/command/which'

describe Command::Which do

  context '#which' do
    klass = Class.new do
      include Command::Which
    end

    it 'returns full path for a valid command' do
      expect( klass.new.which( 'which' ) ).to eq( '/usr/bin/which' )
    end

    it 'returns full path for a valid command although a full path is given' do
      expect( klass.new.which( '/usr/bin/which' ) ).to eq( '/usr/bin/which' )
    end

    it 'returns nil if no executable can be found in path' do
      expect( klass.new.which( 'asdfasdf' ) ).to eq( nil )
    end

    it 'uses paths string to search for command' do
      expect( klass.new.which( 'which', '/usr/bin' ) ).to eq( '/usr/bin/which' )
    end

    it 'uses paths array to search for command' do
      expect( klass.new.which( 'which', [ '/usr/bin' ] ) ).to eq( '/usr/bin/which' )
    end

    it 'uses pathexts to search for command' do
      expect( klass.new.which( 'which', [ '/usr/bin' ], '' ) ).to eq( '/usr/bin/which' )
    end

    it 'uses pathexts array to search for command' do
      expect( klass.new.which( 'which', [ '/usr/bin' ], [ '' ]) ).to eq( '/usr/bin/which' )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.2.1 spec/command/which_spec.rb