summaryrefslogtreecommitdiff
path: root/spec/exception_whitelist_spec.rb
blob: d12fa1a0e8f3765be8bec3a64cbb24926afe199b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require_relative 'helper'

describe "Pry.config.exception_whitelist" do
  before do
    @str_output = StringIO.new
  end

  it 'should rescue all exceptions NOT specified on whitelist' do
    expect(Pry.config.exception_whitelist.include?(NameError)).to eq false
    expect { Pry.start(self, :input => StringIO.new("raise NameError\nexit"), :output => @str_output) }.not_to raise_error
  end

  it 'should NOT rescue exceptions specified on whitelist' do
    old_whitelist = Pry.config.exception_whitelist
    Pry.config.exception_whitelist = [NameError]
    expect { Pry.start(self, :input => StringIO.new("raise NameError"), :output => @str_output) }.to raise_error NameError
    Pry.config.exception_whitelist = old_whitelist
  end
end