byebug 1.0.2 → 1.0.3

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +1 -1
  4. data/bin/byebug +1 -2
  5. data/byebug.gemspec +1 -1
  6. data/ext/byebug/byebug.c +50 -35
  7. data/ext/byebug/context.c +99 -45
  8. data/lib/byebug.rb +5 -10
  9. data/lib/byebug/command.rb +20 -12
  10. data/lib/byebug/commands/breakpoints.rb +1 -1
  11. data/lib/byebug/commands/control.rb +14 -21
  12. data/lib/byebug/commands/display.rb +4 -4
  13. data/lib/byebug/commands/enable.rb +20 -19
  14. data/lib/byebug/commands/eval.rb +1 -1
  15. data/lib/byebug/commands/finish.rb +4 -5
  16. data/lib/byebug/commands/info.rb +118 -116
  17. data/lib/byebug/commands/list.rb +72 -48
  18. data/lib/byebug/commands/reload.rb +4 -3
  19. data/lib/byebug/commands/set.rb +7 -16
  20. data/lib/byebug/commands/show.rb +2 -2
  21. data/lib/byebug/commands/threads.rb +7 -6
  22. data/lib/byebug/context.rb +10 -2
  23. data/lib/byebug/helper.rb +3 -3
  24. data/lib/byebug/processor.rb +1 -1
  25. data/lib/byebug/version.rb +1 -1
  26. data/old_doc/byebug.texi +45 -51
  27. data/test/breakpoints_test.rb +180 -195
  28. data/test/display_test.rb +59 -53
  29. data/test/eval_test.rb +0 -2
  30. data/test/examples/info.rb +5 -5
  31. data/test/examples/info_threads.rb +1 -1
  32. data/test/finish_test.rb +16 -15
  33. data/test/info_test.rb +9 -10
  34. data/test/irb_test.rb +64 -65
  35. data/test/list_test.rb +76 -50
  36. data/test/method_test.rb +10 -5
  37. data/test/post_mortem_test.rb +27 -25
  38. data/test/reload_test.rb +31 -31
  39. data/test/restart_test.rb +106 -110
  40. data/test/show_test.rb +8 -16
  41. data/test/stepping_test.rb +4 -2
  42. data/test/support/test_dsl.rb +37 -76
  43. data/test/test_helper.rb +0 -1
  44. data/test/variables_test.rb +9 -12
  45. metadata +4 -4
@@ -1,167 +1,192 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe "List Command" do
3
+ describe 'List Command' do
4
4
  include TestDsl
5
5
 
6
- describe "List Command Setup" do
6
+ describe 'List Command (Setup)' do
7
+
7
8
  before { LineCache.clear_file_cache }
8
- after { LineCache.clear_file_cache }
9
9
 
10
- describe "listsize" do
11
- before { Byebug::Command.settings[:listsize] = 3 }
10
+ describe 'listsize' do
11
+ before do
12
+ Byebug::Command.settings[:listsize] = 3
13
+ Byebug::Command.settings[:autolist] = 0
14
+ end
12
15
 
13
- it "must show lines according to :listsize setting" do
16
+ it 'must show lines according to :listsize setting' do
14
17
  enter 'set listsize 4', 'break 5', 'cont', 'list'
15
18
  debug_file 'list'
16
19
  check_output_includes "[3, 6] in #{fullpath('list')}"
17
20
  end
18
21
 
19
- it "must not set it if the param is not an integer" do
22
+ it 'must not set it if the param is not an integer' do
20
23
  enter 'set listsize 4.0', 'break 5', 'cont', 'list'
21
24
  debug_file 'list'
22
25
  check_output_includes "[4, 6] in #{fullpath('list')}"
23
26
  end
