Skip to content

Commit 33f91e9

Browse files
committed
fix: add quotes on string args
1 parent 3ea79bb commit 33f91e9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/rubyshell/command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def map_hash_arg(arg)
4343
"--#{k}"
4444
end
4545

46-
[key, v.is_a?(TrueClass) ? nil : v].compact.join(" ")
46+
[key, v.is_a?(TrueClass) ? nil : "'#{v}'"].compact.join(" ")
4747
end.compact
4848
end
4949
end

spec/rubyshell_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ def subject_call
129129
end
130130
end
131131

132+
describe "Validating Command Class" do
133+
context "when hash arg value has is not a TrueClass" do
134+
let(:subject_instance) { RubyShell::Command.new("example", firstparam: "Short Phrase") }
135+
136+
it "returns the correct shell command" do
137+
expect(subject_instance.to_shell).to eq("example --firstparam 'Short Phrase'")
138+
end
139+
end
140+
end
141+
132142
it "has a version number" do
133143
expect(RubyShell::VERSION).not_to be nil
134144
end

0 commit comments

Comments
 (0)