mirror of
				https://github.com/pry/pry.git
				synced 2022-11-09 12:35:05 -05:00 
			
		
		
		
	PryTestHelpers methods are now module_functions, included into Bacon::Context by default
This commit is contained in:
		
							parent
							
								
									64f402e216
								
							
						
					
					
						commit
						9a279461c1
					
				
					 13 changed files with 72 additions and 65 deletions
				
			
		| 
						 | 
				
			
			@ -1,6 +1,10 @@
 | 
			
		|||
# Colorize output (based on greeneggs (c) 2009 Michael Fleet)
 | 
			
		||||
# TODO: Make own gem (assigned to rking)
 | 
			
		||||
module Bacon
 | 
			
		||||
  class Context
 | 
			
		||||
    include PryTestHelpers
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  COLORS    = {'F' => 31, 'E' => 35, 'M' => 33, '.' => 32}
 | 
			
		||||
  USE_COLOR = !(ENV['NO_PRY_COLORED_BACON'] == 'true') && Pry::Helpers::BaseHelpers.use_ansi_codes?
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,10 +2,6 @@ require 'pry'
 | 
			
		|||
 | 
			
		||||
puts "Ruby v#{RUBY_VERSION} (#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"}), Pry v#{Pry::VERSION}, method_source v#{MethodSource::VERSION}, CodeRay v#{CodeRay::VERSION}, Slop v#{Slop::VERSION}"
 | 
			
		||||
 | 
			
		||||
if defined?(Bacon)
 | 
			
		||||
  require File.join(File.expand_path(File.dirname(__FILE__)), 'bacon_helper')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# in case the tests call reset_defaults, ensure we reset them to
 | 
			
		||||
# amended (test friendly) values
 | 
			
		||||
class << Pry
 | 
			
		||||
| 
						 | 
				
			
			@ -34,15 +30,18 @@ def Pad.clear
 | 
			
		|||
end
 | 
			
		||||
 | 
			
		||||
module PryTestHelpers
 | 
			
		||||
 | 
			
		||||
  module_function
 | 
			
		||||
 | 
			
		||||
  # inject a variable into a binding
 | 
			
		||||
  def self.inject_var(name, value, b)
 | 
			
		||||
  def inject_var(name, value, b)
 | 
			
		||||
    Thread.current[:__pry_local__] = value
 | 
			
		||||
    b.eval("#{name} = Thread.current[:__pry_local__]")
 | 
			
		||||
  ensure
 | 
			
		||||
    Thread.current[:__pry_local__] = nil
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self.constant_scope(*names)
 | 
			
		||||
  def constant_scope(*names)
 | 
			
		||||
    names.each do |name|
 | 
			
		||||
      Object.remove_const name if Object.const_defined?(name)
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -54,13 +53,13 @@ module PryTestHelpers
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self.mri18_and_no_real_source_location?
 | 
			
		||||
  def mri18_and_no_real_source_location?
 | 
			
		||||
    Pry::Helpers::BaseHelpers.mri_18? && !(Method.instance_method(:source_location).owner == Method)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Open a temp file and yield it to the block, closing it after
 | 
			
		||||
  # @return [String] The path of the temp file
 | 
			
		||||
  def self.temp_file(ext='.rb')
 | 
			
		||||
  def temp_file(ext='.rb')
 | 
			
		||||
    file = Tempfile.new(['pry', ext])
 | 
			
		||||
    yield file
 | 
			
		||||
  ensure
 | 
			
		||||
| 
						 | 
				
			
			@ -68,7 +67,7 @@ module PryTestHelpers
 | 
			
		|||
    File.unlink("#{file.path}c") if File.exists?("#{file.path}c") # rbx
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self.unindent(*args)
 | 
			
		||||
  def unindent(*args)
 | 
			
		||||
    Pry::Helpers::CommandHelpers.unindent(*args)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -204,3 +203,7 @@ class PryTester
 | 
			
		|||
    @pry.output = @out
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if defined?(Bacon)
 | 
			
		||||
  require File.join(File.expand_path(File.dirname(__FILE__)), 'bacon_helper')
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,19 +12,19 @@ describe Pry::Code do
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    should 'default to Ruby' do
 | 
			
		||||
      PryTestHelpers.temp_file('') do |f|
 | 
			
		||||
      temp_file('') do |f|
 | 
			
		||||
        Pry::Code.from_file(f.path).code_type.should == :ruby
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should 'check the extension' do
 | 
			
		||||
      PryTestHelpers.temp_file('.c') do |f|
 | 
			
		||||
      temp_file('.c') do |f|
 | 
			
		||||
        Pry::Code.from_file(f.path).code_type.should == :c
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should 'use the provided extension' do
 | 
			
		||||
      PryTestHelpers.temp_file('.c') do |f|
 | 
			
		||||
      temp_file('.c') do |f|
 | 
			
		||||
        Pry::Code.from_file(f.path, :ruby).code_type.should == :ruby
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -719,7 +719,7 @@ describe "Pry::Command" do
 | 
			
		|||
      pry_eval("my---test").should =~ /my-testmy-test/
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if !PryTestHelpers.mri18_and_no_real_source_location?
 | 
			
		||||
    if !mri18_and_no_real_source_location?
 | 
			
		||||
      it "should show the source of the process method" do
 | 
			
		||||
        pry_eval("show-source my-test").should =~ /output.puts command_name/
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,21 +6,21 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should amend the last line of input when no line number specified' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
    STR
 | 
			
		||||
 | 
			
		||||
    @t.process_command 'amend-line   puts :blah', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :blah
 | 
			
		||||
    STR
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should amend the specified line of input when line number given' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line 1 def goodbye', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def goodbye
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should amend the first line of input when 0 given as line number' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +44,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line 0 def goodbye', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def goodbye
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +52,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should amend a specified line when negative number given' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +60,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line -1   puts :bink', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bink
 | 
			
		||||
