diff options
Diffstat (limited to 'spec/rubyspec/library/getoptlong')
-rw-r--r-- | spec/rubyspec/library/getoptlong/each_option_spec.rb | 7 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/each_spec.rb | 7 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/error_message_spec.rb | 23 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/get_option_spec.rb | 7 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/get_spec.rb | 7 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/initialize_spec.rb | 28 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/ordering_spec.rb | 38 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/set_options_spec.rb | 98 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/shared/each.rb | 18 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/shared/get.rb | 64 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/terminate_spec.rb | 30 | ||||
-rw-r--r-- | spec/rubyspec/library/getoptlong/terminated_spec.rb | 17 |
12 files changed, 0 insertions, 344 deletions
diff --git a/spec/rubyspec/library/getoptlong/each_option_spec.rb b/spec/rubyspec/library/getoptlong/each_option_spec.rb deleted file mode 100644 index c58815bfa9..0000000000 --- a/spec/rubyspec/library/getoptlong/each_option_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' -require File.expand_path('../shared/each', __FILE__) - -describe "GetoptLong#each_option" do - it_behaves_like(:getoptlong_each, :each_option) -end diff --git a/spec/rubyspec/library/getoptlong/each_spec.rb b/spec/rubyspec/library/getoptlong/each_spec.rb deleted file mode 100644 index d09f84a6db..0000000000 --- a/spec/rubyspec/library/getoptlong/each_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' -require File.expand_path('../shared/each', __FILE__) - -describe "GetoptLong#each" do - it_behaves_like(:getoptlong_each, :each) -end diff --git a/spec/rubyspec/library/getoptlong/error_message_spec.rb b/spec/rubyspec/library/getoptlong/error_message_spec.rb deleted file mode 100644 index 3f44f538c6..0000000000 --- a/spec/rubyspec/library/getoptlong/error_message_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' - -describe "GetoptLong#error_message" do - it "returns nil if no error occurred" do - opts = GetoptLong.new - opts.error_message.should == nil - end - - it "returns the error message of the last error that occurred" do - argv [] do - opts = GetoptLong.new - opts.quiet = true - opts.get - -> { - opts.ordering = GetoptLong::PERMUTE - }.should raise_error(ArgumentError) { |e| - e.message.should == "argument error" - opts.error_message.should == "argument error" - } - end - end -end diff --git a/spec/rubyspec/library/getoptlong/get_option_spec.rb b/spec/rubyspec/library/getoptlong/get_option_spec.rb deleted file mode 100644 index c56903e68e..0000000000 --- a/spec/rubyspec/library/getoptlong/get_option_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' -require File.expand_path('../shared/get', __FILE__) - -describe "GetoptLong#get_option" do - it_behaves_like(:getoptlong_get, :get_option) -end diff --git a/spec/rubyspec/library/getoptlong/get_spec.rb b/spec/rubyspec/library/getoptlong/get_spec.rb deleted file mode 100644 index ba1a1be6ad..0000000000 --- a/spec/rubyspec/library/getoptlong/get_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' -require File.expand_path('../shared/get', __FILE__) - -describe "GetoptLong#get" do - it_behaves_like(:getoptlong_get, :get) -end diff --git a/spec/rubyspec/library/getoptlong/initialize_spec.rb b/spec/rubyspec/library/getoptlong/initialize_spec.rb deleted file mode 100644 index 6ac46b8b5d..0000000000 --- a/spec/rubyspec/library/getoptlong/initialize_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' - -describe "GetoptLong#initialize" do - it "sets ordering to REQUIRE_ORDER if ENV['POSIXLY_CORRECT'] is set" do - begin - old_env_value = ENV["POSIXLY_CORRECT"] - ENV["POSIXLY_CORRECT"] = "" - - opt = GetoptLong.new - opt.ordering.should == GetoptLong::REQUIRE_ORDER - ensure - ENV["POSIXLY_CORRECT"] = old_env_value - end - end - - it "sets ordering to PERMUTE if ENV['POSIXLY_CORRECT'] is not set" do - begin - old_env_value = ENV["POSIXLY_CORRECT"] - ENV["POSIXLY_CORRECT"] = nil - - opt = GetoptLong.new - opt.ordering.should == GetoptLong::PERMUTE - ensure - ENV["POSIXLY_CORRECT"] = old_env_value - end - end -end diff --git a/spec/rubyspec/library/getoptlong/ordering_spec.rb b/spec/rubyspec/library/getoptlong/ordering_spec.rb deleted file mode 100644 index e445de2255..0000000000 --- a/spec/rubyspec/library/getoptlong/ordering_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' - -describe "GetoptLong#ordering=" do - it "raises an ArgumentError if called after processing has started" do - argv [ "--size", "10k", "--verbose" ] do - opts = GetoptLong.new([ '--size', GetoptLong::REQUIRED_ARGUMENT ], - [ '--verbose', GetoptLong::NO_ARGUMENT ]) - opts.quiet = true - opts.get - - lambda { - opts.ordering = GetoptLong::PERMUTE - }.should raise_error(ArgumentError) - end - end - - it "raises an ArgumentError if given an invalid value" do - opts = GetoptLong.new - - lambda { - opts.ordering = 12345 - }.should raise_error(ArgumentError) - end - - it "does not allow changing ordering to PERMUTE if ENV['POSIXLY_CORRECT'] is set" do - begin - old_env_value = ENV['POSIXLY_CORRECT'] - ENV['POSIXLY_CORRECT'] = "" - - opts = GetoptLong.new - opts.ordering = GetoptLong::PERMUTE - opts.ordering.should == GetoptLong::REQUIRE_ORDER - ensure - ENV['POSIXLY_CORRECT'] = old_env_value - end - end -end diff --git a/spec/rubyspec/library/getoptlong/set_options_spec.rb b/spec/rubyspec/library/getoptlong/set_options_spec.rb deleted file mode 100644 index 39d6991bf5..0000000000 --- a/spec/rubyspec/library/getoptlong/set_options_spec.rb +++ /dev/null @@ -1,98 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' - -describe "GetoptLong#set_options" do - before :each do - @opts = GetoptLong.new - end - - it "allows setting command line options" do - argv ["--size", "10k", "-v", "arg1", "arg2"] do - @opts.set_options( - ["--size", GetoptLong::REQUIRED_ARGUMENT], - ["--verbose", "-v", GetoptLong::NO_ARGUMENT] - ) - - @opts.get.should == ["--size", "10k"] - @opts.get.should == ["--verbose", ""] - @opts.get.should == nil - end - end - - it "discards previously defined command line options" do - argv ["--size", "10k", "-v", "arg1", "arg2"] do - @opts.set_options( - ["--size", GetoptLong::REQUIRED_ARGUMENT], - ["--verbose", "-v", GetoptLong::NO_ARGUMENT] - ) - - @opts.set_options( - ["-s", "--size", GetoptLong::REQUIRED_ARGUMENT], - ["-v", GetoptLong::NO_ARGUMENT] - ) - - @opts.get.should == ["-s", "10k"] - @opts.get.should == ["-v", ""] - @opts.get.should == nil - end - end - - it "raises an ArgumentError if too many argument flags where given" do - argv [] do - lambda { - @opts.set_options(["--size", GetoptLong::NO_ARGUMENT, GetoptLong::REQUIRED_ARGUMENT]) - }.should raise_error(ArgumentError) - end - end - - it "raises a RuntimeError if processing has already started" do - argv [] do - @opts.get - lambda { - @opts.set_options() - }.should raise_error(RuntimeError) - end - end - - it "raises an ArgumentError if no argument flag was given" do - argv [] do - lambda { - @opts.set_options(["--size"]) - }.should raise_error(ArgumentError) - end - end - - it "raises an ArgumentError if one of the given arguments is not an Array" do - argv [] do - lambda { - @opts.set_options( - ["--size", GetoptLong::REQUIRED_ARGUMENT], - "test") - }.should raise_error(ArgumentError) - end - end - - it "raises an ArgumentError if the same option is given twice" do - argv [] do - lambda { - @opts.set_options( - ["--size", GetoptLong::NO_ARGUMENT], - ["--size", GetoptLong::OPTIONAL_ARGUMENT]) - }.should raise_error(ArgumentError) - - lambda { - @opts.set_options( - ["--size", GetoptLong::NO_ARGUMENT], - ["-s", "--size", GetoptLong::OPTIONAL_ARGUMENT]) - }.should raise_error(ArgumentError) - end - end - - it "raises an ArgumentError if the given option is invalid" do - argv [] do - lambda { - @opts.set_options(["-size", GetoptLong::NO_ARGUMENT]) - }.should raise_error(ArgumentError) - end - end -end diff --git a/spec/rubyspec/library/getoptlong/shared/each.rb b/spec/rubyspec/library/getoptlong/shared/each.rb deleted file mode 100644 index b534e24c0f..0000000000 --- a/spec/rubyspec/library/getoptlong/shared/each.rb +++ /dev/null @@ -1,18 +0,0 @@ -describe :getoptlong_each, shared: true do - before :each do - @opts = GetoptLong.new( - [ '--size', '-s', GetoptLong::REQUIRED_ARGUMENT ], - [ '--verbose', '-v', GetoptLong::NO_ARGUMENT ], - [ '--query', '-q', GetoptLong::NO_ARGUMENT ], - [ '--check', '--valid', '-c', GetoptLong::NO_ARGUMENT ] - ) - end - - it "passes each argument/value pair to the block" do - argv [ "--size", "10k", "-v", "-q", "a.txt", "b.txt" ] do - pairs = [] - @opts.send(@method) { |arg, val| pairs << [ arg, val ] } - pairs.should == [ [ "--size", "10k" ], [ "--verbose", "" ], [ "--query", ""] ] - end - end -end diff --git a/spec/rubyspec/library/getoptlong/shared/get.rb b/spec/rubyspec/library/getoptlong/shared/get.rb deleted file mode 100644 index 91a0fbaacc..0000000000 --- a/spec/rubyspec/library/getoptlong/shared/get.rb +++ /dev/null @@ -1,64 +0,0 @@ -describe :getoptlong_get, shared: true do - before :each do - @opts = GetoptLong.new( - [ '--size', '-s', GetoptLong::REQUIRED_ARGUMENT ], - [ '--verbose', '-v', GetoptLong::NO_ARGUMENT ], - [ '--query', '-q', GetoptLong::NO_ARGUMENT ], - [ '--check', '--valid', '-c', GetoptLong::NO_ARGUMENT ] - ) - @opts.quiet = true # silence using $deferr - end - - it "returns the next option name and its argument as an Array" do - argv [ "--size", "10k", "-v", "-q", "a.txt", "b.txt" ] do - @opts.send(@method).should == [ "--size", "10k" ] - @opts.send(@method).should == [ "--verbose", "" ] - @opts.send(@method).should == [ "--query", ""] - @opts.send(@method).should == nil - end - end - - it "shifts ARGV on each call" do - argv [ "--size", "10k", "-v", "-q", "a.txt", "b.txt" ] do - @opts.send(@method) - ARGV.should == [ "-v", "-q", "a.txt", "b.txt" ] - - @opts.send(@method) - ARGV.should == [ "-q", "a.txt", "b.txt" ] - - @opts.send(@method) - ARGV.should == [ "a.txt", "b.txt" ] - - @opts.send(@method) - ARGV.should == [ "a.txt", "b.txt" ] - end - end - - it "terminates processing when encountering '--'" do - argv [ "--size", "10k", "--", "-v", "-q", "a.txt", "b.txt" ] do - @opts.send(@method) - ARGV.should == ["--", "-v", "-q", "a.txt", "b.txt"] - - @opts.send(@method) - ARGV.should == ["-v", "-q", "a.txt", "b.txt"] - - @opts.send(@method) - ARGV.should == ["-v", "-q", "a.txt", "b.txt"] - end - end - - it "raises a if an argument was required, but none given" do - argv [ "--size" ] do - lambda { @opts.send(@method) }.should raise_error(GetoptLong::MissingArgument) - end - end - - ruby_version_is "2.5" do - # https://bugs.ruby-lang.org/issues/13858 - it "returns multiline argument" do - argv [ "--size=\n10k\n" ] do - @opts.send(@method).should == [ "--size", "\n10k\n" ] - end - end - end -end diff --git a/spec/rubyspec/library/getoptlong/terminate_spec.rb b/spec/rubyspec/library/getoptlong/terminate_spec.rb deleted file mode 100644 index ad9f9a1623..0000000000 --- a/spec/rubyspec/library/getoptlong/terminate_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' - -describe "GetoptLong#terminate" do - before :each do - @opts = GetoptLong.new( - [ '--size', '-s', GetoptLong::REQUIRED_ARGUMENT ], - [ '--verbose', '-v', GetoptLong::NO_ARGUMENT ], - [ '--query', '-q', GetoptLong::NO_ARGUMENT ], - [ '--check', '--valid', '-c', GetoptLong::NO_ARGUMENT ] - ) - end - - it "terminates option proccessing" do - argv [ "--size", "10k", "-v", "-q", "a.txt", "b.txt" ] do - @opts.get.should == [ "--size", "10k" ] - @opts.terminate - @opts.get.should == nil - end - end - - it "returns self when option processsing is terminated" do - @opts.terminate.should == @opts - end - - it "returns nil when option processing was already terminated" do - @opts.terminate - @opts.terminate.should == nil - end -end diff --git a/spec/rubyspec/library/getoptlong/terminated_spec.rb b/spec/rubyspec/library/getoptlong/terminated_spec.rb deleted file mode 100644 index feaf2bc09e..0000000000 --- a/spec/rubyspec/library/getoptlong/terminated_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'getoptlong' - -describe "GetoptLong#terminated?" do - it "returns true if option processing has terminated" do - argv [ "--size", "10k" ] do - opts = GetoptLong.new(["--size", GetoptLong::REQUIRED_ARGUMENT]) - opts.terminated?.should == false - - opts.get.should == ["--size", "10k"] - opts.terminated?.should == false - - opts.get.should == nil - opts.terminated?.should == true - end - end -end |