Sha256: 77aaa401a2f5b109b9a35b7c4e301d2c4f240a7cc2a2ff2dd6322ea561b7e0a1

Contents?: true

Size: 867 Bytes

Versions: 2

Compression:

Stored size: 867 Bytes

Contents

require_relative '../test_helper'

TestKlass = Class.new do
  include YoutubeDL::Support

  def executable_path
    usable_executable_path_for 'youtube-dl'
  end
end

describe YoutubeDL::Support do
  before do
    @klass = TestKlass.new
  end

  describe '#usable_executable_path' do
    it 'should detect system executable' do
      vendor_bin = File.join(Dir.pwd, 'vendor', 'bin', 'youtube-dl')
      Dir.mktmpdir do |tmpdir|
        FileUtils.cp vendor_bin, tmpdir

        old_path = ENV["PATH"]
        ENV["PATH"] = "#{tmpdir}:#{old_path}"

        usable_path = @klass.usable_executable_path_for('youtube-dl')
        assert_match usable_path, "#{tmpdir}/youtube-dl"

        ENV["PATH"] = old_path
      end
    end

    it 'should not have a newline char in the executable_path' do
      assert_match /youtube-dl\z/, @klass.executable_path
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
youtube-dl.rb-0.1.1 test/youtube-dl/support_test.rb
youtube-dl.rb-0.1.0 test/youtube-dl/support_test.rb