byebug 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/.gitignore +4 -0
  2. data/.travis.yml +0 -5
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile +1 -1
  5. data/LICENSE +23 -20
  6. data/byebug.gemspec +5 -5
  7. data/ext/byebug/breakpoint.c +102 -134
  8. data/ext/byebug/byebug.c +110 -64
  9. data/ext/byebug/byebug.h +2 -3
  10. data/ext/byebug/context.c +72 -39
  11. data/lib/byebug.rb +34 -38
  12. data/lib/byebug/command.rb +19 -24
  13. data/lib/byebug/commands/breakpoints.rb +11 -12
  14. data/lib/byebug/commands/catchpoint.rb +1 -1
  15. data/lib/byebug/commands/control.rb +2 -4
  16. data/lib/byebug/commands/finish.rb +1 -1
  17. data/lib/byebug/commands/frame.rb +15 -17
  18. data/lib/byebug/commands/info.rb +29 -28
  19. data/lib/byebug/commands/irb.rb +23 -21
  20. data/lib/byebug/commands/method.rb +4 -4
  21. data/lib/byebug/commands/reload.rb +8 -6
  22. data/lib/byebug/commands/set.rb +27 -23
  23. data/lib/byebug/commands/show.rb +6 -4
  24. data/lib/byebug/commands/stepping.rb +2 -2
  25. data/lib/byebug/commands/threads.rb +10 -10
  26. data/lib/byebug/commands/trace.rb +13 -14
  27. data/lib/byebug/commands/variables.rb +14 -12
  28. data/lib/byebug/context.rb +2 -15
  29. data/lib/byebug/interface.rb +5 -0
  30. data/lib/byebug/processor.rb +59 -64
  31. data/lib/byebug/version.rb +2 -1
  32. data/old_doc/Makefile +20 -0
  33. data/{man/rdebug.1 → old_doc/byebug.1} +5 -5
  34. data/old_doc/byebug.html +6178 -0
  35. data/old_doc/byebug.texi +3775 -0
  36. data/{doc → old_doc}/hanoi.rb +0 -0
  37. data/{doc → old_doc}/primes.rb +0 -0
  38. data/{doc → old_doc}/test-tri2.rb +0 -0
  39. data/{doc → old_doc}/tri3.rb +0 -0
  40. data/{doc → old_doc}/triangle.rb +0 -0
  41. data/test/breakpoints_test.rb +96 -60
  42. data/test/conditions_test.rb +15 -12
  43. data/test/examples/info.rb +5 -5
  44. data/test/examples/stepping.rb +1 -1
  45. data/test/frame_test.rb +40 -39
  46. data/test/info_test.rb +105 -96
  47. data/test/irb_test.rb +66 -61
  48. data/test/jump_test.rb +18 -9
  49. data/test/list_test.rb +114 -107
  50. data/test/restart_test.rb +51 -58
  51. data/test/save_test.rb +8 -7
  52. data/test/set_test.rb +8 -11
  53. data/test/show_test.rb +3 -5
  54. data/test/stepping_test.rb +43 -53
  55. data/test/support/context.rb +1 -0
  56. data/test/support/processor.rb +10 -4
  57. data/test/support/test_dsl.rb +46 -18
  58. data/test/support/test_interface.rb +8 -5
  59. data/test/test_helper.rb +2 -2
  60. data/test/trace_test.rb +123 -124
  61. metadata +39 -17
  62. data/AUTHORS +0 -10
  63. data/doc/rdebug-emacs.texi +0 -1030
@@ -1,6 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe "Restart Command" do
3
+ describe "Restart Command (test setup)" do
4
4
  include TestDsl
5
5
 
6
6
  def must_restart
@@ -8,47 +8,50 @@ describe "Restart Command" do
8
8
  Byebug::RestartCommand.any_instance.expects(:exec)
9
9
  end
10
10
 
