File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ def self.to_switches(options)
18
18
when Hash
19
19
"--#{ key } #{ value . map { |k , v | "#{ k } :#{ v } " } . join ( ' ' ) } "
20
20
when nil , false
21
- ""
21
+ nil
22
22
else
23
23
"--#{ key } #{ value . inspect } "
24
24
end
25
- end . join ( " " )
25
+ end . compact . join ( " " )
26
26
end
27
27
28
28
# Takes a hash of Thor::Option and a hash with defaults.
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ def remaining
35
35
expect ( Thor ::Options . to_switches ( :color => false ) ) . to eq ( "" )
36
36
end
37
37
38
+ it "avoids extra spaces" do
39
+ expect ( Thor ::Options . to_switches ( :color => false , :foo => nil ) ) . to eq ( "" )
40
+ end
41
+
38
42
it "writes --name value for anything else" do
39
43
expect ( Thor ::Options . to_switches ( :format => "specdoc" ) ) . to eq ( '--format "specdoc"' )
40
44
end
You can’t perform that action at this time.
0 commit comments