1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Allow ARGV to be mutated during option parsing

Reverts
f4d1f448bb
and passes ARGV rather than ARGV.dup to Pry::CLI.parse_options
by default.

@banister wasn't sure why that change was made in the first place, so
there's a wee bit of risk here. But all tests continue to pass,
and everything looks fine. If something does break, let's make sure
to add tests for it this time around! <3 <3 <3

Resolves https://github.com/pry/pry/issues/968, where
the '-r' argument was being passed through and throwing an error
when the file being required began with #puts
This commit is contained in:
Danielle Sucher 2013-09-05 17:11:29 -07:00
parent 395adc1c36
commit b3cdfc2bf5
2 changed files with 11 additions and 1 deletions

View file

@ -55,7 +55,7 @@ class Pry
self.option_processors = nil
end
def parse_options(args=ARGV.dup)
def parse_options(args=ARGV)
unless options
raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options."
end

View file

@ -9,6 +9,16 @@ describe Pry::Hooks do
it 'should raise if no options defined' do
lambda { Pry::CLI.parse_options(["--nothing"]) }.should.raise Pry::CLI::NoOptionsError
end
it "should remove args from ARGV by default" do
ARGV << '-v'
Pry::CLI.add_options do
on :v, "Display the Pry version" do
# irrelevant
end
end.parse_options
ARGV.include?('-v').should == false
end
end
describe "adding options" do