11
- describe "Restart Command 2" do
11
+ describe "Restart Command" do
12
+
13
+ before do
14
+ @old_consts = {}
15
+ @old_hashes = {}
16
+ set_tmp_const(Byebug,
17
+ "INITIAL_DIR", Pathname.new(__FILE__ + "/../..").realpath.to_s)
18
+ set_tmp_const(Byebug,
19
+ "PROG_SCRIPT", Pathname.new(fullpath('restart')).
20
+ relative_path_from(Pathname.new(Byebug::INITIAL_DIR)).
21
+ cleanpath.to_s)
22
+ set_tmp_const(Byebug, "RDEBUG_SCRIPT", 'rdebug_script')
23
+ set_tmp_hash(Byebug::Command.settings, :argv, ['argv'])
24
+ Byebug::RestartCommand.any_instance.stubs(:exec).
25
+ with("#{Byebug::RDEBUG_SCRIPT} argv")
26
+ end
12
27
 
13
- temporary_set_const(Byebug, "INITIAL_DIR",
14
- Pathname.new(__FILE__ + "/../..").realpath.to_s)
15
- temporary_set_const(Byebug, "PROG_SCRIPT",
16
- Pathname.new(fullpath('restart')).realpath.to_s)
17
- temporary_set_const(Byebug, "RDEBUG_SCRIPT", 'rdebug_script')
18
- temporary_change_hash_value(Byebug::Command.settings, :argv, 'argv')
19
- Byebug::RestartCommand.any_instance.stubs(:exec).
20
- with("#{Byebug::RDEBUG_SCRIPT} argv")
28
+ after do
29
+ restore_tmp_const(Byebug, "INITIAL_DIR")
30
+ restore_tmp_const(Byebug, "PROG_SCRIPT")
31
+ restore_tmp_const(Byebug, "RDEBUG_SCRIPT")
32
+ restore_tmp_hash(Byebug::Command.settings, :argv)
33
+ end
21
34
 
22
35
  it "must be restarted with arguments" do
23
36
  Byebug::RestartCommand.any_instance.expects(:exec).
24
- with("#{Byebug::RDEBUG_SCRIPT} test/examples/restart.rb 1 2 3")
37
+ with("#{Byebug::RDEBUG_SCRIPT} test/examples/restart.rb 1 2 3")
25
38
  enter 'restart 1 2 3'
26
39
  debug_file('restart')
27
40
  end
28
41
 
29
42
  it "must be restarted without arguments" do
30
- temporary_set_const(Byebug, "RDEBUG_SCRIPT", 'rdebug_script') do
31
- temporary_set_const(Byebug, "PROG_SCRIPT",
32
- Pathname.new(fullpath('restart')).
33
- relative_path_from(Pathname.new(__FILE__ + "/../..")).
34
- cleanpath.to_s) do
35
- temporary_change_hash_value(Byebug::Command.settings, :argv, ['argv']) do
36
- Byebug::RestartCommand.
37
- any_instance.expects(:exec).with("#{Byebug::RDEBUG_SCRIPT} argv")
38
- enter 'restart'
39
- debug_file('restart')
40
- end
41
- end
42
- end
43
+ Byebug::RestartCommand.
44
+ any_instance.expects(:exec).with("#{Byebug::RDEBUG_SCRIPT} argv")
45
+ enter 'restart'
46
+ debug_file('restart')
43
47
  end
44
48
 
45
49
  it "must specify arguments by 'set' command" do
46
50
  temporary_change_hash_value(Byebug::Command.settings, :argv, []) do
47
- temporary_set_const(Byebug, "RDEBUG_SCRIPT", 'rdebug_script') do
48
- Byebug::RestartCommand.any_instance.expects(:exec).with("#{Byebug::RDEBUG_SCRIPT} 1 2 3")
49
- enter 'set args 1 2 3', 'restart'
50
- debug_file('restart')
51
- end
51
+ Byebug::RestartCommand.any_instance.expects(:exec).
52
+ with("#{Byebug::RDEBUG_SCRIPT} 1 2 3")
53
+ enter 'set args 1 2 3', 'restart'
54
+ debug_file('restart')
52
55
  end