27
+
28
+ it 'must move range up when it goes before begining of file' do
29
+ enter 'set listsize 10', 'break 3', 'cont', 'list'
30
+ debug_file 'list'
31
+ check_output_includes "[1, 10] in #{fullpath('list')}"
32
+ end
33
+
34
+ it 'must move range down when it goes after end of file' do
35
+ enter 'set listsize 10', 'break 10', 'cont', 'list'
36
+ debug_file 'list'
37
+ check_output_includes "[3, 12] in #{fullpath('list')}"
38
+ end
39
+
40
+ it 'must list whole file if number of lines is smaller than listsize' do
41
+ enter 'set listsize 13', 'list'
42
+ debug_file 'list'
43
+ check_output_includes "[1, 12] in #{fullpath('list')}"
44
+ end
45
+
24
46
  end
25
47
 
26
- describe "without arguments" do
48
+ describe 'without arguments' do
27
49
  before { Byebug::Command.settings[:listsize] = 3 }
28
50
 
29
- it "must show surrounding lines with the first call" do
51
+ it 'must show surrounding lines with the first call' do
30
52
  enter 'break 5', 'cont', 'list'
31
53
  debug_file 'list'
32
54
  check_output_includes \
33
- "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
55
+ "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
34
56
  end
35
57
 
36
- it "must list forward after second call" do
58
+ it 'must list forward after second call' do
37
59
  enter 'break 5', 'cont', 'list', 'list'
38
60
  debug_file 'list'
39
61
  check_output_includes \
40
- "[7, 9] in #{fullpath('list')}", "7 7", "8 8", "9 9"
62
+ "[7, 9] in #{fullpath('list')}", '7 7', '8 8', '9 9'
41
63
  end
42
64
  end
43
65
 
44
- describe "list backward" do
66
+ describe 'list backward' do
45
67
  before { Byebug::Command.settings[:listsize] = 3 }
46
68
 
47
- it "must show surrounding lines with the first call" do
69
+ it 'must show surrounding lines with the first call' do
48
70
  enter 'break 5', 'cont', 'list -'
49
71
  debug_file 'list'
50
72
  check_output_includes \
51
- "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
73
+ "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
52
74
  end
53
75
 
54
- it "must list backward after second call" do
76
+ it 'must list backward after second call' do
55
77
  enter 'break 5', 'cont', 'list -', 'list -'
56
78
  debug_file 'list'
57
79
  check_output_includes \
58
- "[1, 3] in #{fullpath('list')}", "1 byebug", "2 2", "3 3"
80
+ "[1, 3] in #{fullpath('list')}", '1 byebug', '2 2', '3 3'
59
81
  end
60
82
  end
61
83
 
62
84
 
63
- describe "list surrounding" do
85
+ describe 'list surrounding' do
64
86
  before { Byebug::Command.settings[:listsize] = 3 }
65
87
 
66
- it "must show the surrounding lines with =" do
88
+ it 'must show the surrounding lines with =' do
67
89
  enter 'break 5', 'cont', 'list ='
68
90
  debug_file 'list'
69
91
  check_output_includes \
70
- "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
92
+ "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
71
93
  end
72
94
  end
73
95
 
74
- describe "autolist" do
96
+ describe 'autolist' do
75
97
  before { Byebug::Command.settings[:listsize] = 3 }
76
98
 
77
- it "must show the surronding lines even without 'list' command if autolist is enabled" do
99
+ it 'must show the surronding lines after stop if autolist is enabled' do
78
100
  enter 'set autolist', 'break 5', 'cont'
79
101
  debug_file 'list'
80
102
  check_output_includes \
81
- "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
103
+ "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
82
104
  end
83
105
  end
84
106
 
85
- describe "specified lines" do
107
+ describe 'specified lines' do
86
108
  before { Byebug::Command.settings[:listsize] = 3 }
87
109
 
88
- it "must show with mm-nn" do
110
+ it 'must show with mm-nn' do
89
111
  enter 'list 4-6'
90
112
  debug_file 'list'
91
113
  check_output_includes \
92
- "[4, 6] in #{fullpath('list')}", "4 4", "5 5", "6 6"
114
+ "[4, 6] in #{fullpath('list')}", '4 4', '5 5', '6 6'
93
115
  end
94
116
 
95
- it "must show with mm,nn" do
117
+ it 'must show with mm,nn' do
96
118
  enter 'list 4,6'
97
119
  debug_file 'list'
98
120
  check_output_includes \
