Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions library/optionparser/order_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'optparse'

describe "OptionParser#order" do
ruby_version_is '2.4' do
it "excepts `into` keyword argument and stores result in it" do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean accepts?

options = {}
parser = OptionParser.new do |opts|
opts.on("-v", "--[no-]verbose", "Run verbosely")
opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
end
parser.order %w[--verbose --require optparse], into: options

options.should == { verbose: true, require: "optparse" }
end
end
end

describe "OptionParser#order!" do
ruby_version_is '2.4' do
it "excepts `into` keyword argument and stores result in it" do
options = {}
parser = OptionParser.new do |opts|
opts.on("-v", "--[no-]verbose", "Run verbosely")
opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
end
parser.order! %w[--verbose --require optparse], into: options

options.should == { verbose: true, require: "optparse" }
end
end
end
32 changes: 32 additions & 0 deletions library/optionparser/parse_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'optparse'

describe "OptionParser#parse" do
ruby_version_is '2.4' do
it "excepts `into` keyword argument and stores result in it" do
options = {}
parser = OptionParser.new do |opts|
opts.on("-v", "--[no-]verbose", "Run verbosely")
opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
end
parser.parse %w[--verbose --require optparse], into: options

options.should == { verbose: true, require: "optparse" }
end
end
end

describe "OptionParser#parse!" do
ruby_version_is '2.4' do
it "excepts `into` keyword argument and stores result in it" do
options = {}
parser = OptionParser.new do |opts|
opts.on("-v", "--[no-]verbose", "Run verbosely")
opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
end
parser.parse! %w[--verbose --require optparse], into: options

options.should == { verbose: true, require: "optparse" }
end
end
end