53
56
  end
54
57
 
@@ -56,40 +59,27 @@ describe "Restart Command" do
56
59
  before { enter 'restart' }
57
60
 
58
61
  describe "reexecing" do
59
-
60
- it "must restart" do
62
+ it "must restart and show a message about reexecing" do
61
63
  must_restart
62
64
  debug_file('restart')
63
- end
64
-
65
- it "must show a message about reexecing" do
66
- temporary_set_const(Byebug, "PROG_SCRIPT",
67
- Pathname.new(fullpath('restart')).
68
- relative_path_from(Pathname.new(__FILE__ + "/../..")).
69
- cleanpath.to_s) do
70
- temporary_change_hash_value(Byebug::Command.settings, :argv,
71
- [Byebug::PROG_SCRIPT]) do
72
- temporary_set_const(Byebug, "RDEBUG_SCRIPT",
73
- Pathname.new(__FILE__ + "/../../bin/byebug").realpath.to_s) do
74
- debug_file('restart')
75
- check_output_includes "Re exec'ing:\n\t#{Byebug::RDEBUG_SCRIPT}"
76
- end
77
- end
78
- end
65
+ check_output_includes "Re exec'ing:\n\t#{Byebug::RDEBUG_SCRIPT}" \
66
+ " argv"
79
67
  end
80
68
  end
81
69
 
82
70
  describe "no script is specified and don't use $0" do
83
71
  before do
84
- force_set_const(Byebug, "DEFAULT_START_SETTINGS", init: false, post_mortem: false, tracing: nil)
72
+ set_tmp_const(Byebug, "PROG_SCRIPT", :__undefined__)
73
+ set_tmp_const(Byebug, "DEFAULT_START_SETTINGS",
74
+ init: false, post_mortem: false, tracing: nil)
85
75
  end
86
-
87
- it "must not restart" do
88
- must_restart.never
89
- debug_file('restart')
76
+ after do
77
+ restore_tmp_const(Byebug, "PROG_SCRIPT")
78
+ restore_tmp_const(Byebug, "DEFAULT_START_SETTINGS")
90
79
  end
91
80
 
92
- it "must show an error message" do
81
+ it "must not restart and show error messages instead" do
82
+ must_restart.never
93
83
  debug_file('restart')
94
84
  check_output_includes "Don't know name of debugged program", interface.error_queue
95
85
  end
@@ -119,6 +109,9 @@ describe "Restart Command" do
119
109
 
120
110
  describe "byebug runner script is not specified" do
121
111
 
112
+ before { set_tmp_const(Byebug, "RDEBUG_SCRIPT", :__undefined__) }
113
+ after { restore_tmp_const(Byebug, "RDEBUG_SCRIPT") }
114
+
122
115
  it "must restart anyway" do
123
116
  must_restart
124
117
  debug_file('restart')
@@ -131,8 +124,8 @@ describe "Restart Command" do
131
124
 
132
125
  it "must show a warning message when prog script is not executable" do
133
126
  debug_file('restart')
134
- check_output_includes "Ruby program #{Byebug::PROG_SCRIPT} doesn't seem to be executable..."
135
- check_output_includes "We'll add a call to Ruby."
127
+ check_output_includes "Ruby program #{Byebug::PROG_SCRIPT} not " \
128
+ "executable... We'll add a call to Ruby."
136
129
  end
137
130
  end
138
131
 
@@ -154,9 +147,9 @@ describe "Restart Command" do
154
147
  describe "Post Mortem" do
155
148
  it "must work in post-mortem mode" do
156
149
  skip("No post morten mode for now")
157
- #must_restart
158
- #enter 'cont', 'restart'
159
- #debug_file 'post_mortem'
150
+ must_restart
151
+ enter 'cont', 'restart'
152
+ debug_file 'post_mortem'
160
153
  end
161
154
  end
162
155
 
@@ -2,14 +2,14 @@ require_relative 'test_helper'
2
2
 
