diff options
author | Lee Jarvis <lee@jarvis.co> | 2010-12-04 00:29:06 +0000 |
---|---|---|
committer | Lee Jarvis <lee@jarvis.co> | 2010-12-04 00:29:06 +0000 |
commit | f80987b9c24935e5ede3d789113d3b0051302924 (patch) | |
tree | e8c80241d049453f7c28def87149467d8df5e1b2 | |
parent | dd26cf6d228374981ab0930a90728d200d0a53ec (diff) | |
parent | b1b76be7272853aecb84d948379d59dbfff426fc (diff) | |
download | slop-f80987b9c24935e5ede3d789113d3b0051302924.tar.gz |
Merge branch 'fix_options_hash' of https://github.com/gregf/slop
-rw-r--r-- | lib/slop.rb | 4 | ||||
-rw-r--r-- | spec/slop_spec.rb | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/slop.rb b/lib/slop.rb index d1e710e..e83d82e 100644 --- a/lib/slop.rb +++ b/lib/slop.rb @@ -106,7 +106,7 @@ class Slop # @return [Hash] def options_hash out = {} - each_option do |opt| + options.each do |opt| if opt.requires_argument? or opt.has_default? out[opt.key] = opt.argument_value || opt.default end @@ -155,4 +155,4 @@ class Slop return unless flag flag[1, 2].include?('-') end -end
\ No newline at end of file +end diff --git a/spec/slop_spec.rb b/spec/slop_spec.rb index 42b9658..bacd686 100644 --- a/spec/slop_spec.rb +++ b/spec/slop_spec.rb @@ -44,6 +44,12 @@ describe Slop do end end + describe "options_hash" do + it "returns a hash" do + @slop.options_hash.should be_kind_of(Hash) + end + end + describe "option_for" do it "returns an option" do @slop.option_for(:v).should be_kind_of(Slop::Option) @@ -110,4 +116,4 @@ describe Slop do end end -end
\ No newline at end of file +end |