From 0efe8bb66e6aa843d361998b7c3c5f78e92a0fc6 Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Mon, 16 Oct 2017 14:41:48 +0300 Subject: [PATCH 1/2] Add spec for OptionParser#order into argument --- library/optionparser/order_spec.rb | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 library/optionparser/order_spec.rb diff --git a/library/optionparser/order_spec.rb b/library/optionparser/order_spec.rb new file mode 100644 index 0000000000..415a033165 --- /dev/null +++ b/library/optionparser/order_spec.rb @@ -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 + 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 From 17383b909662ac04eef88809b044b04d1bf8c42b Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Mon, 16 Oct 2017 14:42:03 +0300 Subject: [PATCH 2/2] Add spec for OptionParser#parse into argument --- library/optionparser/parse_spec.rb | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 library/optionparser/parse_spec.rb diff --git a/library/optionparser/parse_spec.rb b/library/optionparser/parse_spec.rb new file mode 100644 index 0000000000..39fb2b4bae --- /dev/null +++ b/library/optionparser/parse_spec.rb @@ -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