3
3
  describe "Save Command" do
4
4
  include TestDsl
5
- let(:file_name) { 'save_output.txt' }
6
5
 
7
6
  describe "successful saving" do
7
+ let(:file_name) { 'save_output.txt' }
8
8
  let(:file_contents) { File.read(file_name) }
9
9
  before do
10
- enter 'break 2', 'break 3 if true', 'catch NoMethodError', 'display 2 + 3', 'display 5 + 6',
11
- 'set autoeval', 'set autolist',
12
- "save #{file_name}"
10
+ enter 'break 2', 'break 3 if true', 'catch NoMethodError',
11
+ 'display 2 + 3', 'display 5 + 6', 'set autoeval', 'set autolist',
12
+ "save #{file_name}"
13
13
  debug_file 'save'
14
14
  end
15
15
  after do
@@ -79,13 +79,14 @@ describe "Save Command" do
79
79
  end
80
80
 
81
81
  describe "Post Mortem" do
82
+ let(:file_name) { 'save_output.txt' }
82
83
  #let(:file_contents) { File.read(file_name) }
83
84
  #after { FileUtils.rm(file_name) }
84
85
  it "must work in post-mortem mode" do
85
86
  skip("No post morten mode for now")
86
- #enter 'cont', "save #{file_name}"
87
- #debug_file 'post_mortem'
88
- #file_contents.must_include "set autoirb off"
87
+ enter 'cont', "save #{file_name}"
88
+ debug_file 'post_mortem'
89
+ file_contents.must_include "set autoirb off"
89
90
  end
90
91
  end
91
92
 
@@ -64,13 +64,10 @@ describe "Set Command" do
64
64
  end
65
65
 
66
66
  describe "byebugtesting" do
67
- temporary_change_hash_value(Byebug::Command.settings, :byebugtesting, false)
68
- before { $rdebug_state = nil }
69
- after { $rdebug_state = nil }
70
-
71
- it "must set $rdebug_context if byebugsetting is on" do
67
+ it "must set $byebug_state if byebugsetting is on" do
72
68
  enter 'set byebugtesting', 'break 3', 'cont'
73
- debug_file('set') { state.must_be_kind_of Byebug::CommandProcessor::State }
69
+ debug_file('set') {
70
+ state.must_be_kind_of Byebug::CommandProcessor::State }
74
71
  end
75
72
 
76
73
  it "must set basename on too" do
@@ -81,9 +78,9 @@ describe "Set Command" do
81
78
  end
82
79
  end
83
80
 
84
- it "must not set $rdebug_context if byebugsetting is off" do
81
+ it "must not set $byebug_state if byebugsetting is off" do
85
82
  enter 'set nobyebugtesting', 'break 3', 'cont'
86
- debug_file('set') { state.must_be_nil }
83
+ debug_file('set') { $byebug_state.must_be_nil }
87
84
  end
88
85
  end
89
86
 
@@ -168,9 +165,9 @@ describe "Set Command" do
168
165
  temporary_change_hash_value(Byebug::Command.settings, :autolist, 0)
169
166
  it "must work in post-mortem mode" do
170
167
  skip("No post morten mode for now")
171
- #enter 'cont', "set autolist on"
172
- #debug_file 'post_mortem'
173
- #check_output_includes "autolist is on."
168
+ enter 'cont', "set autolist on"
169
+ debug_file 'post_mortem'
170
+ check_output_includes "autolist is on."
174
171
  end
175
172
  end
176
173
 
@@ -106,11 +106,9 @@ describe "Show Command" do
106
106
  end
107
107
 
108
108
  it "must show linetrace" do
109
- temporary_change_method_value(context, :tracing, true) do
110
- enter 'show linetrace'
111
- debug_file 'show'
112
- check_output_includes "line tracing is on."
113
- end
109
+ enter 'trace on', 'show linetrace'
110
+ debug_file 'show'
111
+ check_output_includes "line tracing is on."
114
112
  end
115
113
 
116
114
 
