test-cmd.rb 0.12.3 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06212f56cec2eb07f6ac4cb7bd4bc4e434b8ae624a69d8400c2572ab951d788c
4
- data.tar.gz: c2efc1ddf888419967d0d71642a09ce3674fc3489062ced72cb72dabdb08b2d3
3
+ metadata.gz: 9543aef60b39eebdd49dcd4a1a33b9f08841cdc7ad0176402266d0236bdb483c
4
+ data.tar.gz: 44f38f751770d9cee2d734a768b07d10a67227d3841aec53648a9ecff89ca26a
5
5
  SHA512:
6
- metadata.gz: 4f1cc4b19a41ded01e5e4f0969c1b8b96243ebec4db253b3801f75944e8972610848e37911bf48e4dc568dd254c01f9b2d33ef0fcd0ca7ac5f20ad44d1acfff7
7
- data.tar.gz: b74fad1aed809af6e546dc0f5077b2d5243835a5d531002a66d767a69e63f63e8f16aaf56b2b61ac98fe6506e5d63f199f25176f007415276a19091cf8a4c30f
6
+ metadata.gz: be9bba3851638c04d87a114f92fc2ee28b8683e3df14b13b9a37f7a9749ea0075589def7acf65c8b554e62f6e8575b9ccde4aa9f61b024f65a6455f360686559
7
+ data.tar.gz: 04db2f4f1b84bb1ce41acfa570778bcec93d64593d58825356c1b9e48ff08b181f8c13c516bbfe70fa8065ecf18b83488df1a8ac1354632e3513765be24a47c6
data/lib/test/cmd.rb CHANGED
@@ -32,6 +32,7 @@ class Test::Cmd
32
32
  @spawned = false
33
33
  @stdout = ""
34
34
  @stderr = ""
35
+ @enoent = false
35
36
  end
36
37
 
37
38
  ##
@@ -57,6 +58,7 @@ class Test::Cmd
57
58
  @status = $?
58
59
  rescue Errno::ENOENT => ex
59
60
  @cmd, @argv, @stderr = "false", [], ex.message
61
+ @enoent = true
60
62
  retry
61
63
  end
62
64
  loop do
@@ -154,6 +156,15 @@ class Test::Cmd
154
156
  def spawned?
155
157
  @spawned
156
158
  end
159
+
160
+ ##
161
+ # @return [Boolean]
162
+ # Returns true when a command can't be found
163
+ def command_not_found?
164
+ spawn
165
+ @enoent
166
+ end
167
+ alias_method :not_found?, :command_not_found?
157
168
  end
158
169
 
159
170
  module Kernel
data/test/cmd_test.rb CHANGED
@@ -105,4 +105,13 @@ class Test::Cmd
105
105
  assert_equal true, ruby("puts 42").tap(&:spawn).spawned?
106
106
  end
107
107
  end
108
+
109
+ ##
110
+ # Test::Cmd#command_not_found?
111
+ class CommandNotFoundTest < Test
112
+ def test_command_not_found
113
+ assert_equal true, cmd("/a/path/that/is/not/found").command_not_found?
114
+ assert_equal true, cmd("/a/path/that/is/not/found").not_found?
115
+ end
116
+ end
108
117
  end
data/test-cmd.rb.gemspec CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
5
5
  gem.authors = ["0x1eef"]
6
6
  gem.email = ["0x1eef@protonmail.com"]
7
7
  gem.homepage = "https://github.com/0x1eef/test-cmd.rb#readme"
8
- gem.version = "0.12.3"
8
+ gem.version = "0.12.4"
9
9
  gem.required_ruby_version = ">= 3.0"
10
10
  gem.licenses = ["0BSD"]
11
11
  gem.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-cmd.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-15 00:00:00.000000000 Z
11
+ date: 2024-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit