Skip to content
Browse files

Ensure given hash keys are converted to string before merging values.

  • Loading branch information...
1 parent 5fd48dc commit 5a8fc0083e56cc0f2205a2f6580f88592fcf887c @josevalim josevalim committed
Showing with 6 additions and 1 deletion.
  1. +1 −1 lib/thor/parser/options.rb
  2. +5 −0 spec/parser/options_spec.rb
View
2 lib/thor/parser/options.rb
@@ -34,7 +34,7 @@ def initialize(hash_options={}, defaults={})
# Add defaults
defaults.each do |key, value|
- @assigns[key] = value
+ @assigns[key.to_s] = value
@non_assigned_required.delete(hash_options[key])
end
View
5 spec/parser/options_spec.rb
@@ -93,6 +93,11 @@ def check_unknown!
parse["bar"].must == "baz"
end
+ it "gives higher priority to defaults given in the hash" do
+ create Hash[:bar => true], Hash[:bar => false]
+ parse["bar"].must == false
+ end
+
it "raises an error for unknown switches" do
create :foo => "baz", :bar => :required
parse("--bar", "baz", "--baz", "unknown")

0 comments on commit 5a8fc00

Please sign in to comment.
Something went wrong with that request. Please try again.