@@ -7,51 +7,46 @@ describe "Stepping Commands" do
7
7
 
8
8
  describe "Usual mode" do
9
9
 
10
- before { enter 'break 10', 'cont' }
10
+ before do
11
+ enter 'break 10', 'cont'
12
+ end
11
13
 
12
14
  it "must go to the next line if forced by a setting" do
13
- temporary_change_hash_value(
14
- Byebug::Command.settings, :force_stepping, true) do
15
- enter 'next'
16
- debug_file('stepping') { state.line.must_equal 11 }
17
- end
15
+ Byebug::Command.settings[:force_stepping] = true
16
+ enter 'next'
17
+ debug_file('stepping') { state.line.must_equal 11 }
18
18
  end
19
19
 
20
20
  it "must go to the next line if forced by a setting (by shortcut)" do
21
- temporary_change_hash_value(
22
- Byebug::Command.settings, :force_stepping, true) do
23
- enter 'n'
24
- debug_file('stepping') { state.line.must_equal 11 }
25
- end
21
+ Byebug::Command.settings[:force_stepping] = true
22
+ enter 'n'
23
+ debug_file('stepping') { state.line.must_equal 11 }
26
24
  end
27
25
 
28
26
  it "must leave on the same line if forced by a setting" do
29
- temporary_change_hash_value(
30
- Byebug::Command.settings, :force_stepping, false) do
31
- enter 'next'
32
- debug_file('stepping') { state.line.must_equal 10 }
33
- end
27
+ Byebug::Command.settings[:force_stepping] = false
28
+ enter 'next'
29
+ debug_file('stepping') { state.line.must_equal 10 }
34
30
  end
35
31
 
36
- it "must go to the specified number of lines forward by default" do
37
- temporary_change_hash_value(
38
- Byebug::Command.settings, :force_stepping, true) do
39
- enter 'next 2'
40
- debug_file('stepping') { state.line.must_equal 21 }
41
- end
32
+ it "must go the specified number of lines forward by default" do
33
+ Byebug::Command.settings[:force_stepping] = true
34
+ enter 'next 2'
35
+ debug_file('stepping') { state.line.must_equal 21 }
42
36
  end
43
37
 
44
- it "must go to the next line if forced to do that by 'plus' sign" do
38
+ it "must go to the next line if forced by 'plus' sign" do
45
39
  enter 'next+'
46
40
  debug_file('stepping') { state.line.must_equal 11 }
47
41
  end
48
42
 
49
- it "must leave on the same line if forced to do that by 'minus' sign" do
43
+ it "must leave on the same line if forced by 'minus' sign" do
50
44
  enter 'next-'
51
45
  debug_file('stepping') { state.line.must_equal 10 }
52
46
  end
53
47
 
54
48
  it "must ignore the setting if 'minus' is specified" do
49
+ Byebug::Command.settings[:force_stepping] = true
55
50
  enter 'next-'
56
51
  debug_file('stepping') { state.line.must_equal 10 }
57
52
  end
@@ -61,48 +56,43 @@ describe "Stepping Commands" do
61
56
  temporary_change_hash_value(Byebug::Command.settings, :autoeval, false)
62
57
  it "must not work in post-mortem mode" do
63
58
  skip("No post morten mode for now")
64
- #enter 'cont', "next"
65
- #debug_file('post_mortem')
66
- #check_output_includes 'Unknown command: "next". Try "help".', interface.error_queue
59
+ enter 'cont', "next"
60
+ debug_file('post_mortem')
61
+ check_output_includes 'Unknown command: "next". Try "help".', interface.error_queue
67
62
  end
68
63
  end
69
64
  end
70
65
 
71
-
72
66
  describe "Step Command" do
67
+
73
68
  describe "Usual mode" do
74
- before { enter 'break 10', 'cont' }
69
+
70
+ before do
71
+ enter 'break 10', 'cont'
72
+ end
75
73
 
76
74
  it "must go to the step line if forced by a setting" do
