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,59 +1,49 @@
1
- module HelpTest
2
- class HelpTestCase < TestDsl::TestCase
1
+ module Byebug
2
+ class HelpTestCase < TestCase
3
3
  include Columnize
4
4
 
5
- before do
5
+ def setup
6
6
  @example = -> do
7
7
  byebug
8
8
  end
9
- end
10
9
 
11
- let(:available_cmds) do
12
- Byebug::Command.commands.map(&:names).flatten.uniq.sort
10
+ super
13
11
  end
14
12
 
15
- describe 'when typed alone' do
16
- temporary_change_hash Byebug::Setting, :width, 50
13
+ def available_cmds
14
+ @available_cmds ||=
15
+ Command.commands.map(&:names).flatten.uniq.sort
16
+ end
17
17
 
18
- it 'must show self help when typed alone' do
19
- enter 'help'
18
+ %w(help h).each do |cmd_alias|
19
+ define_method(:"test_#{cmd_alias}_shows_help_for_help_command_itself") do
20
+ enter 'set width 50', cmd_alias
20
21
  debug_proc(@example)
21
22
  check_output_includes \
22
23
  'Type "help <command-name>" for help on a specific command',
23
24
  'Available commands:', columnize(available_cmds, 50)
24
25
  end
25
-
26
- it 'must work when shortcut used' do
27
- enter 'h'
28
- debug_proc(@example)
29
- check_output_includes \
30
- 'Type "help <command-name>" for help on a specific command'
31
- end
32
26
  end
33
27
 
34
- describe 'when typed with a command' do
35
- it 'must show an error if an undefined command is specified' do
36
- enter 'help foobar'
37
- debug_proc(@example)
38
- check_error_includes 'Undefined command: "foobar". Try "help".'
39
- end
28
+ def test_help_with_specific_command_shows_help_for_it
29
+ enter 'help break'
30
+ debug_proc(@example)
31
+ check_output_includes \
32
+ "b[reak] file:line [if expr]\n" \
33
+ "b[reak] class(.|#)method [if expr]\n\n" \
34
+ "Set breakpoint to some position, (optionally) if expr == true\n"
35
+ end
40
36
 
41
- it "must show a command's help" do
42
- enter 'help break'
43
- debug_proc(@example)
44
- check_output_includes \
45
- "b[reak] file:line [if expr]\n" \
46
- "b[reak] class(.|#)method [if expr]\n\n" \
47
- "Set breakpoint to some position, (optionally) if expr == true\n"
48
- end
37
+ def test_help_with_undefined_command_shows_an_error
38
+ enter 'help foobar'
39
+ debug_proc(@example)
40
+ check_error_includes 'Undefined command: "foobar". Try "help".'
49
41
  end
50
42
 
51
- describe 'when typed with command and subcommand' do
52
- it "must show subcommand's help" do
53
- enter 'help info breakpoints'
54
- debug_proc(@example)
55
- check_output_includes "Status of user-settable breakpoints.\n"
56
- end
43
+ def test_help_with_command_and_subcommand_shows_subcommands_help
44
+ enter 'help info breakpoints'
45
+ debug_proc(@example)
46
+ check_output_includes "Status of user-settable breakpoints.\n"
57
47
  end
58
48
  end
59
49
  end
@@ -1,54 +1,45 @@
1
- module HistoryTest
2
- class HistoryTestCase < TestDsl::TestCase
3
- before do
1
+ module Byebug
2
+ class HistoryTestCase < TestCase
3
+ def setup
4
4
  @example = -> do
5
5
  byebug
6
6
  end
7
- end
8
7
 
9
- describe 'history command' do
10
- temporary_change_const Readline, 'HISTORY', %w(aaa bbb ccc ddd)
8
+ super
11
9
 
12
- describe 'with autosave disabled' do
13
- temporary_change_hash Byebug::Setting, :autosave, false
10
+ @old_readline = Readline::HISTORY
11
+ force_set_const(Readline, 'HISTORY', %w(aaa bbb ccc ddd))
12
+ end
14
13
 
