8000 [Feature #20187] Skip examples for bundled gems at Ruby 3.4 by hsbt · Pull Request #9960 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

[Feature #20187] Skip examples for bundled gems at Ruby 3.4 #9960

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Prev Previous commit
Next Next commit
Reapply spec/mspec/tool/wrap_with_guard.rb 'ruby_version_is ""..."3.4…
…"' spec/ruby/library/getoptlong/**/*.rb
  • Loading branch information
hsbt committed Feb 14, 2024
commit be62a871f8118046f98f0a2faf3381bb6f606e79
11 changes: 7 additions & 4 deletions spec/ruby/library/getoptlong/each_option_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require_relative '../../spec_helper'
require 'getoptlong'
require_relative 'shared/each'

describe "GetoptLong#each_option" do
it_behaves_like :getoptlong_each, :each_option
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
end
11 changes: 7 additions & 4 deletions spec/ruby/library/getoptlong/each_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require_relative '../../spec_helper'
require 'getoptlong'
require_relative 'shared/each'

describe "GetoptLong#each" do
it_behaves_like :getoptlong_each, :each
< 8000 /td> ruby_version_is ""..."3.4" do
require 'getoptlong'
require_relative 'shared/each'

describe "GetoptLong#each" do
it_behaves_like :getoptlong_each, :each
end
end
35 changes: 19 additions & 16 deletions spec/ruby/library/getoptlong/error_message_spec.rb
< 8000 td class="blob-code blob-code-addition js-file-line"> opts = GetoptLong.new
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
require_relative '../../spec_helper'
require 'getoptlong'

describe "GetoptLong#error_message" do
it "returns nil if no error occurred" do
opts = GetoptLong.new
opts.error_message.should == nil
end
ruby_version_is ""..."3.4" do
require 'getoptlong'

it "returns the error message of the last error that occurred" do
argv [] do
describe "GetoptLong#error_message" do
it "returns nil if no error occurred" 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"
}
opts.error_message.should == nil
end

it "returns the error message of the last error that occurred" do
argv [] do
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
end
11 changes: 7 additions & 4 deletions spec/ruby/library/getoptlong/get_option_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require_relative '../../spec_helper'
require 'getoptlong'
require_relative 'shared/get'

describe "GetoptLong#get_option" do
it_behaves_like :getoptlong_get, :get_option
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
end
11 changes: 7 additions & 4 deletions spec/ruby/library/getoptlong/get_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require_relative '../../spec_helper'
require 'getoptlong'
require_relative 'shared/get'

describe "GetoptLong#get" do
it_behaves_like :getoptlong_get, :get
ruby_version_is ""..."3.4" do
require 'getoptlong'
require_relative 'shared/get'

describe "GetoptLong#get" do
it_behaves_like :getoptlong_get, :get
end
end
41 changes: 22 additions & 19 deletions spec/ruby/library/getoptlong/initialize_spec.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
require_relative '../../spec_helper'
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"] = ""
ruby_version_is ""..."3.4" do
require 'getoptlong'

opt = GetoptLong.new
opt.ordering.should == GetoptLong::REQUIRE_ORDER
ensure
ENV["POSIXLY_CORRECT"] = old_env_value
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
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
opt = GetoptLong.new
opt.ordering.should == GetoptLong::PERMUTE
ensure
ENV["POSIXLY_CORRECT"] = old_env_value
end
end
end
end
57 changes: 30 additions & 27 deletions spec/ruby/library/getoptlong/ordering_spec.rb
F438
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
require_relative '../../spec_helper'
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
ruby_version_is ""..."3.4" do
require 'getoptlong'

-> {
opts.ordering = GetoptLong::PERMUTE
}.should raise_error(ArgumentError)
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
end

it "raises an ArgumentError if given an invalid value" do
opts = GetoptLong.new
it "raises an ArgumentError if given an invalid value" do
opts = GetoptLong.new

-> {
opts.ordering = 12345
}.should raise_error(ArgumentError)
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'] = ""
1E80 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
opts = GetoptLong.new
opts.ordering = GetoptLong::PERMUTE
opts.ordering.should == GetoptLong::REQUIRE_ORDER
ensure
ENV['POSIXLY_CORRECT'] = old_env_value
end
end
end
end
151 changes: 77 additions & 74 deletions spec/ruby/library/getoptlong/set_options_spec.rb
< 10000 td class="blob-code blob-code-deletion js-file-line"> end
Original file line number Diff line number Diff line change
@@ -1,98 +1,101 @@
require_relative '../../spec_helper'
require 'getoptlong'

describe "GetoptLong#set_options" do
before :each do
@opts = GetoptLong.new
end
ruby_version_is ""..."3.4" do
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]
)
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
@opts.get.should == ["--size", "10k"]
@opts.get.should == ["--verbose", ""]
@opts.get.should == nil
end
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
@opts.get.should == ["-s", "10k"]
@opts.get.should == ["-v", ""]
@opts.get.should == nil
end
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)
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)
it "raises a RuntimeError if processing has already started" do
argv [] do
@opts.get
-> {
@opts.set_options()
}.should raise_error(RuntimeError)
end
end
end

it "raises an ArgumentError if no argument flag was given" do
argv [] do
-> {
@opts.set_options(["--size"])
}.should raise_error(ArgumentError)
it "raises an ArgumentError if no argument flag was given" do
argv [] do
-> {
@opts.set_options(["--size"])
}.should raise_error(ArgumentError)
end
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)
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
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)
-> {
@opts.set_options(
["--size", GetoptLong::NO_ARGUMENT],
["-s", "--size", GetoptLong::OPTIONAL_ARGUMENT])
}.should raise_error(ArgumentError)
end
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)
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
end
Loading
0