77
- temporary_change_hash_value(
78
- Byebug::Command.settings, :force_stepping, true) do
79
- enter 'step'
80
- debug_file('stepping') { state.line.must_equal 11 }
81
- end
75
+ Byebug::Command.settings[:force_stepping] = true
76
+ enter 'step'
77
+ debug_file('stepping') { state.line.must_equal 11 }
82
78
  end
83
79
 
84
80
  it "must go to the next line by shortcut" do
85
- temporary_change_hash_value(
86
- Byebug::Command.settings, :force_stepping, true) do
87
- enter 's'
88
- debug_file('stepping') { state.line.must_equal 11 }
89
- end
81
+ Byebug::Command.settings[:force_stepping] = true
82
+ enter 's'
83
+ debug_file('stepping') { state.line.must_equal 11 }
90
84
  end
91
85
 
92
86
  it "must leave on the same line if forced by a setting" do
93
- temporary_change_hash_value(
94
- Byebug::Command.settings, :force_stepping, false) do
95
- enter 'step'
96
- debug_file('stepping') { state.line.must_equal 10 }
97
- end
87
+ Byebug::Command.settings[:force_stepping] = false
88
+ enter 'step'
89
+ debug_file('stepping') { state.line.must_equal 10 }
98
90
  end
99
91
 
100
- it "must go to the specified number of lines forward by default" do
101
- temporary_change_hash_value(
102
- Byebug::Command.settings, :force_stepping, true) do
103
- enter 'step 2'
104
- debug_file('stepping') { state.line.must_equal 15 }
105
- end
92
+ it "must go the specified number of lines forward by default" do
93
+ Byebug::Command.settings[:force_stepping] = true
94
+ enter 'step 2'
95
+ debug_file('stepping') { state.line.must_equal 15 }
106
96
  end
107
97
 
108
98
  it "must go to the step line if forced to do that by 'plus' sign" do
@@ -120,9 +110,9 @@ describe "Stepping Commands" do
120
110
  temporary_change_hash_value(Byebug::Command.settings, :autoeval, false)
121
111
  it "must not work in post-mortem mode" do
122
112
  skip("No post morten mode for now")
123
- #enter 'cont', "step"
124
- #debug_file('post_mortem')
125
- #check_output_includes 'Unknown command: "step". Try "help".', interface.error_queue
113
+ enter 'cont', "step"
114
+ debug_file('post_mortem')
115
+ check_output_includes 'Unknown command: "step". Try "help".', interface.error_queue
126
116
  end
127
117
  end
128
118
  end
@@ -1,4 +1,5 @@
1
1
  module Byebug
2
+
2
3
  class Context
3
4
 
4
5
  def inspect
@@ -1,7 +1,13 @@
1
- class Byebug::Processor
2
- class << self
3
- def print(message)
4
- Byebug.handler.interface.print_queue << message
1
+ module Byebug
2
+
3
+ class Processor
4
+
5
+ class << self
6
+ def print(message)
7
+ Byebug.handler.interface.print_queue << message
8
+ end
5
9
  end
10
+
6
11
  end
12
+
7
13
  end
@@ -12,6 +12,7 @@ module TestDsl
12
12
  base.class_eval do
13
13
  extend ClassMethods
14
14
  before do
15
+ Byebug::Command.settings[:byebugtesting] = true
15
16
  Byebug.interface = TestInterface.new
16
17
  Byebug.handler.display.clear
17
18
  end
@@ -21,10 +22,11 @@ module TestDsl
21
22
  end
22
23
  end
23
24
 
25
+ ##
24
26
  # Adds commands to the input queue, so they will be later retrieved by
25
- # Processor, i.e. it emulates user's input.
27
+ # Processor, i.e., it emulates user's input.
26
28
  #
27
- # If a command is a Proc object, it will be executed before retrieving by
29
+ # If a command is a Proc object, it will be executed before being retrieved by
28
30
  # Processor. May be handy when you need build a command depending on the
29
31
  # current context/state.
30
32
  #
