diff options
author | Rick Hull <rick.hull@gmail.com> | 2014-12-29 01:36:32 -0500 |
---|---|---|
committer | Rick Hull <rick.hull@gmail.com> | 2014-12-29 12:31:20 -0500 |
commit | 1ef4327cef9f74caaafc2dcb8201aa71f0eff17d (patch) | |
tree | 208fa3000a76e28b0fa51c2f701fe8f46c9149e9 /test | |
parent | 6e0db709d5c77d9cca1559da8a118d358734275f (diff) | |
download | slop-1ef4327cef9f74caaafc2dcb8201aa71f0eff17d.tar.gz |
add Float support
- in lib/
- in test/
- in README
Diffstat (limited to 'test')
-rw-r--r-- | test/types_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/types_test.rb b/test/types_test.rb index 3696126..e060df5 100644 --- a/test/types_test.rb +++ b/test/types_test.rb @@ -34,6 +34,24 @@ describe Slop::IntegerOption do end end +describe Slop::FloatOption do + before do + @options = Slop::Options.new + @apr = @options.float "--apr" + @apr_value = 2.9 + @result = @options.parse %W(--apr #{@apr_value}) + end + + it "returns the value as a float" do + assert_equal @apr_value, @result[:apr] + end + + it "returns nil for non-numbers by default" do + @result.parser.reset.parse %w(--apr hello) + assert_equal nil, @result[:apr] + end +end + describe Slop::ArrayOption do before do @options = Slop::Options.new |