File: breakpoints_test.rb

package info (click to toggle)
ruby-pry-byebug 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 324 kB
  • sloc: ruby: 1,171; makefile: 4
file content (47 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

require "test_helper"

#
# Tests for pry-byebug breakpoints.
#
class BreakpointsTestGeneral < MiniTest::Spec
  #
  # Minimal dummy example class.
  #
  class Tester
    def self.class_method; end

    def instance_method; end
  end

  def breakpoints_class
    Pry::Byebug::Breakpoints
  end

  def test_add_file_raises_argument_error
    Pry.stub :eval_path, "something" do
      assert_raises(ArgumentError) { breakpoints_class.add_file("file", 1) }
    end
  end

  def test_add_method_adds_instance_method_breakpoint
    breakpoints_class.add_method "BreakpointsTest::Tester#instance_method"
    bp = Byebug.breakpoints.last

    assert_equal "BreakpointsTest::Tester", bp.source
    assert_equal "instance_method", bp.pos

    breakpoints_class.delete_all
  end

  def test_add_method_adds_class_method_breakpoint
    breakpoints_class.add_method "BreakpointsTest::Tester.class_method"
    bp = Byebug.breakpoints.last

    assert_equal "BreakpointsTest::Tester", bp.source
    assert_equal "class_method", bp.pos

    breakpoints_class.delete_all
  end
end