# frozen_string_literal: true describe Pry do before do @str_output = StringIO.new end describe ".configure" do it "yields a block with Pry.config as its argument" do Pry.config.foo = nil Pry.configure do |config| config.foo = "bar" end expect(Pry.config.foo).to eq("bar") end end describe "Exotic object support" do # regression test for exotic object support it "Should not error when return value is a BasicObject instance" do ReplTester.start do expect(input('BasicObject.new')).to match(/^=> #')).to match(%r{/\n\n/}) end end describe "newline from an empty heredoc" do it "works" do expect(mock_pry('< { TOPLEVEL_BINDING.eval('self') } expect(Pry.binding_for(main.call).is_a?(Binding)).to eq true expect(Pry.binding_for(main.call)).to eq TOPLEVEL_BINDING expect(Pry.binding_for(main.call)).to eq Pry.binding_for(main.call) end end end end describe 'setting custom options' do it 'does not raise for unrecognized options' do expect { Pry.new(custom_option: 'custom value') }.to_not raise_error end it 'correctly handles the :quiet option (#1261)' do instance = Pry.new(quiet: true) expect(instance.quiet?).to eq true end end describe "a fresh instance" do it "should use `caller` as its backtrace" do location = "#{__FILE__}:#{__LINE__ + 1}"[1..-1] # omit leading . backtrace = Pry.new.backtrace expect(backtrace).not_to equal nil expect(backtrace.any? { |l| l.include?(location) }).to equal true end end end