| 
						 | 
				
			
			@ -68,7 +68,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line -2   puts :bink', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bink
 | 
			
		||||
        puts :bink
 | 
			
		||||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should amend a range of lines of input when negative numbers given' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +85,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line -3..-2   puts :bink', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bink
 | 
			
		||||
        puts :boat
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +93,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should correctly amend the specified line with interpolated text' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +101,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line   puts "#{goodbye}"', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-'STR')
 | 
			
		||||
    eval_str.should == unindent(<<-'STR')
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts "#{goodbye}"
 | 
			
		||||
| 
						 | 
				
			
			@ -122,7 +122,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should correctly amend the specified range of lines' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -131,7 +131,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line 2..3   puts :bong', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bong
 | 
			
		||||
        puts :heart
 | 
			
		||||
| 
						 | 
				
			
			@ -139,7 +139,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should correctly delete a specific line using the ! for content' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -149,7 +149,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line 3 !', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :boast
 | 
			
		||||
| 
						 | 
				
			
			@ -158,7 +158,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should correctly delete a range of lines using the ! for content' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -168,14 +168,14 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line 2..4 !', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :heart
 | 
			
		||||
    STR
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should correctly delete the previous line using the ! for content' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -185,7 +185,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line !', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -194,7 +194,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should amend the specified range of lines, with numbers < 0 in range' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -204,7 +204,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line 2..-2   puts :bong', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bong
 | 
			
		||||
        puts :heart
 | 
			
		||||
| 
						 | 
				
			
			@ -212,7 +212,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should correctly insert a line before a specified line using >' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +220,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line 2 >  puts :inserted', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :inserted
 | 
			
		||||
        puts :bing
 | 
			
		||||
| 
						 | 
				
			
			@ -229,7 +229,7 @@ describe "amend-line" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should ignore second value of range with > syntax' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
        puts :bang
 | 
			
		||||
| 
						 | 
				
			
			@ -237,7 +237,7 @@ describe "amend-line" do
 | 
			
		|||
 | 
			
		||||
    @t.process_command 'amend-line 2..21 >  puts :inserted', eval_str
 | 
			
		||||
 | 
			
		||||
    eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str.should == unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :inserted
 | 
			
		||||
        puts :bing
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ describe "!" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should correctly clear the input buffer ' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
    STR
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@ describe "cat" do
 | 
			
		|||
 | 
			
		||||
  describe "with --in" do
 | 
			
		||||
    it 'should display the last few expressions with indices' do
 | 
			
		||||
      @t.eval('10', '20', 'cat --in').should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
      @t.eval('10', '20', 'cat --in').should == unindent(<<-STR)
 | 
			
		||||
        1:
 | 
			
		||||
          10
 | 
			
		||||
        2:
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +52,7 @@ describe "cat" do
 | 
			
		|||
      @t.insert_nil_input # normally happens when a command is executed
 | 
			
		||||
      @t.eval ':hello'
 | 
			
		||||
 | 
			
		||||
      @t.eval('cat --in 1..3').should == PryTestHelpers.unindent(<<-EOS)
 | 
			
		||||
      @t.eval('cat --in 1..3').should == unindent(<<-EOS)
 | 
			
		||||
        1:
 | 
			
		||||
          10
 | 
			
		||||
        3:
 | 
			
		||||