@@ -39,13 +41,13 @@ module TestDsl
39
41
  interface.input_queue.concat(messages)
40
42
  end
41
43
 
42
- # Runs a byebug with the provided basename for a file. The file should be
43
- # placed in the test/examples dir.
44
+ ##
45
+ # Runs byebug with the provided basename for a file.
44
46
  #
45
- # You also can specify a block, which will be executed when Processor extracts
46
- # all the commands from the input queue. You can use it e.g. for making
47
- # asserts for the current test. If you specified the block, and it never was
48
- # executed, the test will fail.
47
+ # The file should be placed in the test/examples dir. You also can specify a
48
+ # block, which will be executed when Processor extracts all the commands from
49
+ # the input queue. You can use that for making asserts on the current test. If
50
+ # you specified the block and it never was executed, the test will fail.
49
51
  #
50
52
  # Usage:
51
53
  # debug "ex1" # ex1 should be placed in test/examples/ex1.rb
@@ -81,18 +83,20 @@ module TestDsl
81
83
  raise exception if exception
82
84
  end
83
85
 
86
+ ##
87
+ # Checks the output of byebug.
84
88
  #
85
- # Checks the output of byebug. By default it checks output queue of the current
86
- # interface, but you can check again any queue by providing it as a second
87
- # argument.
89
+ # By default it checks output queue of the current interface, but you can
90
+ # check again any queue by providing it as a second argument.
88
91
  #
89
92
  # Usage:
90
93
  # enter 'break 4', 'cont'
91
- # debug("ex1")
94
+ # debug 'ex1'
92
95
  # check_output "Breakpoint 1 at #{fullpath('ex1')}:4"
93
96
  #
94
97
  def check_output(check_method, *args)
95
- queue = args.last.is_a?(String) || args.last.is_a?(Regexp) ? interface.output_queue : args.pop
98
+ queue = args.last.is_a?(String) || args.last.is_a?(Regexp) ?
99
+ interface.output_queue : args.pop
96
100
  queue_messages = queue.map(&:strip)
97
101
  messages = Array(args).map { |msg| msg.is_a?(String) ? msg.strip : msg }
98
102
  queue_messages.send(check_method, messages)
@@ -111,17 +115,13 @@ module TestDsl
111
115
  end
112
116
 
113
117
  def state
114
- $rdebug_state
118
+ $byebug_state
115
119
  end
116
120
 
117
121
  def context
118
122
  state.context
119
123
  end
120
124
 
121
- def breakpoint
122
- Byebug.breakpoints.first
123
- end
124
-
125
125
  def force_set_const(klass, const, value)
126
126
  klass.send(:remove_const, const) if klass.const_defined?(const)
127
127
  klass.const_set(const, value)
@@ -161,6 +161,34 @@ module TestDsl
161
161
  end
162
162
  end
163
163
 
164
+ def set_tmp_hash(hash, key, value)
165
+ @old_hashes.merge!({ hash => { key => hash[key] } }) do |k, v1, v2|
166
+ v1.merge(v2)
167
+ end
168
+ hash[key] = value
169
+ end
170
+
171
+ def restore_tmp_hash(hash, key)
172
+ hash[key] = @old_hashes[hash][key]
173
+ end
174
+
175
+ def set_tmp_const(klass, const, value)
176
+ @old_consts.merge!({ klass =>
177
+ { const => klass.const_defined?(const) ?
178
+ klass.const_get(const) : :__undefined__ } }) do |k, v1, v2|
179
+ v1.merge(v2)
180
+ end
181
+ value == :__undefined__ ? klass.send(:remove_const, const) :
182
+ force_set_const(klass, const, value)
183
+ end
184
+
185
+ def restore_tmp_const(klass, const)
186
+ @old_consts[klass][const] == :__undefined ?
187
+ klass.send(:remove_const, const) :
188
+ force_set_const(klass, const, @old_consts[klass][const])
189
+ end
190
+
191
+
164
192
  module ClassMethods
165
193
 
166
194
  include Shared