15
- it 'must not show records from readline' do
16
- enter 'history'
17
- debug_proc(@example)
18
- check_error_includes "Not currently saving history. " \
19
- 'Enable it with "set autosave"'
20
- end
21
- end
14
+ def teardown
15
+ force_set_const(Readline, 'HISTORY', @old_readline)
16
+ end
22
17
 
23
- describe 'with autosave enabled' do
24
- temporary_change_hash Byebug::Setting, :autosave, true
18
+ def test_history_displays_latest_records_from_readline_history
19
+ enter 'set histsize 3', 'history'
20
+ debug_proc(@example)
21
+ check_output_includes(/2 bbb\n 3 ccc\n 4 ddd/)
22
+ check_output_doesnt_include(/1 aaa/)
23
+ end
25
24
 
26
- describe 'must show records from readline' do
27
- it 'displays last max_size records from readline history' do
28
- enter 'set histsize 3', 'history'
29
- debug_proc(@example)
30
- check_output_includes(/2 bbb\n 3 ccc\n 4 ddd/)
31
- check_output_doesnt_include(/1 aaa/)
32
- end
33
- end
25
+ def test_history_displays_whole_history_if_max_size_is_bigger_than_readline
26
+ enter 'set histsize 7', 'history'
27
+ debug_proc(@example)
28
+ check_output_includes(/1 aaa\n 2 bbb\n 3 ccc\n 4 ddd/)
29
+ end
34
30
 
35
- describe 'max records' do
36
- it 'displays whole history if max_size is bigger than Readline::HISTORY' do
37
- enter 'set histsize 7', 'history'
38
- debug_proc(@example)
39
- check_output_includes(/1 aaa\n 2 bbb\n 3 ccc\n 4 ddd/)
40
- end
41
- end
31
+ def test_history_n_displays_lastest_n_records_from_readline_history
32
+ enter 'history 2'
33
+ debug_proc(@example)
34
+ check_output_includes(/3 ccc\n 4 ddd/)
35
+ check_output_doesnt_include(/1 aaa\n 2 bbb/)
36
+ end
42
37
 
43
- describe 'with specified size' do
44
- it 'displays the specified number of entries most recent first' do
45
- enter 'history 2'
46
- debug_proc(@example)
47
- check_output_includes(/3 ccc\n 4 ddd/)
48
- check_output_doesnt_include(/1 aaa\n 2 bbb/)
49
- end
50
- end
51
- end
38
+ def test_history_with_autosave_disabled_does_not_show_records_from_readline
39
+ enter 'set noautosave', 'history'
40
+ debug_proc(@example)
41
+ check_error_includes "Not currently saving history. " \
42
+ 'Enable it with "set autosave"'
52
43
  end
53
44
  end
54
45
  end
@@ -1,12 +1,12 @@
1
- module InfoTest
2
- class Example
1
+ module Byebug
2
+ class InfoExample
3
3
  def initialize
4
4
  @foo = 'bar'
5
5
  @bla = 'blabla'
6
6
  end
7
7
 
8
8
  def a(y, z)
9
- w = '1' * 30
9
+ w = '1' * 45
10
10
  x = 2
11
11
  w + x.to_s + y + z + @foo
12
12
  end
@@ -28,293 +28,261 @@ module InfoTest
28
28
  end
29
29
  end
30
30
 
31
- class InfoTestCase < TestDsl::TestCase
31
+ class InfoTestCase < TestCase
32
32
  include Columnize
33
33
 
34
- before do
34
+ def setup
35
35
  @example = -> do
36
36
  byebug
37
- i = Example.new
37
+ i = InfoExample.new
38
38
  i.b
39
39
  i.c
40
40
  i.d
41
41
  end
42
- end
43
42
 
44
- describe 'Args info' do
45
- it 'must show info about all args' do
46
- enter 'break 11', 'cont', 'info args'
47
- debug_proc(@example)
48
- check_output_includes 'y = "a"', 'z = "b"'
49
- end
43
+ super
50
44
  end
51
45
 