| 
						 | 
				
			
			@ -75,7 +75,7 @@ describe "cat" do
 | 
			
		|||
 | 
			
		||||
    if !Pry::Helpers::BaseHelpers.rbx?
 | 
			
		||||
      it 'cat --ex should display repl code that generated exception' do
 | 
			
		||||
        @t.eval PryTestHelpers.unindent(<<-EOS)
 | 
			
		||||
        @t.eval unindent(<<-EOS)
 | 
			
		||||
          begin
 | 
			
		||||
            this raises error
 | 
			
		||||
          rescue => e
 | 
			
		||||
| 
						 | 
				
			
			@ -98,7 +98,7 @@ describe "cat" do
 | 
			
		|||
 | 
			
		||||
  describe "with --ex N" do
 | 
			
		||||
    it 'should cat first level of backtrace when --ex used with no argument ' do
 | 
			
		||||
      PryTestHelpers.temp_file do |f|
 | 
			
		||||
      temp_file do |f|
 | 
			
		||||
        f << "bt number 1"
 | 
			
		||||
        f.flush
 | 
			
		||||
        @t.last_exception = mock_exception("#{f.path}:1", 'x', 'x')
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ describe "cat" do
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    it 'should cat first level of backtrace when --ex 0 used ' do
 | 
			
		||||
      PryTestHelpers.temp_file do |f|
 | 
			
		||||
      temp_file do |f|
 | 
			
		||||
        f << "bt number 1"
 | 
			
		||||
        f.flush
 | 
			
		||||
        @t.last_exception = mock_exception("#{f.path}:1", 'x', 'x')
 | 
			
		||||
| 
						 | 
				
			
			@ -116,7 +116,7 @@ describe "cat" do
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    it 'should cat second level of backtrace when --ex 1 used ' do
 | 
			
		||||
      PryTestHelpers.temp_file do |f|
 | 
			
		||||
      temp_file do |f|
 | 
			
		||||
        f << "bt number 2"
 | 
			
		||||
        f.flush
 | 
			
		||||
        @t.last_exception = mock_exception('x', "#{f.path}:1", 'x')
 | 
			
		||||
| 
						 | 
				
			
			@ -125,7 +125,7 @@ describe "cat" do
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    it 'should cat third level of backtrace when --ex 2 used' do
 | 
			
		||||
      PryTestHelpers.temp_file do |f|
 | 
			
		||||
      temp_file do |f|
 | 
			
		||||
        f << "bt number 3"
 | 
			
		||||
        f.flush
 | 
			
		||||
        @t.last_exception = mock_exception('x', 'x', "#{f.path}:1")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,7 +49,7 @@ describe "edit" do
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      it "should reload the file if it is a ruby file" do
 | 
			
		||||
        PryTestHelpers.temp_file do |tf|
 | 
			
		||||
        temp_file do |tf|
 | 
			
		||||
          counter = Pad.counter
 | 
			
		||||
          path    = tf.path
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +60,7 @@ describe "edit" do
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      it "should not reload the file if it is not a ruby file" do
 | 
			
		||||
        PryTestHelpers.temp_file('.py') do |tf|
 | 
			
		||||
        temp_file('.py') do |tf|
 | 
			
		||||
          counter = Pad.counter
 | 
			
		||||
          path    = tf.path
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -71,7 +71,7 @@ describe "edit" do
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      it "should not reload a ruby file if -n is given" do
 | 
			
		||||
        PryTestHelpers.temp_file do |tf|
 | 
			
		||||
        temp_file do |tf|
 | 
			
		||||
          counter = Pad.counter
 | 
			
		||||
          path    = tf.path
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ describe "edit" do
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      it "should reload a non-ruby file if -r is given" do
 | 
			
		||||
        PryTestHelpers.temp_file('.pryrc') do |tf|
 | 
			
		||||
        temp_file('.pryrc') do |tf|
 | 
			
		||||
          counter = Pad.counter
 | 
			
		||||
          path    = tf.path
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -81,7 +81,7 @@ describe "play" do
 | 
			
		|||
 | 
			
		||||
      pry_tester(@o).process_command 'play -d test_method', @eval_str
 | 
			
		||||
 | 
			
		||||
      @eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
      @eval_str.should == unindent(<<-STR)
 | 
			
		||||
        @v = 10
 | 
			
		||||
        @y = 20
 | 
			
		||||
      STR
 | 
			
		||||
| 
						 | 
				
			
			@ -98,7 +98,7 @@ describe "play" do
 | 
			
		|||
 | 
			
		||||
      pry_tester(@o).process_command 'play -d test_method --lines 2..3', @eval_str
 | 
			
		||||
 | 
			
		||||
      @eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
      @eval_str.should == unindent(<<-STR)
 | 
			
		||||
        @v = 10
 | 
			
		||||
        @y = 20
 | 
			
		||||
      STR
 | 
			
		||||