99
- "[4, 6] in #{fullpath('list')}", "4 4", "5 5", "6 6"
121
+ "[4, 6] in #{fullpath('list')}", '4 4', '5 5', '6 6'
100
122
  end
101
123
 
102
- it "must show surroundings with mm-" do
124
+ it 'must show surroundings with mm-' do
103
125
  enter 'list 4-'
104
126
  debug_file 'list'
105
127
  check_output_includes \
106
- "[3, 5] in #{fullpath('list')}", "3 3", "4 4", "5 5"
128
+ "[3, 5] in #{fullpath('list')}", '3 3', '4 4', '5 5'
107
129
  end
108
130
 
109
- it "must show surroundings with mm," do
131
+ it 'must show surroundings with mm,' do
110
132
  enter 'list 4,'
111
133
  debug_file 'list'
112
134
  check_output_includes \
113
- "[3, 5] in #{fullpath('list')}", "3 3", "4 4", "5 5"
135
+ "[3, 5] in #{fullpath('list')}", '3 3', '4 4', '5 5'
114
136
  end
115
137
 
116
- it "must show nothing if there is no such lines" do
138
+ it 'must show nothing if there is no such lines' do
117
139
  enter 'list 44,44'
118
140
  debug_file 'list'
119
- check_output_includes "[44, 44] in #{fullpath('list')}"
141
+ check_error_includes 'Invalid line range'
142
+ check_output_doesnt_include "[44, 44] in #{fullpath('list')}"
120
143
  check_output_doesnt_include /^44 \S/
121
144
  end
122
145
 
123
- it "must show nothing if range is incorrect" do
146
+ it 'must show nothing if range is incorrect' do
124
147
  enter 'list 5,4'
125
148
  debug_file 'list'
126
149
  check_output_includes "[5, 4] in #{fullpath('list')}"
127
- check_output_doesnt_include "5 5"
128
- check_output_doesnt_include "4 4"
150
+ check_output_doesnt_include '5 5'
151
+ check_output_doesnt_include '4 4'
129
152
  end
130
153
  end
131
154
 
132
- describe "reload source" do
133
- before { Byebug::Command.settings[:reload_source_on_change] = false }
134
- after { change_line_in_file(fullpath('list'), 4, '4') }
155
+ describe 'reload source' do
156
+ after do
157
+ change_line_in_file(fullpath('list'), 4, '4')
158
+ Byebug::Command.settings[:reload_source_on_change] = true
159
+ end
135
160
 
136
- it "must not reload if setting is false" do
161
+ it 'must not reload if setting is false' do
137
162
  enter 'set noautoreload', -> do
138
163
  change_line_in_file(fullpath('list'), 4, '100')
139
164
  'list 4-4'
140
165
  end
141
166
  debug_file 'list'
142
- check_output_includes "4 4"
167
+ check_output_includes '4 4'
143
168
  end
144
169
 
145
- it "must reload if setting is true" do
170
+ it 'must reload if setting is true' do
146
171
  enter 'set autoreload', -> do
147
172
  change_line_in_file(fullpath('list'), 4, '100')
148
173
  'list 4-4'
149
174
  end
150
175
  debug_file 'list'
151
- check_output_includes "4 100"
176
+ check_output_includes '4 100'
152
177
  end
153
178
  end
154
179
 
155
- it "must show an error when there is no such file" do
156
- enter ->{state.file = "blabla"; 'list 4-4'}
180
+ it 'must show an error when there is no such file' do
181
+ enter ->{state.file = 'blabla'; 'list 4-4'}
157
182
  debug_file 'list'
158
- check_output_includes "No sourcefile available for blabla",
183
+ check_output_includes 'No sourcefile available for blabla',
159
184
  interface.error_queue
160
185
  end
161
186
 
162
- describe "Post Mortem" do
163
- it "must work in post-mortem mode" do
164
- skip("No post morten mode for now")
187
+ describe 'Post Mortem' do
188
+ it 'must work in post-mortem mode' do
189
+ skip('No post morten mode for now')
165
190
  enter 'cont', 'list'
166
191
  debug_file 'post_mortem'