52
- describe 'Breakpoints info' do
53
- it 'must show info about all breakpoints' do
54
- enter 'break 38', 'break 39 if y == z', 'info breakpoints'
55
- debug_proc(@example)
56
- check_output_includes 'Num Enb What',
57
- /\d+ +y at #{__FILE__}:38/,
58
- /\d+ +y at #{__FILE__}:39 if y == z/
59
- end
46
+ def test_info_about_all_args
47
+ enter 'break 11', 'cont', 'info args'
48
+ debug_proc(@example)
49
+ check_output_includes 'y = "a"', 'z = "b"'
50
+ end
60
51
 
61
- it 'must show info about specific breakpoint' do
62
- enter 'break 38', 'break 39',
63
- -> { "info breakpoints #{Byebug.breakpoints.first.id}" }
64
- debug_proc(@example)
65
- check_output_includes 'Num Enb What', /\d+ +y at #{__FILE__}:38/
66
- check_output_doesnt_include(/\d+ +y at #{__FILE__}:39/)
67
- end
52
+ def test_info_about_all_breakpoints
53
+ enter 'break 38', 'break 39 if y == z', 'info breakpoints'
54
+ debug_proc(@example)
55
+ check_output_includes 'Num Enb What',
56
+ /\d+ +y at #{__FILE__}:38/,
57
+ /\d+ +y at #{__FILE__}:39 if y == z/
58
+ end
68
59
 
69
- it 'must show an error if no breakpoints are found' do
70
- enter 'info breakpoints'
71
- debug_proc(@example)
72
- check_output_includes 'No breakpoints.'
73
- end
60
+ def test_info_about_specific_breakpoints
61
+ enter 'break 38', 'break 39',
62
+ -> { "info breakpoints #{first_brkpt.id}" }
63
+ debug_proc(@example)
64
+ check_output_includes 'Num Enb What', /\d+ +y at #{__FILE__}:38/
65
+ check_output_doesnt_include(/\d+ +y at #{__FILE__}:39/)
66
+ end
74
67
 
75
- it 'must show an error if no breakpoints are found' do
76
- enter 'break 38', 'info breakpoints 100'
77
- debug_proc(@example)
78
- check_error_includes 'No breakpoints found among list given.'
79
- end
68
+ def test_info_breakpoints_shows_a_message_when_no_breakpoints_found
69
+ enter 'info breakpoints'
70
+ debug_proc(@example)
71
+ check_output_includes 'No breakpoints.'
72
+ end
80
73
 
81
- it 'must show hit count' do
82
- enter 'break 39', 'cont', 'info breakpoints'
83
- debug_proc(@example)
84
- check_output_includes(
85
- /\d+ +y at #{__FILE__}:39/, 'breakpoint already hit 1 time')
86
- end
74
+ def test_info_breakpoints_shows_error_if_specific_breakpoint_do_not_exist
75
+ enter 'break 38', 'info breakpoints 100'
76
+ debug_proc(@example)
77
+ check_error_includes 'No breakpoints found among list given.'
87
78
  end
88
79
 
89
- describe 'Display info' do
90
- it 'must show all display expressions' do
91
- enter 'display 3 + 3', 'display a + b', 'info display'
92
- debug_proc(@example)
93
- check_output_includes "Auto-display expressions now in effect:\n" \
94
- 'Num Enb Expression',
95
- '1: y 3 + 3',
96
- '2: y a + b'
97
- end
80
+ def test_info_breakpoints_shows_hit_counts
81
+ enter 'break 39', 'cont', 'info breakpoints'
82
+ debug_proc(@example)
83
+ check_output_includes(
84
+ /\d+ +y at #{__FILE__}:39/, 'breakpoint already hit 1 time')
85
+ end
98
86
 
99
- it 'must show a message if there are no display expressions created' do
100
- enter 'info display'
101
- debug_proc(@example)
102
- check_output_includes 'There are no auto-display expressions now.'
103
- end
87
+ def test_info_display_shows_all_display_expressions
88
+ enter 'display 3 + 3', 'display a + b', 'info display'
89
+ debug_proc(@example)
90
+ check_output_includes "Auto-display expressions now in effect:\n" \
91
+ 'Num Enb Expression',
92
+ '1: y 3 + 3',
93
+ '2: y a + b'
104
94
  end
105
95
 
106
- describe 'Files info' do
107
- let(:files) { SCRIPT_LINES__.keys.uniq.sort }
96
+ def test_info_display_shows_a_message_when_no_display_expressions_found
97
+ enter 'info display'
98
+ debug_proc(@example)
99
+ check_output_includes 'There are no auto-display expressions now.'
100
+ end
108
101
 
109
- it 'must show all files read in' do
110
- enter 'info files'
111
- debug_proc(@example)
112
- check_output_includes files.map { |f| "File #{f}" }
113
- end
102
+ def files
103
+ @files ||= SCRIPT_LINES__.keys.uniq.sort
104
+ end
114
105
 
115
- it 'must show all files read in using "info file" too' do
116
- enter 'info file'
106
+ %w(file files).each do |subcmd_alias|
107
+ define_method(:"test_info_#{subcmd_alias}_shows_all_files_read_in") do
108
+ enter 'list' # list command explicitly reloads current file into cache
109
+ enter "info #{subcmd_alias}"
117
110
  debug_proc(@example)
118
- check_output_includes files.map { |f| "File #{f}" }
111
+ check_output_includes "File #{__FILE__}", File.stat(__FILE__).mtime.to_s
119
112
  end
113
+ end
120
114
 
121
- it 'must show explicitly loaded files' do
122
- enter 'info files stat'
123
- debug_proc(@example)
124
- check_output_includes "File #{__FILE__}",
125
- LineCache.stat(__FILE__).mtime.to_s
126
- end
115
+ def filename
116
+ @filename ||= "File #{__FILE__}"
127
117
  end
128
118
 
129
- describe 'File info' do
130
- let(:file) { __FILE__ }
131
- let(:filename) { "File #{file}" }
132
- let(:lines) { "#{LineCache.size(file)} lines" }
133
- let(:mtime) { LineCache.stat(file).mtime.to_s }
134
- let(:sha1) { LineCache.sha1(file) }
135
- let(:breakpoint_line_numbers) {
136
- columnize(LineCache.trace_line_numbers(file).to_a.sort,
137
- Byebug::Setting[:width]) }
119
+ def lines
120
+ @lines ||= "#{File.foreach(__FILE__).count} lines"
121
+ end
138
122
 
139
- it 'must show basic info about the file' do
140
- enter "info file #{file} basic"
141
- debug_proc(@example)
142
- check_output_includes filename, lines
143
- check_output_doesnt_include breakpoint_line_numbers, mtime, sha1
144
- end
123
+ def mtime
124
+ @mtime ||= File.stat(__FILE__).mtime.to_s
125
+ end
145
126
 
146
- it 'must show number of lines' do
147
- enter "info file #{file} lines"
148
- debug_proc(@example)
149
- check_output_includes filename, lines
150
- check_output_doesnt_include breakpoint_line_numbers, mtime, sha1
151
- end
127
+ def sha1
128
+ @sha1 ||= Digest::SHA1.hexdigest(__FILE__)
129
+ end
152
130
 
153
- it 'must show mtime of the file' do
154
- enter "info file #{file} mtime"
155
- debug_proc(@example)
156
- check_output_includes filename, mtime
157
- check_output_doesnt_include lines, breakpoint_line_numbers, sha1
158
- end
131
+ def breakpoint_line_numbers
132
+ @breakpoint_line_numbers ||=
133
+ columnize(LineCache.trace_line_numbers(__FILE__).to_a.sort,
134
+ Setting[:width])
135
+ end
159
136
 
160
- it 'must show sha1 of the file' do
161
- enter "info file #{file} sha1"
162
- debug_proc(@example)
163
- check_output_includes filename, sha1
164
- check_output_doesnt_include lines, breakpoint_line_numbers, mtime
165
- end
137
+ def test_info_file_basic_shows_basic_info_about_a_specific_file
138
+ enter "info file #{__FILE__} basic"
139
+ debug_proc(@example)
140
+ check_output_includes filename, lines
141
+ check_output_doesnt_include breakpoint_line_numbers, mtime, sha1
142
+ end
166
143
 
167
- it 'must show breakpoints in the file' do
168
- enter 'break 38', 'break 39', "info file #{file} breakpoints"
169
- debug_proc(@example)
170
- check_output_includes(/Created breakpoint \d+ at #{file}:38/,
171
- /Created breakpoint \d+ at #{file}:39/,
172
- filename,
173
- 'breakpoint line numbers:', breakpoint_line_numbers)
174
- check_output_doesnt_include lines, mtime, sha1
175
- end
144
+ def test_info_file_lines_shows_number_of_lines_in_a_specific_file
145
+ enter "info file #{__FILE__} lines"
146
+ debug_proc(@example)
147
+ check_output_includes filename, lines
148
+ check_output_doesnt_include breakpoint_line_numbers, mtime, sha1
149
+ end
176
150
 
177
- it 'must show all info about the file' do
178
- enter "info file #{file} all"
179
- debug_proc(@example)
180
- check_output_includes \
181
- filename, lines, breakpoint_line_numbers, mtime, sha1
182
- end
151
+ def test_info_file_mtime_shows_mtime_of_a_specific_file
152
+ enter "info file #{__FILE__} mtime"
153
+ debug_proc(@example)
154
+ check_output_includes filename, mtime
155
+ check_output_doesnt_include lines, breakpoint_line_numbers, sha1
156
+ end
183
157
 
184
- it 'must not show any info if the parameter is invalid' do
185
- enter "info file #{file} blabla"
186
- debug_proc(@example)
187
- check_error_includes 'Invalid parameter blabla'
188
- end
158
+ def test_info_file_sha1_shows_sha1_signature_of_a_specific_file
159
+ enter "info file #{__FILE__} sha1"
160
+ debug_proc(@example)
161
+ check_output_includes filename, sha1
162
+ check_output_doesnt_include lines, breakpoint_line_numbers, mtime
189
163
  end
190
164
 
191
- describe 'Instance variables info' do
192
- it 'must show instance variables' do
193
- enter 'break 11', 'cont', 'info instance_variables'
194
- debug_proc(@example)
195
- check_output_includes '@bla = "blabla"', '@foo = "bar"'
196
- end
165
+ def test_info_file_breakpoints_shows_breakpoints_in_a_specific_file
166
+ enter 'break 38', 'break 39', "info file #{__FILE__} breakpoints"
167
+ debug_proc(@example)
168
+ check_output_includes(
169
+ /Created breakpoint \d+ at #{__FILE__}:38/,
170
+ /Created breakpoint \d+ at #{__FILE__}:39/,
171
+ filename,
172
+ 'breakpoint line numbers:', breakpoint_line_numbers)
173
+ check_output_doesnt_include lines, mtime, sha1
197
174
  end
198
175
 
199
- describe 'Line info' do
200
- it 'must show the current line' do
201
- enter 'break 11', 'cont', 'info line'
202
- debug_proc(@example)
203
- check_output_includes "Line 11 of \"#{__FILE__}\""
204
- end
176
+ def test_info_file_all_shows_all_available_info_about_a_specific_file
177
+ enter "info file #{__FILE__} all"
178
+ debug_proc(@example)
179
+ check_output_includes \
180
+ filename, lines, breakpoint_line_numbers, mtime, sha1
205
181
  end
206
182
 
207
- describe 'Locals info' do
208
- temporary_change_hash Byebug::Setting, :width, 28
183
+ def test_info_file_does_not_show_any_info_if_parameter_is_invalid
184
+ enter "info file #{__FILE__} blabla"
185
+ debug_proc(@example)
186
+ check_error_includes 'Invalid parameter blabla'
187
+ end
209
188
 
210
- it 'must show the current local variables' do
211
- enter 'break 11', 'cont', 'info locals'
212
- debug_proc(@example)
213
- check_output_includes 'w = "11111111111111111111...', 'x = 2'
214
- end
189
+ def test_info_instance_variables_shows_instance_variables
190
+ enter 'break 11', 'cont', 'info instance_variables'
191
+ debug_proc(@example)
192
+ check_output_includes '@bla = "blabla"', '@foo = "bar"'
193
+ end
215
194
 
216
- it 'must fail if local variable doesn\'t respond to #to_s or to #inspect' do
217
- enter 'break 16', 'cont', 'info locals'
218
- debug_proc(@example)
219
- check_output_includes 'a = *Error in evaluation*'
220
- end
195
+ def test_info_line_shows_info_about_the_current_line
196
+ enter 'break 11', 'cont', 'info line'
197
+ debug_proc(@example)
198
+ check_output_includes "Line 11 of \"#{__FILE__}\""
221
199
  end
222
200
 
223
- describe 'Program info' do
224
- it 'must show the initial stop reason' do
225
- enter 'info program'
226
- debug_proc(@example)
227
- check_output_includes \
228
- "It stopped after stepping, next'ing or initial start."
229
- end
201
+ def test_info_locals_shows_info_about_the_current_local_variables
202
+ enter 'break 11', 'cont', 'set width 28', 'info locals'
203
+ debug_proc(@example)
204
+ check_output_includes 'w = "11111111111111111111...', 'x = 2'
205
+ end
230
206
 
231
- it 'must show the step stop reason' do
232
- enter 'step', 'info program'
233
- debug_proc(@example)
234
- check_output_includes \
235
- 'Program stopped.',
236
- "It stopped after stepping, next'ing or initial start."
237
- end
207
+ def test_info_locals_fail_if_local_variable_does_not_have_to_s_or_inspect
208
+ enter 'break 16', 'cont', 'info locals'
209
+ debug_proc(@example)
210
+ check_output_includes 'a = *Error in evaluation*'
211
+ end
238
212
 
239
- it 'must show the breakpoint stop reason' do
240
- enter 'break 38', 'cont', 'info program'
241
- debug_proc(@example)
242
- check_output_includes 'Program stopped.', 'It stopped at a breakpoint.'
243
- end
213
+ def test_info_program_shows_the_initial_stop_reason
214
+ enter 'info program'
215
+ debug_proc(@example)
216
+ check_output_includes \
217
+ "It stopped after stepping, next'ing or initial start."
218
+ end
244
219
 
245
- it 'must show the catchpoint stop reason' do
246
- enter 'catch Exception', 'cont', 'info program'
247
- debug_proc(@example)
248
- check_output_includes 'Program stopped.', 'It stopped at a catchpoint.'
249
- end
220
+ def test_info_program_shows_the_step_stop_reason
221
+ enter 'step', 'info program'
222
+ debug_proc(@example)
223
+ check_output_includes \
224
+ 'Program stopped.',
225
+ "It stopped after stepping, next'ing or initial start."
226
+ end
250
227
 
251
- it 'must show the unknown stop reason' do
252
- enter 'break 39', 'cont',
253
- ->{ context.stubs(:stop_reason).returns('blabla'); 'info program' }
254
- debug_proc(@example)
255
- check_output_includes 'Program stopped.', 'unknown reason: blabla'
256
- end
228
+ def test_info_program_shows_the_breakpoint_stop_reason
229
+ enter 'break 38', 'cont', 'info program'
230
+ debug_proc(@example)
231
+ check_output_includes 'Program stopped.', 'It stopped at a breakpoint.'
232
+ end
257
233
 
258
- it 'must show an error if the program is crashed' do
259
- skip('TODO')
260
- end
234
+ def test_info_program_shows_the_catchpoint_stop_reason
235
+ enter 'catch Exception', 'cont', 'info program'
236
+ debug_proc(@example)
237
+ check_output_includes 'Program stopped.', 'It stopped at a catchpoint.'
261
238
  end
262
239
 
263
- describe 'Stack info' do
264
- it 'must show stack info' do
265
- file = __FILE__
266
- enter 'set fullpath', 'break 9', 'cont', 'info stack'
267
- debug_proc(@example)
268
- check_output_includes(
269
- /--> #0 InfoTest::Example.a\(y#String, z#String\)\s+at #{file}:9/,
270
- /#1 InfoTest::Example.b\s+at #{file}:20/,
271
- /#2 block \(2 levels\) in <class:InfoTestCase>\s+at #{file}:38/)
272
- end
240
+ def test_info_program_shows_the_unknown_stop_reason
241
+ enter 'break 39', 'cont',
242
+ ->{ context.stubs(:stop_reason).returns('blabla'); 'info program' }
243
+ debug_proc(@example)
244
+ check_output_includes 'Program stopped.', 'unknown reason: blabla'
273
245
  end
274
246
 
275
- describe 'Global Variables info' do
276
- it 'must show global variables' do
277
- enter 'info global_variables'
278
- debug_proc(@example)
279
- check_output_includes "$$ = #{Process.pid}"
280
- end
247
+ def test_shows_an_error_if_the_program_is_crashed
248
+ skip('TODO')
281
249
  end
282
250
 
283
- describe 'Variables info' do
284
- temporary_change_hash Byebug::Setting, :width, 30
251
+ def test_info_global_variables_shows_global_variables
252
+ enter 'info global_variables'
253
+ debug_proc(@example)
254
+ check_output_includes "$$ = #{Process.pid}"
255
+ end
285
256
 
286
- it 'must show all variables' do
287
- enter 'break 11', 'cont', 'info variables'
288
- debug_proc(@example)
289
- check_output_includes(/self = #<InfoTest::Example:\S*.../,
290
- 'w = "1111111111111111111111...',
291
- 'x = 2',
292
- '@bla = "blabla"',
293
- '@foo = "bar"')
294
- end
257
+ def test_info_variables_shows_all_variables
258
+ enter 'break 11', 'cont', 'set width 45', 'info variables'
259
+ debug_proc(@example)
260
+ check_output_includes(/self = #<Byebug::InfoExample:\S*.../,
261
+ 'w = "1111111111111111111111111111111111111...',
262
+ 'x = 2',
263
+ '@bla = "blabla"',
264
+ '@foo = "bar"')
265
+ end
295
266
 
296
- it 'must fail if the variable doesn\'t respond to #to_s or to #inspect' do
297
- enter 'break 16', 'cont', 'info variables'
298
- debug_proc(@example)
299
- check_output_includes 'a = *Error in evaluation*',
300
- /self = #<InfoTest::Example:\S*.../,
301
- '@bla = "blabla"',
302
- '@foo = "bar"'
303
- end
267
+ def test_info_variables_fails_if_variables_has_no_to_s_or_inspect_methods
268
+ enter 'break 16', 'cont', 'info variables'
269
+ debug_proc(@example)
270
+ check_output_includes 'a = *Error in evaluation*',
271
+ /self = #<Byebug::InfoExample:\S*.../,
272
+ '@bla = "blabla"',
273
+ '@foo = "bar"'
274
+ end
304
275
 
305
- it 'must correctly print variables containing % sign' do
306
- enter 'break 22', 'cont', 'info variables'
307
- debug_proc(@example)
308
- check_output_includes 'e = "%.2f"'
309
- end
276
+ def test_info_variables_correctly_print_variables_containing_percentage
277
+ enter 'break 22', 'cont', 'info variables'
278
+ debug_proc(@example)
279
+ check_output_includes 'e = "%.2f"'
310
280
  end
311
281
 
312
- describe 'Help' do
313
- it 'must show help when typing just "info"' do
314
- enter 'info', 'cont'
315
- debug_proc(@example)
316
- check_output_includes(/List of "info" subcommands:/)
317
- end
282
+ def test_shows_help_when_typing_just_info
283
+ enter 'info', 'cont'
284
+ debug_proc(@example)
285
+ check_output_includes(/List of "info" subcommands:/)
318
286
  end
319
287
  end
320
288
  end