From 80d5484f99a28b09d745d4d3637aed8a1744a81b Mon Sep 17 00:00:00 2001 From: Ben Brady Date: Tue, 24 Nov 2015 20:18:00 -0800 Subject: Fix bug where true is passed to BoolOption block regardless of --no- prefix --- test/types_test.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/types_test.rb b/test/types_test.rb index 5950016..f806c48 100644 --- a/test/types_test.rb +++ b/test/types_test.rb @@ -6,7 +6,9 @@ describe Slop::BoolOption do @verbose = @options.bool "--verbose" @quiet = @options.bool "--quiet" @inversed = @options.bool "--inversed", default: true - @result = @options.parse %w(--verbose --no-inversed) + @bloc = @options.bool("--bloc"){|val| (@bloc_val ||= []) << val} + @result = @options.parse %w(--verbose --no-inversed + --bloc --no-bloc) end it "returns true if used" do @@ -20,6 +22,10 @@ describe Slop::BoolOption do it "can be inversed via --no- prefix" do assert_equal false, @result[:inversed] end + + it "will invert the value passed to &block via --no- prefix" do + assert_equal [true, false], @bloc_val + end end describe Slop::IntegerOption do -- cgit v1.2.1