167
192
  check_output_includes "[7, 9] in #{fullpath('post_mortem')}"
@@ -169,4 +194,5 @@ describe "List Command" do
169
194
  end
170
195
 
171
196
  end
197
+
172
198
  end
@@ -3,8 +3,13 @@ require_relative 'test_helper'
3
3
  describe "Method Command" do
4
4
  include TestDsl
5
5
 
6
- # TODO: Need to write tests for 'method signature' command, but I can't install the 'ruby-internal' gem
7
- # on my machine, it fails to build gem native extension.
6
+ # TODO: Need to write tests for 'method signature' command, but I can't
7
+ # install the 'ruby-internal' gem on my machine, it fails to build gem native
8
+ # extension.
9
+
10
+ def after_setup
11
+ Byebug::Command.settings[:autolist] = 0
12
+ end
8
13
 
9
14
  describe "show instance method of a class" do
10
15
  it "must show using full command name" do
@@ -61,9 +66,9 @@ describe "Method Command" do
61
66
  describe "Post Mortem" do
62
67
  it "must work in post-mortem mode" do
63
68
  skip("No post morten mode for now")
64
- #enter 'cont', 'm i self'
65
- #debug_file 'post_mortem'
66
- #check_output_includes /to_s/
69
+ enter 'cont', 'm i self'
70
+ debug_file 'post_mortem'
71
+ check_output_includes /to_s/
67
72
  end
68
73
  end
69
74
 
@@ -1,27 +1,29 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- # XXX: No post morten mode for now
4
- #
5
- #describe "Post Mortem" do
6
- # include TestDsl
7
- #
8
- # it "must enter into port mortem mode" do
9
- # enter 'cont'
10
- # debug_file("post_mortem") { Byebug.post_mortem?.must_equal true }
11
- # end
12
- #
13
- # it "must stop at the correct line" do
14
- # enter 'cont'
15
- # debug_file("post_mortem") { state.line.must_equal 8 }
16
- # end
17
- #
18
- # it "must exit from post mortem mode after stepping command" do
19
- # enter 'cont', 'break 12', 'cont'
20
- # debug_file("post_mortem") { Byebug.post_mortem?.must_equal false }
21
- # end
22
- #
23
- # it "must save the raised exception" do
24
- # enter 'cont'
25
- # debug_file("post_mortem") { Byebug.last_exception.must_be_kind_of RuntimeError }
26
- # end
27
- #end
3
+ describe 'Post Mortem' do
4
+ include TestDsl
5
+
6
+ it 'must enter into post mortem mode' do
7
+ skip('No post morten mode for now')
8
+ enter 'cont'
9
+ debug_file('post_mortem') { Byebug.post_mortem?.must_equal true }
10
+ end
11
+
12
+ it 'must stop at the correct line' do
13
+ skip('No post morten mode for now')
14
+ enter 'cont'
15
+ debug_file('post_mortem') { state.line.must_equal 8 }
16
+ end
17
+
18
+ it 'must exit from post mortem mode after stepping command' do
19
+ skip('No post morten mode for now')
20
+ enter 'cont', 'break 12', 'cont'
21
+ debug_file('post_mortem') { Byebug.post_mortem?.must_equal false }
22
+ end
23
+
24
+ it 'must save the raised exception' do
25
+ skip('No post morten mode for now')
26
+ enter 'cont'
27
+ debug_file('post_mortem') { Byebug.last_exception.must_be_kind_of RuntimeError }
28
+ end
29
+ end
@@ -1,49 +1,49 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe "Reload Command" do
3
+ describe 'Reload Command' do
4
4
  include TestDsl
5
5
 
6
- describe "Reload Command (Setup)" do
6
+ describe 'autoreloading' do
7
+ after { Byebug::Command.settings[:reload_source_on_change] = true }
7
8
 
8
- before { Byebug::Command.settings[:reload_source_on_change] = false }
9
-
10
- it "must notify that automatic reloading is off" do
9
+ it 'must notify that automatic reloading is on by default' do
11
10
  enter 'reload'
12
11
  debug_file 'reload'
