summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBen Brady <bbrady@edgecast.com>2015-11-24 20:18:00 -0800
committerBen Brady <bbrady@edgecast.com>2015-11-24 20:18:00 -0800
commit80d5484f99a28b09d745d4d3637aed8a1744a81b (patch)
treeb44a4d6e7ad80e6877b36503ac1b1d602f8c814f /test
parent2c532b9a153ffbb982d67d1297e0e94fb08f7040 (diff)
downloadslop-80d5484f99a28b09d745d4d3637aed8a1744a81b.tar.gz
Fix bug where true is passed to BoolOption block regardless of --no- prefix
Diffstat (limited to 'test')
-rw-r--r--test/types_test.rb8
1 files changed, 7 insertions, 1 deletions
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