Skip to content

Commit 31150ee

Browse files
committed
Does not raise when default is a symbol and type is string
1 parent be1a315 commit 31150ee

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/thor/parser/option.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def validate_default_type!
119119
:boolean
120120
when Numeric
121121
:numeric
122+
when Symbol
123+
:string
122124
when Hash, Array, String
123125
@default.class.name.downcase.to_sym
124126
end

spec/parser/option_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ def option(name, options = {})
141141
end.to raise_error(ArgumentError, "An option's default must match its type.")
142142
end
143143

144+
it "does not raises an error if default is an symbol and type string" do
145+
expect do
146+
option = option("foo", :type => :string, :default => :bar)
147+
end.not_to raise_error
148+
end
149+
144150
it "boolean options cannot be required" do
145151
expect do
146152
option("foo", :required => true, :type => :boolean)

0 commit comments

Comments
 (0)