-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "spec/mspec/tool/wrap_with_guard.rb 'ruby_version_is ""..."3.4…
…"' spec/ruby/library/getoptlong/**/*.rb" This reverts commit 8538c30.
- Loading branch information
Showing
10 changed files
with
184 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
require_relative '../../spec_helper' | ||
require 'getoptlong' | ||
require_relative 'shared/each' | ||
|
||
ruby_version_is ""..."3.4" do | ||
require 'getoptlong' | ||
require_relative 'shared/each' | ||
|
||
describe "GetoptLong#each_option" do | ||
it_behaves_like :getoptlong_each, :each_option | ||
end | ||
describe "GetoptLong#each_option" do | ||
it_behaves_like :getoptlong_each, :each_option | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
require_relative '../../spec_helper' | ||
require 'getoptlong' | ||
require_relative 'shared/each' | ||
|
||
ruby_version_is ""..."3.4" do | ||
require 'getoptlong' | ||
require_relative 'shared/each' | ||
|
||
describe "GetoptLong#each" do | ||
it_behaves_like :getoptlong_each, :each | ||
end | ||
describe "GetoptLong#each" do | ||
it_behaves_like :getoptlong_each, :each | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
require_relative '../../spec_helper' | ||
require 'getoptlong' | ||
|
||
ruby_version_is ""..."3.4" do | ||
require 'getoptlong' | ||
describe "GetoptLong#error_message" do | ||
it "returns nil if no error occurred" do | ||
opts = GetoptLong.new | ||
opts.error_message.should == nil | ||
end | ||
|
||
describe "GetoptLong#error_message" do | ||
it "returns nil if no error occurred" do | ||
it "returns the error message of the last error that occurred" do | ||
argv [] 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 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
require_relative '../../spec_helper' | ||
require 'getoptlong' | ||
require_relative 'shared/get' | ||
|
||
ruby_version_is ""..."3.4" do | ||
require 'getoptlong' | ||
require_relative 'shared/get' | ||
|
||
describe "GetoptLong#get_option" do | ||
it_behaves_like :getoptlong_get, :get_option | ||
end | ||
describe "GetoptLong#get_option" do | ||
it_behaves_like :getoptlong_get, :get_option | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
require_relative '../../spec_helper' | ||
require 'getoptlong' | ||
require_relative 'shared/get' | ||
|
||
ruby_version_is ""..."3.4" do | ||
require 'getoptlong' | ||
require_relative 'shared/get' | ||
|
||
describe "GetoptLong#get" do | ||
it_behaves_like :getoptlong_get, :get | ||
end | ||
describe "GetoptLong#get" do | ||
it_behaves_like :getoptlong_get, :get | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
require_relative '../../spec_helper' | ||
require 'getoptlong' | ||
|
||
ruby_version_is ""..."3.4" do | ||
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"] = "" | ||
|
||
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 | ||
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 | ||
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 | ||
opt = GetoptLong.new | ||
opt.ordering.should == GetoptLong::PERMUTE | ||
ensure | ||
ENV["POSIXLY_CORRECT"] = old_env_value | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,38 @@ | ||
require_relative '../../spec_helper' | ||
require 'getoptlong' | ||
|
||
ruby_version_is ""..."3.4" do | ||
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 | ||
|
||
-> { | ||
opts.ordering = GetoptLong::PERMUTE | ||
}.should raise_error(ArgumentError) | ||
end | ||
end | ||
|
||
it "raises an ArgumentError if given an invalid value" do | ||
opts = GetoptLong.new | ||
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 | ||
|
||
-> { | ||
opts.ordering = 12345 | ||
opts.ordering = GetoptLong::PERMUTE | ||
}.should raise_error(ArgumentError) | ||
end | ||
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'] = "" | ||
it "raises an ArgumentError if given an invalid value" do | ||
opts = GetoptLong.new | ||
|
||
opts = GetoptLong.new | ||
opts.ordering = GetoptLong::PERMUTE | ||
opts.ordering.should == GetoptLong::REQUIRE_ORDER | ||
ensure | ||
ENV['POSIXLY_CORRECT'] = old_env_value | ||
end | ||
-> { | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,98 @@ | ||
require_relative '../../spec_helper' | ||
require 'getoptlong' | ||
|
||
ruby_version_is ""..."3.4" do | ||
require 'getoptlong' | ||
|
||
describe "GetoptLong#set_options" do | ||
before :each do | ||
@opts = GetoptLong.new | ||
end | ||
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] | ||
) | ||
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 | ||
@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] | ||
) | ||
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.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 | ||
@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 | ||
-> { | ||
@opts.set_options(["--size", GetoptLong::NO_ARGUMENT, GetoptLong::REQUIRED_ARGUMENT]) | ||
}.should raise_error(ArgumentError) | ||
end | ||
it "raises an ArgumentError if too many argument flags where given" do | ||
argv [] do | ||
-> { | ||
@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 | ||
-> { | ||
@opts.set_options() | ||
}.should raise_error(RuntimeError) | ||
end | ||
it "raises a RuntimeError if processing has already started" do | ||
argv [] do | ||
@opts.get | ||
-> { | ||
@opts.set_options() | ||
}.should raise_error(RuntimeError) | ||
end | ||
end | ||
|
||
it "raises an ArgumentError if no argument flag was given" do | ||
argv [] do | ||
-> { | ||
@opts.set_options(["--size"]) | ||
}.should raise_error(ArgumentError) | ||
end | ||
it "raises an ArgumentError if no argument flag was given" do | ||
argv [] do | ||
-> { | ||
@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 | ||
-> { | ||
@opts.set_options( | ||
["--size", GetoptLong::REQUIRED_ARGUMENT], | ||
"test") | ||
}.should raise_error(ArgumentError) | ||
end | ||
it "raises an ArgumentError if one of the given arguments is not an Array" do | ||
argv [] do | ||
-> { | ||
@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 | ||
-> { | ||
@opts.set_options( | ||
["--size", GetoptLong::NO_ARGUMENT], | ||
["--size", GetoptLong::OPTIONAL_ARGUMENT]) | ||
}.should raise_error(ArgumentError) | ||
it "raises an ArgumentError if the same option is given twice" do | ||
argv [] do | ||
-> { | ||
@opts.set_options( | ||
["--size", GetoptLong::NO_ARGUMENT], | ||
["--size", GetoptLong::OPTIONAL_ARGUMENT]) | ||
}.should raise_error(ArgumentError) | ||
|
||
-> { | ||
@opts.set_options( | ||
["--size", GetoptLong::NO_ARGUMENT], | ||
["-s", "--size", GetoptLong::OPTIONAL_ARGUMENT]) | ||
}.should raise_error(ArgumentError) | ||
end | ||
-> { | ||
@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 | ||
-> { | ||
@opts.set_options(["-size", GetoptLong::NO_ARGUMENT]) | ||
}.should raise_error(ArgumentError) | ||
end | ||
it "raises an ArgumentError if the given option is invalid" do | ||
argv [] do | ||
-> { | ||
@opts.set_options(["-size", GetoptLong::NO_ARGUMENT]) | ||
}.should raise_error(ArgumentError) | ||
end | ||
end | ||
end |
Oops, something went wrong.