13
- check_output_includes "Source code is reloaded. Automatic reloading is off."
12
+ check_output_includes \
13
+ 'Source code is reloaded. Automatic reloading is on.'
14
14
  end
15
15
 
16
- it "must notify that automatic reloading is on" do
17
- enter 'set autoreload', 'reload'
16
+ it 'must notify that automatic reloading is off if setting changed' do
17
+ enter 'set noautoreload', 'reload'
18
18
  debug_file 'reload'
19
- check_output_includes "Source code is reloaded. Automatic reloading is on."
19
+ check_output_includes \
20
+ 'Source code is reloaded. Automatic reloading is off.'
20
21
  end
22
+ end
21
23
 
22
- describe "reloading" do
23
- after { change_line_in_file(fullpath('reload'), 4, '4') }
24
- it "must reload the code" do
25
- enter 'break 3', 'cont', 'l 4-4', -> do
26
- change_line_in_file(fullpath('reload'), 4, '100')
27
- 'reload'
28
- end, 'l 4-4'
29
- debug_file 'reload'
30
- check_output_includes "4 100"
31
- end
24
+ describe 'reloading' do
25
+ after { change_line_in_file(fullpath('reload'), 4, '4') }
26
+ it 'must reload the code' do
27
+ enter 'break 3', 'cont', 'l 4-4', -> do
28
+ change_line_in_file(fullpath('reload'), 4, '100')
29
+ 'reload'
30
+ end, 'l 4-4'
31
+ debug_file 'reload'
32
+ check_output_includes '4 100'
32
33
  end
34
+ end
33
35
 
34
- describe "Post Mortem" do
35
- after { change_line_in_file(fullpath('post_mortem'), 7, ' z = 4') }
36
- it "must work in post-mortem mode" do
37
- skip("No post morten mode for now")
38
- enter 'cont', -> do
39
- change_line_in_file(fullpath('post_mortem'), 7, 'z = 100')
40
- 'reload'
41
- end, 'l 7-7'
42
- debug_file 'post_mortem'
43
- check_output_includes "7 z = 100"
44
- end
36
+ describe 'Post Mortem' do
37
+ after { change_line_in_file(fullpath('post_mortem'), 7, ' z = 4') }
38
+ it 'must work in post-mortem mode' do
39
+ skip('No post morten mode for now')
40
+ enter 'cont', -> do
41
+ change_line_in_file(fullpath('post_mortem'), 7, 'z = 100')
42
+ 'reload'
43
+ end, 'l 7-7'
44
+ debug_file 'post_mortem'
45
+ check_output_includes '7 z = 100'
45
46
  end
46
-
47
47
  end
48
48
 
49
49
  end
@@ -1,6 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe "Restart Command (test setup)" do
3
+ describe 'Restart Command' do
4
4
  include TestDsl
5
5
 
6
6
  def must_restart
@@ -8,150 +8,146 @@ describe "Restart Command (test setup)" do
8
8
  Byebug::RestartCommand.any_instance.expects(:exec)
9
9
  end
10
10
 
11
- describe "Restart Command" do
12
-
11
+ describe 'usual restarting' do
13
12
  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", 'byebug_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
27
-
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)
13
+ force_set_const Byebug, 'BYEBUG_SCRIPT', 'byebug_script'
33
14
  end
34
15
 
35
- it "must be restarted with arguments" do
16
+ it 'must be restarted with arguments' do
36
17
  Byebug::RestartCommand.any_instance.expects(:exec).
37
- with("#{Byebug::RDEBUG_SCRIPT} test/examples/restart.rb 1 2 3")
18
+ with("#{Byebug::BYEBUG_SCRIPT} 1 2 3")
38
19
  enter 'restart 1 2 3'
39
- debug_file('restart')
20
+ debug_file 'restart'
40
21
  end
41
22
 
42
- it "must be restarted without arguments" do
43
- Byebug::RestartCommand.
44
- any_instance.expects(:exec).with("#{Byebug::RDEBUG_SCRIPT} argv")
23
+ it 'arguments must be correctly escaped' do
24
+ Byebug::Command.settings[:argv] = ['argv1', 'argv 2']
25
+ Byebug::RestartCommand.any_instance.expects(:exec).with \
26
+ "#{Byebug::BYEBUG_SCRIPT} argv1 argv\\ 2"
45
27
  enter 'restart'
