byebug 3.1.2 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -2
  3. data/CHANGELOG.md +15 -0
  4. data/GUIDE.md +17 -35
  5. data/Gemfile +8 -5
  6. data/LICENSE +1 -1
  7. data/README.md +10 -22
  8. data/Rakefile +1 -1
  9. data/ext/byebug/byebug.c +3 -2
  10. data/lib/byebug.rb +3 -38
  11. data/lib/byebug/commands/break.rb +83 -0
  12. data/lib/byebug/commands/catchpoint.rb +0 -1
  13. data/lib/byebug/commands/condition.rb +10 -6
  14. data/lib/byebug/commands/continue.rb +3 -6
  15. data/lib/byebug/commands/delete.rb +38 -0
  16. data/lib/byebug/commands/edit.rb +0 -2
  17. data/lib/byebug/commands/enable.rb +7 -8
  18. data/lib/byebug/commands/finish.rb +0 -2
  19. data/lib/byebug/commands/frame.rb +13 -15
  20. data/lib/byebug/commands/help.rb +1 -3
  21. data/lib/byebug/commands/history.rb +3 -3
  22. data/lib/byebug/commands/info.rb +4 -13
  23. data/lib/byebug/commands/interrupt.rb +25 -0
  24. data/lib/byebug/commands/kill.rb +0 -2
  25. data/lib/byebug/commands/list.rb +2 -4
  26. data/lib/byebug/commands/method.rb +2 -8
  27. data/lib/byebug/commands/quit.rb +0 -2
  28. data/lib/byebug/commands/reload.rb +2 -15
  29. data/lib/byebug/commands/repl.rb +0 -3
  30. data/lib/byebug/commands/{control.rb → restart.rb} +2 -26
  31. data/lib/byebug/commands/save.rb +0 -1
  32. data/lib/byebug/commands/set.rb +4 -7
  33. data/lib/byebug/commands/show.rb +0 -3
  34. data/lib/byebug/commands/source.rb +0 -3
  35. data/lib/byebug/commands/stepping.rb +3 -4
  36. data/lib/byebug/commands/trace.rb +0 -1
  37. data/lib/byebug/commands/variables.rb +3 -4
  38. data/lib/byebug/context.rb +0 -1
  39. data/lib/byebug/helper.rb +23 -0
  40. data/lib/byebug/interfaces/script_interface.rb +1 -1
  41. data/lib/byebug/processors/command_processor.rb +9 -9
  42. data/lib/byebug/remote.rb +2 -2
  43. data/lib/byebug/setting.rb +3 -1
  44. data/lib/byebug/settings/autoeval.rb +3 -1
  45. data/lib/byebug/settings/autoirb.rb +3 -1
  46. data/lib/byebug/settings/autolist.rb +3 -1
  47. data/lib/byebug/settings/autoreload.rb +1 -3
  48. data/lib/byebug/settings/autosave.rb +1 -3
  49. data/lib/byebug/settings/callstyle.rb +2 -4
  50. data/lib/byebug/settings/fullpath.rb +1 -3
  51. data/lib/byebug/settings/histfile.rb +1 -3
  52. data/lib/byebug/settings/histsize.rb +0 -4
  53. data/lib/byebug/settings/listsize.rb +1 -3
  54. data/lib/byebug/settings/post_mortem.rb +14 -1
  55. data/lib/byebug/settings/width.rb +1 -17
  56. data/lib/byebug/version.rb +1 -1
  57. data/test/break_test.rb +376 -0
  58. data/test/condition_test.rb +82 -0
  59. data/test/continue_test.rb +27 -30
  60. data/test/debugger_alias_test.rb +4 -4
  61. data/test/delete_test.rb +26 -0
  62. data/test/display_test.rb +80 -102
  63. data/test/edit_test.rb +28 -31
  64. data/test/eval_test.rb +50 -80
  65. data/test/finish_test.rb +23 -23
  66. data/test/frame_test.rb +172 -186
  67. data/test/help_test.rb +27 -37
  68. data/test/history_test.rb +32 -41
  69. data/test/info_test.rb +198 -230
  70. data/test/interrupt_test.rb +17 -36
  71. data/test/irb_test.rb +47 -0
  72. data/test/kill_test.rb +19 -19
  73. data/test/list_test.rb +126 -133
  74. data/test/method_test.rb +21 -54
  75. data/test/post_mortem_test.rb +44 -46
  76. data/test/pry_test.rb +42 -0
  77. data/test/quit_test.rb +17 -15
  78. data/test/reload_test.rb +23 -28
  79. data/test/restart_test.rb +35 -63
  80. data/test/save_test.rb +46 -62
  81. data/test/set_test.rb +93 -144
  82. data/test/show_test.rb +50 -71
  83. data/test/source_test.rb +23 -26
  84. data/test/stepping_test.rb +125 -153
  85. data/test/support/matchers.rb +1 -6
  86. data/test/support/test_interface.rb +1 -1
  87. data/test/support/{test_dsl.rb → utils.rb} +17 -64
  88. data/test/test_helper.rb +25 -7
  89. data/test/thread_test.rb +101 -89
  90. data/test/trace_test.rb +48 -85
  91. data/test/variables_test.rb +43 -80
  92. metadata +18 -13
  93. data/lib/byebug/commands/breakpoints.rb +0 -137
  94. data/lib/byebug/commands/skip.rb +0 -30
  95. data/test/breakpoints_test.rb +0 -474
  96. data/test/conditions_test.rb +0 -82
  97. data/test/repl_test.rb +0 -75
