Files
news.gitea.happylizard.me/bin/gems/facets-3.1.0/test/standard/test_shellwords.rb
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

75 lines
1.3 KiB
Ruby

covers 'facets/shellwords'
test_case Shellwords do
class_method :shellwords do
test do
cmd = "ruby my_prog.rb | less"
Shellwords.shellwords(cmd).assert.instance_of?(Array)
Shellwords.shellwords(cmd).length.assert == 4
end
test "unmatched double quote" do
bad_cmd = 'one two "three'
expect ArgumentError do
Shellwords.shellwords(bad_cmd)
end
end
test "unmatched single quote" do
bad_cmd = "one two 'three"
expect ArgumentError do
Shellwords.shellwords(bad_cmd)
end
end
test "unmatched quotes" do
bad_cmd = "one '"'"''""'""
expect ArgumentError do
Shellwords.shellwords(bad_cmd)
end
end
end
end
test_case Array do
method :shellwords do
test do
e = ["a", "b"]
a = ["a", "b"].shellwords
a.assert == e
end
test do
e = ["-d", "a", "b"]
a = ["a", "b", {:d=>true}].shellwords
a.assert == e
end
end
end
test_case Hash do
method :shellwords do
test do
e = ['--debug']
a = {:debug=>true}.shellwords
a.assert == e
end
test do
e = ['--name="jim"', '--debug']
a = {:debug=>true, :name=>"jim"}.shellwords
a.each do |x|
e.assert.include?(x)
end
end
end
end