Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
RSpec.configure do |config|
config.include WithExitstatus
config.include StubOS

config.before(:example) do
Terrapin::CommandLine.path = nil
Terrapin::CommandLine.runner = nil
end
end

def best_logger
Expand Down
20 changes: 9 additions & 11 deletions spec/terrapin/runners_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@
end

describe 'When running an executable in the supplemental path' do
before do
path = Pathname.new(File.dirname(__FILE__)) + '..' + 'support'
File.open(path + 'ls', 'w'){|f| f.puts "#!/bin/sh\necho overridden-ls\n" }
FileUtils.chmod(0755, path + 'ls')
Terrapin::CommandLine.path = path
end

after do
FileUtils.rm_f("#{Terrapin::CommandLine.path}/ls")
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heck yea 🥳

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for moving the setup stuff within the specific test that needs it!

[
Terrapin::CommandLine::BackticksRunner,
Terrapin::CommandLine::PopenRunner,
Expand All @@ -72,10 +61,19 @@
describe runner_class do
describe '#run' do
it 'finds the correct executable' do
path = Pathname.new(File.dirname(__FILE__)) + '..' + 'support'
File.open(path + 'ls', 'w'){|f| f.puts "#!/bin/sh\necho overridden-ls\n" }
FileUtils.chmod(0755, path + 'ls')
Terrapin::CommandLine.path = path
Terrapin::CommandLine.runner = runner_class.new
command = Terrapin::CommandLine.new('ls')

result = command.run

expect(result.strip).to eq('overridden-ls')

ensure
FileUtils.rm("#{Terrapin::CommandLine.path}/ls")
end
end
end
Expand Down