diff options
author | Lee Jarvis <ljjarvis@gmail.com> | 2014-12-30 15:07:58 +0000 |
---|---|---|
committer | Lee Jarvis <ljjarvis@gmail.com> | 2014-12-30 15:07:58 +0000 |
commit | eb0164aea27b43f24c05e16c3d699dac520c9945 (patch) | |
tree | 6cbef486159d587a9948891fb197a4f8d719faa6 /test | |
parent | d6b91418f9cb8aa141ecb1f4c00c5f06ae293b67 (diff) | |
download | slop-eb0164aea27b43f24c05e16c3d699dac520c9945.tar.gz |
Reset parser every time parse is called
Diffstat (limited to 'test')
-rw-r--r-- | test/parser_test.rb | 10 | ||||
-rw-r--r-- | test/result_test.rb | 8 | ||||
-rw-r--r-- | test/types_test.rb | 10 |
3 files changed, 14 insertions, 14 deletions
diff --git a/test/parser_test.rb b/test/parser_test.rb index fe3b714..0dc361c 100644 --- a/test/parser_test.rb +++ b/test/parser_test.rb @@ -11,13 +11,13 @@ describe Slop::Parser do end it "ignores everything after --" do - @parser.reset.parse %w(-v -- --name lee) + @parser.parse %w(-v -- --name lee) assert_equal [@verbose], @parser.used_options end it "parses flag=argument" do @options.integer "-p", "--port" - @result.parser.reset.parse %w(--name=bob -p=123) + @result.parser.parse %w(--name=bob -p=123) assert_equal "bob", @result[:name] assert_equal 123, @result[:port] end @@ -28,19 +28,19 @@ describe Slop::Parser do end it "parses boolean flags" do - @result.parser.reset.parse %w(-qv) + @result.parser.parse %w(-qv) assert_equal true, @result.quiet? assert_equal true, @result.verbose? end it "sends the argument to the last flag" do - @result.parser.reset.parse %w(-qvn foo) + @result.parser.parse %w(-qvn foo) assert_equal "foo", @result[:name] end it "doesn't screw up single hyphen long options" do @options.string "-host" - @result.parser.reset.parse %w(-host localhost) + @result.parser.parse %w(-host localhost) assert_equal "localhost", @result[:host] end end diff --git a/test/result_test.rb b/test/result_test.rb index 41ed253..32574f1 100644 --- a/test/result_test.rb +++ b/test/result_test.rb @@ -22,27 +22,27 @@ describe Slop::Result do it "increments option count" do # test this here so it's more "full stack" assert_equal 1, @verbose.count - @result.parser.reset.parse %w(-v --verbose) + @result.parser.parse %w(-v --verbose) assert_equal 2, @verbose.count end it "handles default values" do @options.string("--foo", default: "bar") - @result.parser.reset.parse %w() + @result.parser.parse %w() assert_equal "bar", @result[:foo] end it "handles custom finishing" do @options.string "--foo" @options.reverse_everything "-r" - @result.parser.reset.parse %w(-r --name lee --foo bar) + @result.parser.parse %w(-r --name lee --foo bar) assert_equal %w(eel rab), @result.to_hash.values_at(:name, :foo) end it "yields arguments to option blocks" do output = nil @options.string("--foo") { |v| output = v } - @result.parser.reset.parse %w(--foo bar) + @result.parser.parse %w(--foo bar) assert_equal output, "bar" end diff --git a/test/types_test.rb b/test/types_test.rb index 1716776..39cccc9 100644 --- a/test/types_test.rb +++ b/test/types_test.rb @@ -29,7 +29,7 @@ describe Slop::IntegerOption do end it "returns nil for non-numbers by default" do - @result.parser.reset.parse %w(--age hello) + @result.parser.parse %w(--age hello) assert_equal nil, @result[:age] end end @@ -47,7 +47,7 @@ describe Slop::FloatOption do end it "returns nil for non-numbers by default" do - @result.parser.reset.parse %w(--apr hello) + @result.parser.parse %w(--apr hello) assert_equal nil, @result[:apr] end end @@ -70,17 +70,17 @@ describe Slop::ArrayOption do end it "collects multiple option values" do - @result.parser.reset.parse %w(--files foo.txt --files bar.rb) + @result.parser.parse %w(--files foo.txt --files bar.rb) assert_equal %w(foo.txt bar.rb), @result[:files] end it "can use a custom delimiter" do - @result.parser.reset.parse %w(-d foo.txt:bar.rb) + @result.parser.parse %w(-d foo.txt:bar.rb) assert_equal %w(foo.txt bar.rb), @result[:d] end it "can use a custom limit" do - @result.parser.reset.parse %w(-l foo,bar,baz) + @result.parser.parse %w(-l foo,bar,baz) assert_equal ["foo", "bar,baz"], @result[:l] end end |