File: file_with_exec_ext_spec.rb

package info (click to toggle)
ruby-tty-which 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 196 kB
  • sloc: ruby: 274; makefile: 4
file content (17 lines) | stat: -rw-r--r-- 534 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

RSpec.describe TTY::Which, "#file_with_exec_ext?" do
  it "detects executable extension" do
    filename = "file.exe"
    allow(TTY::Which).to receive(:extensions).and_return([".EXE", ".BAT", ".CMD"])

    expect(TTY::Which.file_with_exec_ext?(filename)).to eq(true)
  end

  it "fails to detect executable extension" do
    filename = "file.unknown"
    allow(TTY::Which).to receive(:extensions).and_return([".EXE", ".BAT"])

    expect(TTY::Which.file_with_exec_ext?(filename)).to eq(false)
  end
end