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

Added support for FAIL_PRY which will make pry raise a RuntimeError if it is called with that env variable present

This commit is contained in:
Ozer Chagatai 2016-03-31 15:32:37 -05:00
parent 90d127778f
commit fd1631f6de
2 changed files with 21 additions and 0 deletions

View file

@ -161,6 +161,9 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
# Pry.start(Object.new, :input => MyInput.new)
def self.start(target=nil, options={})
return if ENV['DISABLE_PRY']
if ENV['FAIL_PRY']
raise 'You have FAIL_PRY set to true, which results in Pry calls failing'
end
options = options.to_hash
if in_critical_section?

View file

@ -42,6 +42,24 @@ describe Pry do
end
end
describe 'FAIL_PRY' do
before do
ENV['FAIL_PRY'] = 'true'
end
after do
ENV.delete 'FAIL_PRY'
end
it 'should raise an error for binding.pry' do
expect{binding.pry}.to raise_error(RuntimeError)
end
it 'should raise an error for Pry.start' do
expect{Pry.start}.to raise_error(RuntimeError)
end
end
describe "Pry.critical_section" do
it "should prevent Pry being called" do
output = StringIO.new