summaryrefslogtreecommitdiff
path: root/spec/ruby/library/getoptlong
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/getoptlong')
-rw-r--r--spec/ruby/library/getoptlong/each_option_spec.rb6
-rw-r--r--spec/ruby/library/getoptlong/each_spec.rb6
-rw-r--r--spec/ruby/library/getoptlong/error_message_spec.rb4
-rw-r--r--spec/ruby/library/getoptlong/get_option_spec.rb6
-rw-r--r--spec/ruby/library/getoptlong/get_spec.rb6
-rw-r--r--spec/ruby/library/getoptlong/initialize_spec.rb2
-rw-r--r--spec/ruby/library/getoptlong/ordering_spec.rb10
-rw-r--r--spec/ruby/library/getoptlong/set_options_spec.rb30
-rw-r--r--spec/ruby/library/getoptlong/shared/get.rb12
-rw-r--r--spec/ruby/library/getoptlong/terminate_spec.rb4
-rw-r--r--spec/ruby/library/getoptlong/terminated_spec.rb8
11 files changed, 46 insertions, 48 deletions
diff --git a/spec/ruby/library/getoptlong/each_option_spec.rb b/spec/ruby/library/getoptlong/each_option_spec.rb
index c58815bfa9..c6d82af86d 100644
--- a/spec/ruby/library/getoptlong/each_option_spec.rb
+++ b/spec/ruby/library/getoptlong/each_option_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'getoptlong'
-require File.expand_path('../shared/each', __FILE__)
+require_relative 'shared/each'
describe "GetoptLong#each_option" do
- it_behaves_like(:getoptlong_each, :each_option)
+ it_behaves_like :getoptlong_each, :each_option
end
diff --git a/spec/ruby/library/getoptlong/each_spec.rb b/spec/ruby/library/getoptlong/each_spec.rb
index d09f84a6db..d9022f02af 100644
--- a/spec/ruby/library/getoptlong/each_spec.rb
+++ b/spec/ruby/library/getoptlong/each_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'getoptlong'
-require File.expand_path('../shared/each', __FILE__)
+require_relative 'shared/each'
describe "GetoptLong#each" do
- it_behaves_like(:getoptlong_each, :each)
+ it_behaves_like :getoptlong_each, :each
end
diff --git a/spec/ruby/library/getoptlong/error_message_spec.rb b/spec/ruby/library/getoptlong/error_message_spec.rb
index 3f44f538c6..10435b1350 100644
--- a/spec/ruby/library/getoptlong/error_message_spec.rb
+++ b/spec/ruby/library/getoptlong/error_message_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'getoptlong'
describe "GetoptLong#error_message" do
@@ -14,7 +14,7 @@ describe "GetoptLong#error_message" do
opts.get
-> {
opts.ordering = GetoptLong::PERMUTE
- }.should raise_error(ArgumentError) { |e|
+ }.should.raise(ArgumentError) { |e|
e.message.should == "argument error"
opts.error_message.should == "argument error"
}
diff --git a/spec/ruby/library/getoptlong/get_option_spec.rb b/spec/ruby/library/getoptlong/get_option_spec.rb
index c56903e68e..3cb2044379 100644
--- a/spec/ruby/library/getoptlong/get_option_spec.rb
+++ b/spec/ruby/library/getoptlong/get_option_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'getoptlong'
-require File.expand_path('../shared/get', __FILE__)
+require_relative 'shared/get'
describe "GetoptLong#get_option" do
- it_behaves_like(:getoptlong_get, :get_option)
+ it_behaves_like :getoptlong_get, :get_option
end
diff --git a/spec/ruby/library/getoptlong/get_spec.rb b/spec/ruby/library/getoptlong/get_spec.rb
index ba1a1be6ad..a8ec586fc9 100644
--- a/spec/ruby/library/getoptlong/get_spec.rb
+++ b/spec/ruby/library/getoptlong/get_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'getoptlong'
-require File.expand_path('../shared/get', __FILE__)
+require_relative 'shared/get'
describe "GetoptLong#get" do
- it_behaves_like(:getoptlong_get, :get)
+ it_behaves_like :getoptlong_get, :get
end
diff --git a/spec/ruby/library/getoptlong/initialize_spec.rb b/spec/ruby/library/getoptlong/initialize_spec.rb
index 6ac46b8b5d..782edbd981 100644
--- a/spec/ruby/library/getoptlong/initialize_spec.rb
+++ b/spec/ruby/library/getoptlong/initialize_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'getoptlong'
describe "GetoptLong#initialize" do
diff --git a/spec/ruby/library/getoptlong/ordering_spec.rb b/spec/ruby/library/getoptlong/ordering_spec.rb
index e445de2255..60ce73afaa 100644
--- a/spec/ruby/library/getoptlong/ordering_spec.rb
+++ b/spec/ruby/library/getoptlong/ordering_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'getoptlong'
describe "GetoptLong#ordering=" do
@@ -9,18 +9,18 @@ describe "GetoptLong#ordering=" do
opts.quiet = true
opts.get
- lambda {
+ -> {
opts.ordering = GetoptLong::PERMUTE
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
end
it "raises an ArgumentError if given an invalid value" do
opts = GetoptLong.new
- lambda {
+ -> {
opts.ordering = 12345
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "does not allow changing ordering to PERMUTE if ENV['POSIXLY_CORRECT'] is set" do
diff --git a/spec/ruby/library/getoptlong/set_options_spec.rb b/spec/ruby/library/getoptlong/set_options_spec.rb
index 39d6991bf5..f60dcc87a3 100644
--- a/spec/ruby/library/getoptlong/set_options_spec.rb
+++ b/spec/ruby/library/getoptlong/set_options_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'getoptlong'
describe "GetoptLong#set_options" do
@@ -39,60 +39,60 @@ describe "GetoptLong#set_options" do
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)
+ }.should.raise(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)
+ }.should.raise(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)
+ }.should.raise(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)
+ }.should.raise(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)
+ }.should.raise(ArgumentError)
- lambda {
+ -> {
@opts.set_options(
["--size", GetoptLong::NO_ARGUMENT],
["-s", "--size", GetoptLong::OPTIONAL_ARGUMENT])
- }.should raise_error(ArgumentError)
+ }.should.raise(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)
+ }.should.raise(ArgumentError)
end
end
end
diff --git a/spec/ruby/library/getoptlong/shared/get.rb b/spec/ruby/library/getoptlong/shared/get.rb
index 91a0fbaacc..8d24c4c255 100644
--- a/spec/ruby/library/getoptlong/shared/get.rb
+++ b/spec/ruby/library/getoptlong/shared/get.rb
@@ -49,16 +49,14 @@ describe :getoptlong_get, shared: true do
it "raises a if an argument was required, but none given" do
argv [ "--size" ] do
- lambda { @opts.send(@method) }.should raise_error(GetoptLong::MissingArgument)
+ -> { @opts.send(@method) }.should.raise(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
+ # 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
diff --git a/spec/ruby/library/getoptlong/terminate_spec.rb b/spec/ruby/library/getoptlong/terminate_spec.rb
index 66d318527b..a12d1df2ef 100644
--- a/spec/ruby/library/getoptlong/terminate_spec.rb
+++ b/spec/ruby/library/getoptlong/terminate_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'getoptlong'
describe "GetoptLong#terminate" do
@@ -19,7 +19,7 @@ describe "GetoptLong#terminate" do
end
end
- it "returns self when option processsing is terminated" do
+ it "returns self when option processing is terminated" do
@opts.terminate.should == @opts
end
diff --git a/spec/ruby/library/getoptlong/terminated_spec.rb b/spec/ruby/library/getoptlong/terminated_spec.rb
index feaf2bc09e..6108a7f6e9 100644
--- a/spec/ruby/library/getoptlong/terminated_spec.rb
+++ b/spec/ruby/library/getoptlong/terminated_spec.rb
@@ -1,17 +1,17 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
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.should_not.terminated?
opts.get.should == ["--size", "10k"]
- opts.terminated?.should == false
+ opts.should_not.terminated?
opts.get.should == nil
- opts.terminated?.should == true
+ opts.should.terminated?
end
end
end