@@ -1,19 +1,37 @@
1
1
  if ENV['CI']
2
- require 'coveralls'
3
- Coveralls.wear! do
4
- add_filter 'test'
5
- end
2
+ require 'codeclimate-test-reporter'
3
+ CodeClimate::TestReporter.start
6
4
  end
7
5
 
8
6
  require 'minitest'
9
- require 'minitest/spec'
10
7
  require 'pathname'
11
8
  require 'mocha/mini_test'
12
9
  require 'byebug'
13
10
 
14
- Dir.glob(File.expand_path('../support/*.rb', __FILE__)).each { |f| require f }
11
+ require_relative 'support/utils'
12
+
13
+ class Byebug::TestCase < Minitest::Test
14
+ #
15
+ # Reset to default state before each test
16
+ #
17
+ def setup
18
+ Byebug.handler = Byebug::CommandProcessor.new(Byebug::TestInterface.new)
19
+ Byebug.breakpoints.clear if Byebug.breakpoints
20
+ Byebug.catchpoints.clear if Byebug.catchpoints
21
+
22
+ Byebug::Setting.load
23
+ Byebug::Setting[:autolist] = false
24
+ Byebug::Setting[:testing] = true
25
+ Byebug::Setting[:verbose] = true
26
+ Byebug::Setting[:width] = 80
15
27
 
16
- Byebug::Setting[:testing] = true
28
+ byebug_bin = File.expand_path('../../../bin/byebug', __FILE__)
29
+ force_set_const(Byebug, 'BYEBUG_SCRIPT', byebug_bin)
30
+ force_set_const(Byebug, 'PROG_SCRIPT', $0)
31
+ end
32
+
33
+ include Byebug::TestUtils
34
+ end
17
35
 
18
36
  # Init globals to avoid warnings
19
37
  $bla = nil
@@ -1,5 +1,5 @@
1
- module ThreadTest
2
- class Example
1
+ module Byebug
2
+ class ThreadExample
3
3
  def initialize
4
4
  Thread.main[:should_break] = false
5
5
  end
@@ -27,17 +27,21 @@ module ThreadTest
27
27
  end
28
28
  end
29
29
 
30
- class ThreadTestCase < TestDsl::TestCase
31
- let(:release) { 'eval Thread.main[:should_break] = true' }
32
-
33
- before do
30
+ class ThreadTestCase < TestCase
31
+ def setup
34
32
  @example = -> do
35
33
  byebug
36
34
 
37
- t = Example.new
35
+ t = ThreadExample.new
38
36
  t.launch
39
37
  t.kill
40
38
  end
39
+
40
+ super
41
+ end
42
+
43
+ def release
44
+ @release ||= 'eval Thread.main[:should_break] = true'
41
45
  end
42
46
 
43
47
  def first_thnum
@@ -48,105 +52,113 @@ module ThreadTest
48
52
  Byebug.contexts.last.thnum
49
53
  end
50
54
 
