Sha256: 077e8545040233a41cb9c7367e62a1c9ecde803d572b051b2145c8656f0d3edb
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
# encoding: utf-8 require 'spec_helper' describe TTY::System::Which, '#which' do let(:path) { "/usr/local/bin:/usr/local/git/bin" } let(:extension) { '.bat' } subject { described_class.new(command) } context 'without extension' do let(:command) { 'ruby' } before { allow(ENV).to receive(:[]).with('PATHEXT').and_return(nil) allow(ENV).to receive(:[]).with('PATH').and_return(path) } it 'finds command' do allow(File).to receive(:executable?) { true } expect(subject.which).to eql "/usr/local/bin/ruby" end it "doesn't find command" do allow(File).to receive(:executable?) { false } expect(subject.which).to be_nil end end context 'with extension' do let(:command) { 'ruby' } before { allow(ENV).to receive(:[]).with('PATHEXT').and_return(extension) allow(ENV).to receive(:[]).with('PATH').and_return(path) } it 'finds command' do allow(File).to receive(:executable?) { true } expect(subject.which).to eql "/usr/local/bin/ruby.bat" end it "doesn't find command" do allow(File).to receive(:executable?) { false } expect(subject.which).to be_nil end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
tty-0.1.3 | spec/tty/system/which/which_spec.rb |
tty-0.1.2 | spec/tty/system/which/which_spec.rb |
tty-0.1.1 | spec/tty/system/which/which_spec.rb |
tty-0.1.0 | spec/tty/system/which/which_spec.rb |