| 
						 | 
				
			
			@ -110,13 +110,13 @@ describe "play" do
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    it 'should APPEND to the input buffer when playing a line with play -m, not replace it' do
 | 
			
		||||
      @eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
      @eval_str = unindent(<<-STR)
 | 
			
		||||
        def another_test_method
 | 
			
		||||
      STR
 | 
			
		||||
 | 
			
		||||
      pry_tester(@o).process_command 'play -m test_method --lines 2', @eval_str
 | 
			
		||||
 | 
			
		||||
      @eval_str.should == PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
      @eval_str.should == unindent(<<-STR)
 | 
			
		||||
        def another_test_method
 | 
			
		||||
          :test_method_content
 | 
			
		||||
      STR
 | 
			
		||||
| 
						 | 
				
			
			@ -132,7 +132,7 @@ describe "play" do
 | 
			
		|||
 | 
			
		||||
      pry_tester(@o).process_command 'play -m test_method --lines 3..4', @eval_str
 | 
			
		||||
 | 
			
		||||
      @eval_str.should == PryTestHelpers.unindent(<<-STR, 2)
 | 
			
		||||
      @eval_str.should == unindent(<<-STR, 2)
 | 
			
		||||
        @var1 = 20
 | 
			
		||||
        @var2 = 30
 | 
			
		||||
      STR
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ describe "save-file" do
 | 
			
		|||
 | 
			
		||||
  describe "-f" do
 | 
			
		||||
    it 'should save a file to a file' do
 | 
			
		||||
      PryTestHelpers.temp_file do |f|
 | 
			
		||||
      temp_file do |f|
 | 
			
		||||
        path = f.path
 | 
			
		||||
        f.puts ":cute_horse"
 | 
			
		||||
        f.flush
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -209,7 +209,7 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      it 'should lookup module name with respect to current context' do
 | 
			
		||||
        PryTestHelpers.constant_scope(:AlphaClass, :BetaClass) do
 | 
			
		||||
        constant_scope(:AlphaClass, :BetaClass) do
 | 
			
		||||
          # top-level beta
 | 
			
		||||
          class BetaClass
 | 
			
		||||
            def alpha
 | 
			
		||||
| 
						 | 
				
			
			@ -229,7 +229,7 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      it 'should look up nested modules' do
 | 
			
		||||
        PryTestHelpers.constant_scope(:AlphaClass) do
 | 
			
		||||
        constant_scope(:AlphaClass) do
 | 
			
		||||
          class AlphaClass
 | 
			
		||||
            # nested beta
 | 
			
		||||
            class BetaClass
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ describe "show-input" do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  it 'should correctly show the current lines in the input buffer' do
 | 
			
		||||
    eval_str = PryTestHelpers.unindent(<<-STR)
 | 
			
		||||
    eval_str = unindent(<<-STR)
 | 
			
		||||
      def hello
 | 
			
		||||
        puts :bing
 | 
			
		||||
    STR
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -201,7 +201,7 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
 | 
			
		|||
 | 
			
		||||
      describe "on variables that shadow methods" do
 | 
			
		||||
        before do
 | 
			
		||||
          @t = pry_tester.eval PryTestHelpers.unindent(<<-EOS)
 | 
			
		||||
          @t = pry_tester.eval unindent(<<-EOS)
 | 
			
		||||
            class ::TestHost
 | 
			
		||||
              def hello
 | 
			
		||||
                hello = proc { ' smile ' }
 | 
			
		||||
| 
						 | 
				
			
			@ -339,7 +339,7 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
 | 
			
		|||
 | 
			
		||||
      if !Pry::Helpers::BaseHelpers.mri_18?
 | 
			
		||||
        before do
 | 
			
		||||
          pry_eval PryTestHelpers.unindent(<<-EOS)
 | 
			
		||||
          pry_eval unindent(<<-EOS)
 | 
			
		||||
            class Dog
 | 
			
		||||
              def woof
 | 
			
		||||
              end
 | 
			
		||||
| 
						 | 
				
			
			@ -369,7 +369,7 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
 | 
			
		|||
 | 
			
		||||
        it 'should lookup module name with respect to current context' do
 | 
			
		||||
 | 
			
		||||
        PryTestHelpers.constant_scope(:AlphaClass, :BetaClass) do
 | 
			
		||||
        constant_scope(:AlphaClass, :BetaClass) do
 | 
			
		||||
          class BetaClass
 | 
			
		||||
            def alpha
 | 
			
		||||
            end
 | 
			
		||||
| 
						 | 
				
			
			@ -387,7 +387,7 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      it 'should lookup nested modules' do
 | 
			
		||||
        PryTestHelpers.constant_scope(:AlphaClass) do
 | 
			
		||||
        constant_scope(:AlphaClass) do
 | 
			
		||||
          class AlphaClass
 | 
			
		||||
            class BetaClass
 | 
			
		||||
              def beta
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue