Sha256: af69162de6dbd2bb5baa4aba8710bb33e1fb7f894a209623a4fc9e8e74332bd2

Contents?: true

Size: 1.33 KB

Versions: 120

Compression:

Stored size: 1.33 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'fedux_org_stdlib/command/which'

RSpec.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 for a invalid command if a full path is given' do
      expect(klass.new.which('/usr/bin/which1')).to eq(nil)
    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', paths: '/usr/bin')).to eq('/usr/bin/which')
    end

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

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

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

Version data entries

120 entries across 120 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.11.18 spec/command/which_spec.rb
fedux_org-stdlib-0.11.17 spec/command/which_spec.rb
fedux_org-stdlib-0.11.16 spec/command/which_spec.rb
fedux_org-stdlib-0.11.15 spec/command/which_spec.rb
fedux_org-stdlib-0.11.14 spec/command/which_spec.rb
fedux_org-stdlib-0.11.12 spec/command/which_spec.rb
fedux_org-stdlib-0.11.11 spec/command/which_spec.rb
fedux_org-stdlib-0.11.9 spec/command/which_spec.rb
fedux_org-stdlib-0.11.8 spec/command/which_spec.rb
fedux_org-stdlib-0.11.7 spec/command/which_spec.rb
fedux_org-stdlib-0.11.6 spec/command/which_spec.rb
fedux_org-stdlib-0.11.5 spec/command/which_spec.rb
fedux_org-stdlib-0.11.4 spec/command/which_spec.rb
fedux_org-stdlib-0.11.3 spec/command/which_spec.rb
fedux_org-stdlib-0.11.2 spec/command/which_spec.rb
fedux_org-stdlib-0.11.1 spec/command/which_spec.rb
fedux_org-stdlib-0.11.0 spec/command/which_spec.rb
fedux_org-stdlib-0.10.9 spec/command/which_spec.rb
fedux_org-stdlib-0.10.8 spec/command/which_spec.rb
fedux_org-stdlib-0.10.7 spec/command/which_spec.rb