Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 17th, 2012  |  syntax: None  |  size: 2.04 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     describe "with --ex NUM" do
  2.       before do
  3.         Pry.config.editor = proc do |file, line|
  4.           @__ex_file__ = file
  5.           @__ex_line__ = line
  6.           nil
  7.         end
  8.       end
  9.  
  10.       it 'should start editor on first level of backtrace when --ex used with no argument ' do
  11.         pry_instance = Pry.new(:input => StringIO.new("edit -n --ex"), :output => StringIO.new)
  12.         pry_instance.last_exception = MockPryException.new("a:1", "b:2", "c:3")
  13.         pry_instance.rep(self)
  14.         @__ex_file__.should == "a"
  15.         @__ex_line__.should == 1
  16.       end
  17.  
  18.       it 'should start editor on first level of backtrace when --ex 0 used ' do
  19.         pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 0"), :output => StringIO.new)
  20.         pry_instance.last_exception = MockPryException.new("a:1", "b:2", "c:3")
  21.         pry_instance.rep(self)
  22.         @__ex_file__.should == "a"
  23.         @__ex_line__.should == 1
  24.       end
  25.  
  26.       it 'should start editor on second level of backtrace when --ex 1 used' do
  27.         pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 1"), :output => StringIO.new)
  28.         pry_instance.last_exception = MockPryException.new("a:1", "b:2", "c:3")
  29.         pry_instance.rep(self)
  30.         @__ex_file__.should == "b"
  31.         @__ex_line__.should == 2
  32.       end
  33.  
  34.       it 'should start editor on third level of backtrace when --ex 2 used' do
  35.         pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 2"), :output => StringIO.new)
  36.         pry_instance.last_exception = MockPryException.new("a:1", "b:2", "c:3")
  37.         pry_instance.rep(self)
  38.         @__ex_file__.should == "c"
  39.         @__ex_line__.should == 3
  40.       end
  41.  
  42.       it 'should display error message when backtrace level is out of bounds (using --ex 4)' do
  43.         pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 4"), :output => str_output = StringIO.new)
  44.         pry_instance.last_exception = MockPryException.new("a:1", "b:2", "c:3")
  45.         pry_instance.rep(self)
  46.         str_output.string.should =~ /Exception has no associated file/
  47.       end
  48.     end