summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2013-06-16 09:42:31 +0100
committerLee Jarvis <ljjarvis@gmail.com>2013-08-13 20:34:43 +0100
commit6e41cbac607029ef6739da3a7b6c39036fd4ac6c (patch)
tree876f71ec13a49a43d6df53b7e228cec12ae415ae /test
parent7d62cc1b72e19b965fd313f2712db2fa4853fb33 (diff)
downloadslop-6e41cbac607029ef6739da3a7b6c39036fd4ac6c.tar.gz
Slop is now strict by default, and adds --help by default
Also use 1.9 hash syntax
Diffstat (limited to 'test')
-rw-r--r--test/option_test.rb8
-rw-r--r--test/slop_test.rb8
2 files changed, 8 insertions, 8 deletions
diff --git a/test/option_test.rb b/test/option_test.rb
index c26fc0c..c57126d 100644
--- a/test/option_test.rb
+++ b/test/option_test.rb
@@ -7,7 +7,7 @@ class OptionTest < TestCase
def option_with_argument(*args, &block)
options = args.shift
- slop = Slop.new
+ slop = Slop.new(strict: false, help: false)
option = slop.opt(*args)
slop.parse(options)
slop.options.find {|opt| opt.key == option.key }
@@ -57,12 +57,12 @@ class OptionTest < TestCase
opts.parse %w'-f 1'
assert_equal 1, opts[:f]
- opts = Slop.new(:strict => true) { on :r=, :as => Integer }
+ opts = Slop.new { on :r=, :as => Integer }
assert_raises(Slop::InvalidArgumentError) { opts.parse %w/-r abc/ }
end
test "float type cast" do
- opts = Slop.new(:strict => true) { on :r=, :as => Float }
+ opts = Slop.new { on :r=, :as => Float }
assert_raises(Slop::InvalidArgumentError) { opts.parse %w/-r abc/ }
end
@@ -80,7 +80,7 @@ class OptionTest < TestCase
assert_equal((1..1), option_value(%w/-r 1/, :r=, :as => Range))
assert_equal((-1..10), option_value(%w/-r -1..10/, :r, :as => Range, :optional_argument => true))
- opts = Slop.new(:strict => true) { on :r=, :as => Range }
+ opts = Slop.new { on :r=, :as => Range }
assert_raises(Slop::InvalidArgumentError) { opts.parse %w/-r abc/ }
end
diff --git a/test/slop_test.rb b/test/slop_test.rb
index 1a3a520..0a1bf1a 100644
--- a/test/slop_test.rb
+++ b/test/slop_test.rb
@@ -164,7 +164,7 @@ class SlopTest < TestCase
end
test "on no_options callback" do
- opts = Slop.new
+ opts = Slop.new(strict: false)
foo = nil
opts.add_callback(:no_options) { foo = "bar" }
opts.parse %w( --foo --bar etc hello )
@@ -293,7 +293,7 @@ class SlopTest < TestCase
end
test "ignoring case" do
- opts = Slop.new { on :foo }
+ opts = Slop.new(strict: false) { on :foo }
opts.parse %w' --FOO bar '
assert_nil opts[:foo]
@@ -318,7 +318,7 @@ class SlopTest < TestCase
test "ensure negative integers are not processed as options" do
items = %w(-1)
- Slop.parse!(items)
+ Slop.parse!(items, strict: false)
assert_equal %w(-1), items
end
@@ -463,7 +463,7 @@ class SlopTest < TestCase
test "ensure a runner does not execute when a help option is present" do
items = []
- Slop.parse(%w'--help foo bar') do
+ Slop.parse(%w'--help foo bar', strict: false) do
run { |o, a| items.concat a }
end
assert_equal %w'--help foo bar', items