diff options
author | Lee Jarvis <ljjarvis@gmail.com> | 2013-11-04 14:46:09 +0000 |
---|---|---|
committer | Lee Jarvis <ljjarvis@gmail.com> | 2013-11-04 14:47:07 +0000 |
commit | af15855b9ece13e3f9c88874d3cce9aae437b4af (patch) | |
tree | 48a23da68e1a707bb790af4dcdfd1e031a3d23b0 | |
parent | d07e2b3f429290d5a0a56f61bcd9012967546254 (diff) | |
download | slop-next.tar.gz |
Pass builder options to result hash, not parsed options onlynext
-rw-r--r-- | lib/slop/result.rb | 2 | ||||
-rw-r--r-- | test/builder_test.rb | 2 | ||||
-rw-r--r-- | test/result_test.rb | 6 |
3 files changed, 4 insertions, 6 deletions
diff --git a/lib/slop/result.rb b/lib/slop/result.rb index 100413f..2e12dff 100644 --- a/lib/slop/result.rb +++ b/lib/slop/result.rb @@ -33,7 +33,7 @@ module Slop end def to_hash - parser.options.each_with_object({}) do |option, result| + builder.options.each_with_object({}) do |option, result| result[option.key] = option.value end end diff --git a/test/builder_test.rb b/test/builder_test.rb index 3fee95c..35f446d 100644 --- a/test/builder_test.rb +++ b/test/builder_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Slop::Builder do - subject { Slop::Builder.new } + subject { Slop::Builder.new } describe "#on" do it "returns a Slop::Option" do diff --git a/test/result_test.rb b/test/result_test.rb index c112c05..807be74 100644 --- a/test/result_test.rb +++ b/test/result_test.rb @@ -1,11 +1,11 @@ require "test_helper" describe Slop::Result do - subject { Slop.parse(%w"--name Lee") { |o| o.string :name } } + subject { Slop.parse(%w"--name Lee") { |o| o.string :name; o.bool :verbose } } describe "to_h" do it "returns option => arguments in hash form" do - subject.to_hash.must_equal({ name: "Lee" }) + subject.to_hash.must_equal({ name: "Lee", verbose: nil }) end end @@ -13,7 +13,6 @@ describe Slop::Result do it "fetches the option and calls .value on it" do subject["name"].must_equal "Lee" end - end describe "method_missing" do @@ -26,7 +25,6 @@ describe Slop::Result do it "raises if not a valid option" do -> { subject.bar? }.must_raise(NoMethodError) end - end end |