diff --git a/lib/thor/parser/option.rb b/lib/thor/parser/option.rb index 654f7adce..fa9bcf9b0 100644 --- a/lib/thor/parser/option.rb +++ b/lib/thor/parser/option.rb @@ -127,7 +127,8 @@ def validate_default_type! @default.class.name.downcase.to_sym end - raise ArgumentError, "An option's default must match its type." unless default_type == @type + # TODO: This should raise an ArgumentError in a future version of Thor + warn "Expected #{@type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == @type end def dasherized? diff --git a/spec/parser/option_spec.rb b/spec/parser/option_spec.rb index 8a7c329b4..7dca4fd6b 100644 --- a/spec/parser/option_spec.rb +++ b/spec/parser/option_spec.rb @@ -135,9 +135,9 @@ def option(name, options = {}) end it "raises an error if default is inconsistent with type" do - expect do - option("foo", :type => :numeric, :default => "bar") - end.to raise_error(ArgumentError, "An option's default must match its type.") + expect(capture(:stderr) do + option("foo_bar", :type => :numeric, :default => "baz") + end.chomp).to eq('Expected numeric default value for \'--foo-bar\'; got "baz" (string)') end it "does not raises an error if default is an symbol and type string" do