46
- debug_file('restart')
28
+ debug_file 'restart'
47
29
  end
48
30
 
49
- it "must specify arguments by 'set' command" do
50
- temporary_change_hash_value(Byebug::Command.settings, :argv, []) do
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')
55
- end
31
+ it 'must specify arguments by "set" command' do
32
+ Byebug::Command.settings[:argv] = []
33
+ Byebug::RestartCommand.any_instance.expects(:exec).
34
+ with("#{Byebug::BYEBUG_SCRIPT} 1 2 3")
35
+ enter 'set args 1 2 3', 'restart'
36
+ debug_file 'restart'
56
37
  end
38
+ end
57
39
 
58
- describe "messaging" do
59
- before { enter 'restart' }
40
+ describe 'messaging' do
41
+ before { enter 'restart' }
60
42
 
61
- describe "reexecing" do
62
- it "must restart and show a message about reexecing" do
63
- must_restart
64
- debug_file('restart')
65
- check_output_includes "Re exec'ing:\n\t#{Byebug::RDEBUG_SCRIPT}" \
66
- " argv"
67
- end
43
+ describe 'reexecing' do
44
+ it 'must restart and show a message about reexecing' do
45
+ force_set_const Byebug, 'BYEBUG_SCRIPT', 'byebug_script'
46
+ Byebug::Command.settings[:argv] = ['argv']
47
+ must_restart
48
+ debug_file 'restart'
49
+ check_output_includes \
50
+ "Re exec'ing:\n\t#{Byebug::BYEBUG_SCRIPT} argv"
68
51
  end
52
+ end
69
53
 
70
- describe "no script is specified and don't use $0" do
71
- before do
72
- set_tmp_const(Byebug, "PROG_SCRIPT", :__undefined__)
73
- set_tmp_const(Byebug, "DEFAULT_START_SETTINGS",
74
- init: false, post_mortem: false, tracing: nil)
75
- end
76
- after do
77
- restore_tmp_const(Byebug, "PROG_SCRIPT")
78
- restore_tmp_const(Byebug, "DEFAULT_START_SETTINGS")
79
- end
80
-
81
- it "must not restart and show error messages instead" do
82
- must_restart.never
83
- debug_file('restart')
84
- check_output_includes "Don't know name of debugged program", interface.error_queue
85
- end
54
+ describe 'no script specified and no $0 used instead' do
55
+ before do
56
+ force_unset_const Byebug, 'PROG_SCRIPT'
57
+ force_set_const Byebug,
58
+ 'DEFAULT_START_SETTINGS',
59
+ init: false, post_mortem: false, tracing: nil
86
60
  end
87
61
 
88
- it "must use prog_script from $0 if PROG_SCRIPT is undefined" do
89
- $0 = 'prog-0'
90
- Byebug.send(:remove_const, "PROG_SCRIPT")
91
- force_set_const(Byebug, "DEFAULT_START_SETTINGS", init: true, post_mortem: false, tracing: nil)
92
- debug_file('restart')
93
- check_output_includes "Ruby program prog-0 doesn't exist", interface.error_queue
62
+ it 'must not restart and show error messages instead' do
63
+ must_restart.never
64
+ debug_file 'restart'
65
+ check_output_includes 'Don\'t know name of debugged program',
66
+ interface.error_queue
94
67
  end
68
+ end
95
69
 
96
- describe "no script at the specified path" do
97
- before { force_set_const(Byebug, "PROG_SCRIPT", 'blabla') }
98
-
99
- it "must not restart" do
100
- must_restart.never
101
- debug_file('restart')
102
- end
103
-
104
- it "must show an error message" do
105
- debug_file('restart')
106
- check_output_includes "Ruby program blabla doesn't exist", interface.error_queue
107
- end
70
+ describe 'no script specified, $0 used instead' do
71
+ before do
72
+ @old_prog_name = $0
73
+ $0 = 'prog-0'
74
+ force_unset_const Byebug, 'PROG_SCRIPT'
108
75
  end
