Sha256: 141df0b466a16a7a12aa02ebeca54200a7484f9edbed6490879b08fe3dc161c0

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require_relative 'test_helper'

class TestEdit < TestDsl::TestCase

  describe 'open configured editor' do
    temporary_change_hash ENV, 'EDITOR', 'editr'

    it 'must open current file in current line in configured editor' do
      Byebug::Edit.any_instance.expects(:system).
                                with("editr +2 #{fullpath('edit')}")
      enter 'edit'
      debug_file 'edit'
    end
  end

  describe 'open default editor' do
    temporary_change_hash ENV, 'EDITOR', nil

    it 'must call "ex" with current line and file if EDITOR env not set' do
      Byebug::Edit.any_instance.expects(:system).
                                with("ex +2 #{fullpath('edit')}")
      enter 'edit'
      debug_file 'edit'
    end
  end

  describe 'open configured editor specifying line and file' do
    temporary_change_hash ENV, 'EDITOR', 'editr'

    it 'must open specified line in specified file with configured editor' do
      Byebug::Edit.any_instance.expects(:system).
                                with("editr +3 #{fullpath('breakpoint')}")
      enter "edit #{fullpath('breakpoint')}:3"
      debug_file 'edit'
    end
  end

  it 'must show an error if there is no such line' do
    enter "edit #{fullpath('edit3')}:6"
    debug_file 'edit'
    check_error_includes "File \"#{fullpath('edit3')}\" is not readable."
  end

  it 'must show an error if there is incorrect syntax' do
    enter 'edit blabla'
    debug_file 'edit'
    check_error_includes 'Invalid file/line number specification: blabla'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
byebug-2.1.1 test/edit_test.rb
byebug-2.1.0 test/edit_test.rb
byebug-2.0.0 test/edit_test.rb