51
- describe 'list' do
52
- it 'must show current thread by "plus" sign' do
53
- thnum = nil
54
- enter 'break 8', 'cont', 'thread list', release
55
- debug_proc(@example) { thnum = first_thnum }
56
- check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:8/)
57
- end
55
+ def test_thread_list_marks_current_thread_with_a_plus_sign
56
+ skip 'for now'
57
+ thnum = nil
58
+ enter 'break 8', 'cont', 'thread list', release
59
+ debug_proc(@example) { thnum = first_thnum }
60
+ check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:8/)
61
+ end
58
62
 
59
- it 'must work with shortcut' do
60
- thnum = nil
61
- enter 'break 8', 'cont', 'th list', release
62
- debug_proc(@example) { thnum = first_thnum }
63
- check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:8/)
64
- end
63
+ def test_thread_list_works_with_shortcut
64
+ skip 'for now'
65
+ thnum = nil
66
+ enter 'break 8', 'cont', 'th list', release
67
+ debug_proc(@example) { thnum = first_thnum }
68
+ check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:8/)
69
+ end
65
70
 
66
- it 'must show 3 available threads' do
67
- enter 'break 21', 'cont', 'thread list', release
68
- debug_proc(@example)
69
- check_output_includes(/(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
70
- /(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
71
- /(\+)?\d+ #<Thread:\S+ (sleep|run)>/)
72
- end
71
+ def test_thread_list_show_all_available_threads
72
+ skip 'for now'
73
+ enter 'break 21', 'cont', 'thread list', release
74
+ debug_proc(@example)
75
+ check_output_includes(/(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
76
+ /(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
77
+ /(\+)?\d+ #<Thread:\S+ (sleep|run)>/)
73
78
  end
74
79
 
75
- describe 'stop' do
76
- it 'must mark thread as suspended' do
77
- thnum = nil
78
- enter 'break 21', 'cont', ->{ "thread stop #{last_thnum}" }, release
79
- debug_proc(@example) { thnum = last_thnum }
80
- check_output_includes(/\$ #{thnum} #<Thread:/)
81
- end
80
+ def test_thread_stop_marks_thread_as_suspended
81
+ skip 'for now'
82
+ thnum = nil
83
+ enter 'break 21', 'cont', -> { "thread stop #{last_thnum}" }, release
84
+ debug_proc(@example) { thnum = last_thnum }
85
+ check_output_includes(/\$ #{thnum} #<Thread:/)
86
+ end
82
87
 
83
- it 'must actually suspend thread execution' do
84
- enter 'break 21', 'cont', 'trace on',
85
- ->{ "thread stop #{last_thnum}" }, release
86
- debug_proc(@example)
87
- check_output_doesnt_include(/Tracing: #{__FILE__}:16/,
88
- /Tracing: #{__FILE__}:17/)
89
- end
88
+ def test_thread_stop_actually_suspends_thread_execution
89
+ skip 'for now'
90
+ enter 'break 21', 'cont', 'trace on',
91
+ -> { "thread stop #{last_thnum}" }, release
92
+ debug_proc(@example)
93
+ check_output_doesnt_include(/Tracing: #{__FILE__}:16/,
94
+ /Tracing: #{__FILE__}:17/)
95
+ end
90
96
 
91
- it 'must show error message if thread number is not specified' do
92
- enter 'break 8', 'cont', 'thread stop', release
93
- debug_proc(@example)
94
- check_error_includes '"thread stop" needs a thread number'
95
- end
97
+ def test_thread_stop_shows_error_when_thread_number_not_specified
98
+ skip 'for now'
99
+ enter 'break 8', 'cont', 'thread stop', release
100
+ debug_proc(@example)
101
+ check_error_includes '"thread stop" needs a thread number'
102
+ end
96
103
 
97
- it 'must show error message when trying to stop current thread' do
98
- enter 'break 8', 'cont', -> { "thread stop #{first_thnum}" }, release
99
- debug_proc(@example)
100
- check_error_includes "It's the current thread"
101
- end
104
+ def test_thread_stop_shows_error_when_trying_to_stop_current_thread
105
+ skip 'for now'
106
+ enter 'break 8', 'cont', -> { "thread stop #{first_thnum}" }, release
107
+ debug_proc(@example)
108
+ check_error_includes "It's the current thread"
102
109
  end
103
110
 
104
- describe 'resume' do
105
- it 'must mark remove thread from the suspended state' do
106
- thnum = nil
107
- enter 'break 21', 'cont',
108
- -> { thnum = last_thnum ; "thread stop #{thnum}" },
109
- -> { "thread resume #{thnum}" }, release
110
- debug_proc(@example) { Byebug.contexts.last.suspended?.must_equal false }
111
- check_output_includes(/\$ #{thnum} #<Thread:/, /#{thnum} #<Thread:/)
111
+ def test_thread_resume_removes_threads_from_the_suspended_state
112
+ skip 'for now'
113
+ thnum = nil
114
+ enter 'break 21', 'cont',
115
+ -> { thnum = last_thnum ; "thread stop #{thnum}" },
116
+ -> { "thread resume #{thnum}" }, release
117
+ debug_proc(@example) do
118
+ assert_equal false, Byebug.contexts.last.suspended?
112
119
  end
120
+ check_output_includes(/\$ #{thnum} #<Thread:/, /#{thnum} #<Thread:/)
121
+ end
113
122
 
114
- it 'must show error message if thread number is not specified' do
115
- enter 'break 8', 'cont', 'thread resume', release
116
- debug_proc(@example)
117
- check_error_includes '"thread resume" needs a thread number'
118
- end
123
+ def test_thread_resume_shows_error_if_thread_number_not_specified
124
+ skip 'for now'
125
+ enter 'break 8', 'cont', 'thread resume', release
126
+ debug_proc(@example)
127
+ check_error_includes '"thread resume" needs a thread number'
128
+ end
119
129
 
120
- it 'must show error message when trying to resume current thread' do
121
- enter 'break 8', 'cont', ->{ "thread resume #{first_thnum}" }, release
122
- debug_proc(@example)
123
- check_error_includes "It's the current thread"
124
- end
130
+ def test_thread_resume_shows_error_when_trying_to_resume_current_thread
131
+ skip 'for now'
132
+ enter 'break 8', 'cont', -> { "thread resume #{first_thnum}" }, release
133
+ debug_proc(@example)
134
+ check_error_includes "It's the current thread"
135
+ end
125
136
 
126
- it 'must show error message if it is not stopped' do
127
- enter 'break 21', 'cont', ->{ "thread resume #{last_thnum}" }, release
128
- debug_proc(@example)
129
- check_error_includes 'Already running'
130
- end
137
+ def test_thread_resume_shows_error_if_thread_is_already_running
138
+ skip 'for now'
139
+ enter 'break 21', 'cont', -> { "thread resume #{last_thnum}" }, release
140
+ debug_proc(@example)
141
+ check_error_includes 'Already running'
131
142
  end
132
143
 
133
- describe 'switch' do
134
- it 'must switch to another thread' do
135
- enter 'break 21', 'cont', ->{ "thread switch #{last_thnum}" }, release
136
- debug_proc(@example) { assert_equal state.line, 16 }
137
- end
144
+ def test_thread_switch_changes_execution_to_another_thread
145
+ skip 'for now'
146
+ enter 'break 21', 'cont', -> { "thread switch #{last_thnum}" }, release
147
+ debug_proc(@example) { assert_equal state.line, 16 }
148
+ end
138
149
 
139
- it 'must show error message if thread number is not specified' do
140
- enter 'break 8', 'cont', 'thread switch', release
141
- debug_proc(@example)
142
- check_error_includes '"thread switch" needs a thread number'
143
- end
150
+ def test_thread_switch_shows_error_if_thread_number_not_specified
151
+ skip 'for now'
152
+ enter 'break 8', 'cont', 'thread switch', release
153
+ debug_proc(@example)
154
+ check_error_includes '"thread switch" needs a thread number'
155
+ end
144
156
 
145
- it 'must show error message when trying to switch current thread' do
146
- enter 'break 8', 'cont', ->{ "thread switch #{first_thnum}" }, release
147
- debug_proc(@example)
148
- check_error_includes "It's the current thread"
149
- end
157
+ def test_thread_switch_shows_error_when_trying_to_switch_current_thread
158
+ skip 'for now'
159
+ enter 'break 8', 'cont', -> { "thread switch #{first_thnum}" }, release
160
+ debug_proc(@example)
161
+ check_error_includes "It's the current thread"
150
162
  end
151
163
  end
152
164
  end
@@ -1,6 +1,6 @@
1
- module TraceTest
2
- class TraceTestCase < TestDsl::TestCase
3
- before do
1
+ module Byebug
2
+ class TraceTestCase < TestCase
3
+ def setup
4
4
  @example = -> do
5
5
  $bla = 5
6
6
  byebug
@@ -11,98 +11,61 @@ module TraceTest
11
11
  $bla = (0 == (10 % $bla))
12
12
  end
13
13
  untrace_var(:$bla) if defined?($bla)
14
- end
15
-
16
- describe 'line tracing' do
17
- describe 'enabling' do
18
- it 'must trace execution by setting trace to on' do
19
- enter 'set linetrace', 'cont 10', 'set nolinetrace'
20
- debug_proc(@example)
21
- check_output_includes 'linetrace is on',
22
- "Tracing: #{__FILE__}:8 $bla = 8",
23
- "Tracing: #{__FILE__}:10 $bla = 10"
24
- end
25
-
26
- it 'must be able to use a shortcut' do
27
- enter 'set lin on', 'cont 10', 'set nolin'
28
- debug_proc(@example)
29
- check_output_includes 'linetrace is on',
30
- "Tracing: #{__FILE__}:8 $bla = 8",
31
- "Tracing: #{__FILE__}:10 $bla = 10"
32
- end
33
-
34
- it 'must correctly print lines containing % sign' do
35
- enter 'cont 10', 'set linetrace', 'next', 'set nolinetrace'
36
- debug_proc(@example)
37
- check_output_includes "Tracing: #{__FILE__}:11 $bla = (0 == (10 % $bla))"
38
- end
39
-
40
- describe 'when basename set' do
41
- temporary_change_hash Byebug::Setting, :basename, true
42
14
 
43
- it 'must correctly print file lines' do
44
- enter 'set linetrace on', 'cont 10', 'set nolinetrace'
45
- debug_proc(@example)
46
- check_output_includes \
47
- "Tracing: #{File.basename(__FILE__)}:10 $bla = 10"
48
- end
49
- end
50
- end
15
+ super
16
+ end
51
17
 
52
- describe 'disabling' do
53
- it 'must stop tracing by setting trace to off' do
54
- enter 'set linetrace', 'next', 'set nolinetrace'
55
- debug_proc(@example)
56
- check_output_includes "Tracing: #{__FILE__}:8 $bla = 8"
57
- check_output_doesnt_include "Tracing: #{__FILE__}:9 $bla = 9"
58
- end
18
+ def test_linetrace_setting_enables_tracing_program_execution
19
+ enter 'set linetrace', 'cont 11', 'set nolinetrace'
20
+ debug_proc(@example)
21
+ check_output_includes 'linetrace is on',
22
+ "Tracing: #{__FILE__}:8 $bla = 8",
23
+ "Tracing: #{__FILE__}:9 $bla = 9",
24
+ "Tracing: #{__FILE__}:10 $bla = 10",
25
+ "Tracing: #{__FILE__}:11 $bla = (0 == (10 % $bla))"
26
+ end
59
27
 
60
- it 'must show a message when turned off' do
61
- enter 'set nolinetrace'
62
- debug_proc(@example)
63
- check_output_includes 'linetrace is off'
64
- end
65
- end
28
+ def test_basename_setting_affects_tracing_output
29
+ enter 'set basename', 'set linetrace on', 'cont 10', 'set nolinetrace'
30
+ debug_proc(@example)
31
+ check_output_includes \
32
+ "Tracing: #{File.basename(__FILE__)}:10 $bla = 10"
66
33
  end
67
34
 
68
- describe 'global variable tracing' do
69
- it 'must track global variable' do
70
- enter 'tracevar bla'
71
- debug_proc(@example)
72
- check_output_includes "traced global variable 'bla' has value '7'",
73
- "traced global variable 'bla' has value '10'"
74
- end
35
+ def test_disabling_linetrace_setting_stops_tracing
36
+ enter 'set linetrace', 'next', 'set nolinetrace'
37
+ debug_proc(@example)
38
+ check_output_includes "Tracing: #{__FILE__}:8 $bla = 8"
39
+ check_output_doesnt_include "Tracing: #{__FILE__}:9 $bla = 9"
40
+ end
75
41
 
76
- it 'must be able to use a shortcut' do
77
- enter 'tracevar bla'
78
- debug_proc(@example)
79
- check_output_includes "traced global variable 'bla' has value '7'"
80
- "traced global variable 'bla' has value '10'"
81
- end
42
+ def test_tracevar_tracks_global_variables
43
+ enter 'tracevar bla'
44
+ debug_proc(@example)
45
+ check_output_includes "traced global variable 'bla' has value '7'",
46
+ "traced global variable 'bla' has value '10'"
47
+ end
82
48
 
83
- it 'must track global variable with stop' do
84
- enter 'tracevar bla stop', 'break 10', 'cont'
85
- debug_proc(@example) { state.line.must_equal 8 }
86
- end
49
+ def test_tracevar_stop_makes_program_stop_when_global_var_changes
50
+ enter 'tracevar bla stop', 'break 10', 'cont'
51
+ debug_proc(@example) { assert_equal 8, state.line }
52
+ end
87
53
 
88
- it 'must track global variable with nostop' do
89
- enter 'tracevar bla nostop', 'break 10', 'cont'
90
- debug_proc(@example) { state.line.must_equal 10 }
91
- end
54
+ def test_tracevar_nostop_does_not_stop_when_global_var_changes
55
+ enter 'tracevar bla nostop', 'break 10', 'cont'
56
+ debug_proc(@example) { assert_equal 10, state.line }
57
+ end
92
58
 
93
- describe 'errors' do
94
- it 'must show an error message if there is no such global variable' do
95
- enter 'tracevar foo'
96
- debug_proc(@example)
97
- check_error_includes "'foo' is not a global variable."
98
- end
59
+ def test_tracevar_shows_an_error_message_if_there_is_no_such_global_var
60
+ enter 'tracevar foo'
61
+ debug_proc(@example)
62
+ check_error_includes "'foo' is not a global variable."
63
+ end
99
64
 
100
- it 'must show an error message if subcommand is invalid' do
101
- enter 'tracevar bla foo'
102
- debug_proc(@example)
103
- check_error_includes 'expecting "stop" or "nostop"; got "foo"'
104
- end
105
- end
65
+ def test_tracevar_shows_an_error_message_if_subcommand_is_invalid
66
+ enter 'tracevar bla foo'
67
+ debug_proc(@example)
68
+ check_error_includes 'expecting "stop" or "nostop"; got "foo"'
106
69
  end
107
70
  end
108
71
  end
@@ -1,5 +1,5 @@
1
- module VariablesTest
2
- class Example
1
+ module Byebug
2
+ class VariablesExample
3
3
  SOMECONST = 'foo' unless defined?(SOMECONST)
4
4
 
5
5
  def initialize
@@ -18,116 +18,79 @@ module VariablesTest
18
18
  end
19
19
  end
20
20
 
21
-
22
- class VariablesTestCase < TestDsl::TestCase
23
- before do
21
+ class VariablesTestCase < TestCase
22
+ def setup
24
23
  @example = -> do
25
24
  byebug
26
25
 
27
- v = Example.new
26
+ v = VariablesExample.new
28
27
  v.run
29
28
  end
29
+
30
+ super
30
31
  end
31
32
 
32
33
  # we check a class minitest variable... brittle but ok for now
33
- describe 'class variables' do
34
- before { enter 'break 28', 'cont' }
35
-
36
- it 'must show variables' do
37
- enter 'var class'
38
- debug_proc(@example)
39
- check_output_includes(/@@runnables/)
40
- end
41
-
42
- it 'must be able to use shortcut' do
43
- enter 'v cl'
34
+ ['var class', 'v cl'].each do |cmd_alias|
35
+ define_method(:"test_#{cmd_alias}_shows_class_variables") do
36
+ enter cmd_alias
44
37
  debug_proc(@example)
45
38
  check_output_includes(/@@runnables/)
46
39
  end
47
40
  end
48
41
 
49
- describe 'constants' do
50
- it 'must show constants' do
51
- enter 'break 28', 'cont', 'var const Example'
42
+ ['var const', 'v co'].each do |cmd_alias|
43
+ define_method(:"test_#{cmd_alias}_shows_constants_in_class_or_module") do
44
+ enter "#{cmd_alias} VariablesExample"
52
45
  debug_proc(@example)
53
46
  check_output_includes 'SOMECONST => "foo"'
54
47
  end
55
-
56
- it 'must be able to use shortcut' do
57
- enter 'break 28', 'cont', 'v co Example'
58
- debug_proc(@example)
59
- check_output_includes 'SOMECONST => "foo"'
60
- end
61
-
62
- it 'must show error message if given object is not a class or a module' do
63
- enter 'break 28', 'cont', 'var const v'
64
- debug_proc(@example)
65
- check_output_includes 'Should be Class/Module: v'
66
- end
67
48
  end
68
49
 
69
- describe 'globals' do
70
- it 'must show global variables' do
71
- enter 'break 28', 'cont', 'var global'
72
- debug_proc(@example)
73
- check_output_includes '$VERBOSE = true'
74
- end
50
+ def test_var_const_shows_error_if_given_object_is_not_a_class_or_module
51
+ enter 'var const v'
52
+ debug_proc(@example)
53
+ check_output_includes 'Should be Class/Module: v'
54
+ end
75
55
 
76
- it 'must be able to use shortcut' do
77
- enter 'break 28', 'cont', 'v g'
56
+ ['var global', 'v g'].each do |cmd_alias|
57
+ define_method(:"test_#{cmd_alias}_shows_global_variables") do
58
+ enter cmd_alias
78
59
  debug_proc(@example)
79
60
  check_output_includes '$VERBOSE = true'
80
61
  end
81
62
  end
82
63
 
83
- describe 'instance variables' do
84
- it 'must show instance variables of the given object' do
85
- enter 'break 28', 'cont', 'var instance v'
86
- debug_proc(@example)
87
- check_output_includes '@inst_a = 1', '@inst_b = 2'
88
- end
89
-
90
- it 'must show instance variables of self' do
91
- enter 'break 9', 'cont', 'var instance'
92
- debug_proc(@example)
93
- check_output_includes '@inst_a = 1', '@inst_b = 2'
94
- end
95
-
96
- it 'must show instance variables' do
97
- enter 'break 28', 'cont', 'var instance v'
98
- debug_proc(@example)
99
- check_output_includes '@inst_a = 1', '@inst_b = 2'
100
- end
101
-
102
- it 'must be able to use shortcut' do
103
- enter 'break 28', 'cont', 'v ins v'
64
+ ['var instance', 'v ins'].each do |cmd_alias|
65
+ define_method(:"test_#{cmd_alias}_shows_instance_vars_of_an_object") do
66
+ enter 'break 27', 'cont', "#{cmd_alias} v"
104
67
  debug_proc(@example)
105
68
  check_output_includes '@inst_a = 1', '@inst_b = 2'
106
69
  end
70
+ end
107
71
 
108
- describe 'when width is too small' do
109
- temporary_change_hash Byebug::Setting, :width, 20
72
+ def test_var_instance_shows_instance_variables_of_self_if_no_object_given
73
+ enter 'break 9', 'cont', 'var instance'
74
+ debug_proc(@example)
75
+ check_output_includes '@inst_a = 1', '@inst_b = 2'
76
+ end
110
77
 
111
- it 'must cut long variable values according it' do
112
- enter 'break 28', 'cont', 'var instance v'
113
- debug_proc(@example)
114
- check_output_includes '@inst_c = "1111111111111111...'
115
- end
116
- end
78
+ def test_var_instance_cuts_long_variable_values_according_to_width_setting
79
+ enter 'break 27', 'cont', 'set width 45', 'var instance v'
80
+ debug_proc(@example)
81
+ check_output_includes '@inst_c = "1111111111111111111111111111111...'
82
+ end
117
83
 
118
- it 'must show error if value doesn\'t have #to_s/#inspect methods' do
119
- enter 'break 28', 'cont', 'var instance v'
120
- debug_proc(@example)
121
- check_output_includes '@inst_d = *Error in evaluation*'
122
- end
84
+ def test_v_ins_shows_error_if_value_does_not_have_to_s_or_inspect_methods
85
+ enter 'break 27', 'cont', 'v ins v'
86
+ debug_proc(@example)
87
+ check_output_includes '@inst_d = *Error in evaluation*'
123
88
  end
124
89
 
125
- describe 'local variables' do
126
- it 'must show local variables' do
127
- enter 'break 15', 'cont', 'var local'
128
- debug_proc(@example)
129
- check_output_includes 'a => 4', 'b => nil', 'i => 1'
130
- end
90
+ def test_var_local_shows_local_variables
91
+ enter 'break 15', 'cont', 'var local'
92
+ debug_proc(@example)
93
+ check_output_includes 'a => 4', 'b => nil', 'i => 1'
131
94
  end
132
95
  end
133
96
  end