Skip to content

Commit

Permalink
Change to check global executable without directory parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Jul 5, 2020
1 parent 5d832e2 commit ff32bc5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions spec/unit/executable_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# frozen_string_literal: true

RSpec.describe TTY::Which, '#executable_file?' do
it "checks if file is executable" do
allow(::File).to receive(:join).with('/usr/local/bin', 'ruby').
and_return('/usr/local/bin/ruby')
RSpec.describe TTY::Which, "#executable_file?" do
it "checks if file in directory is executable" do
path = "/usr/local/bin/ruby"
allow(::File).to receive(:join).with("/usr/local/bin", "ruby").and_return(path)
allow(::File).to receive(:file?).with(path).and_return(true)
allow(::File).to receive(:executable?).with(path).and_return(true)

allow(::File).to receive(:file?).and_return(true)
allow(::File).to receive(:executable?).with('/usr/local/bin/ruby').and_return(true)
expect(TTY::Which.executable_file?("ruby", "/usr/local/bin")).to eq(true)
end

it "checks if only a file is executable" do
allow(::File).to receive(:file?).with("ruby").and_return(true)
allow(::File).to receive(:executable?).with("ruby").and_return(true)

expect(TTY::Which.executable_file?('ruby', '/usr/local/bin')).to eq(true)
expect(TTY::Which.executable_file?("ruby")).to eql(true)
end
end

0 comments on commit ff32bc5

Please sign in to comment.