76
+ after { $0 = @old_prog_name }
109
77
 
110
- describe "byebug runner script is not specified" do
78
+ it 'must use prog_script from $0 if PROG_SCRIPT is undefined' do
79
+ debug_file 'restart'
80
+ check_output_includes 'Ruby program prog-0 doesn\'t exist',
81
+ interface.error_queue
82
+ end
83
+ end
111
84
 
112
- before { set_tmp_const(Byebug, "RDEBUG_SCRIPT", :__undefined__) }
113
- after { restore_tmp_const(Byebug, "RDEBUG_SCRIPT") }
85
+ describe 'no script at the specified path' do
86
+ before do
87
+ force_set_const Byebug, 'PROG_SCRIPT', 'blabla'
88
+ force_set_const Byebug,
89
+ 'DEFAULT_START_SETTINGS',
90
+ init: false, post_mortem: false, tracing: nil
91
+ end
114
92
 
115
- it "must restart anyway" do
116
- must_restart
117
- debug_file('restart')
118
- end
93
+ it 'must not restart' do
94
+ must_restart.never
95
+ debug_file 'restart'
96
+ end
119
97
 
120
- it "must show a warning message" do
121
- debug_file('restart')
122
- check_output_includes "Byebug was not called from the outset..."
123
- end
98
+ it 'must show an error message' do
99
+ debug_file 'restart'
100
+ check_output_includes 'Ruby program blabla doesn\'t exist',
101
+ interface.error_queue
102
+ end
103
+ end
124
104
 
125
- it "must show a warning message when prog script is not executable" do
126
- debug_file('restart')
127
- check_output_includes "Ruby program #{Byebug::PROG_SCRIPT} not " \
128
- "executable... We'll add a call to Ruby."
129
- end
105
+ describe 'byebug runner script is not specified' do
106
+ before do
107
+ must_restart
130
108
  end
131
109
 
132
- describe "when can't change the dir to INITIAL_DIR" do
133
- before { force_set_const(Byebug, "INITIAL_DIR", "unexisted/path") }
110
+ it 'must restart anyway' do
111
+ debug_file 'restart'
112
+ end
134
113
 
135
- it "must restart anyway" do
136
- must_restart
137
- debug_file('restart')
138
- end
114
+ it 'must show a warning message' do
115
+ debug_file 'restart'
116
+ check_output_includes 'Byebug was not called from the outset...'
117
+ end
139
118
 
140
- it "must show an error message " do
141
- debug_file('restart')
142
- check_output_includes "Failed to change initial directory unexisted/path"
143
- end
119
+ it 'must show a warning message when prog script is not executable' do
120
+ debug_file 'restart'
121
+ check_output_includes "Ruby program #{Byebug::PROG_SCRIPT} not " \
122
+ "executable... We'll add a call to Ruby."
144
123
  end
145
124
  end
146
125
 
147
- describe "Post Mortem" do
148
- it "must work in post-mortem mode" do
149
- skip("No post morten mode for now")
126
+ describe 'when can\'t change the dir to INITIAL_DIR' do
127
+ before do
128
+ force_set_const(Byebug, 'INITIAL_DIR', '/unexistent/path')
150
129
  must_restart
151
- enter 'cont', 'restart'
152
- debug_file 'post_mortem'
130
+ end
131
+
132
+ it 'must restart anyway' do
133
+ debug_file 'restart'
134
+ end
135
+
136
+ it 'must show an error message ' do
137
+ debug_file 'restart'
138
+ check_output_includes \
139
+ 'Failed to change initial directory /unexistent/path'
153
140
  end
154
141
  end
142
+ end
155
143
 
144
+ describe 'Post Mortem' do
145
+ it 'must work in post-mortem mode' do
146
+ skip('No post morten mode for now')
147
+ must_restart
148
+ enter 'cont', 'restart'
149
+ debug_file 'post_mortem'
150
+ end
156
151
  end
152
+
157
153
  end