pry 0.9.12.6-i386-mingw32 → 0.10.0-i386-mingw32

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 (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +37 -31
  5. data/lib/pry.rb +38 -151
  6. data/lib/pry/cli.rb +35 -17
  7. data/lib/pry/code.rb +19 -63
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +2 -1
  10. data/lib/pry/code/loc.rb +2 -2
  11. data/lib/pry/code_object.rb +40 -21
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +12 -9
  14. data/lib/pry/command_set.rb +81 -38
  15. data/lib/pry/commands.rb +1 -1
  16. data/lib/pry/commands/amend_line.rb +2 -2
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat.rb +11 -2
  19. data/lib/pry/commands/cat/exception_formatter.rb +6 -7
  20. data/lib/pry/commands/cat/file_formatter.rb +15 -32
  21. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  22. data/lib/pry/commands/cd.rb +14 -3
  23. data/lib/pry/commands/change_inspector.rb +27 -0
  24. data/lib/pry/commands/change_prompt.rb +26 -0
  25. data/lib/pry/commands/code_collector.rb +4 -4
  26. data/lib/pry/commands/easter_eggs.rb +3 -3
  27. data/lib/pry/commands/edit.rb +10 -22
  28. data/lib/pry/commands/edit/exception_patcher.rb +2 -2
  29. data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
  30. data/lib/pry/commands/exit_program.rb +0 -1
  31. data/lib/pry/commands/find_method.rb +16 -22
  32. data/lib/pry/commands/gem_install.rb +5 -2
  33. data/lib/pry/commands/gem_open.rb +1 -1
  34. data/lib/pry/commands/gist.rb +10 -11
  35. data/lib/pry/commands/help.rb +14 -14
  36. data/lib/pry/commands/hist.rb +27 -8
  37. data/lib/pry/commands/install_command.rb +14 -12
  38. data/lib/pry/commands/list_inspectors.rb +35 -0
  39. data/lib/pry/commands/list_prompts.rb +35 -0
  40. data/lib/pry/commands/ls.rb +72 -296
  41. data/lib/pry/commands/ls/constants.rb +47 -0
  42. data/lib/pry/commands/ls/formatter.rb +49 -0
  43. data/lib/pry/commands/ls/globals.rb +48 -0
  44. data/lib/pry/commands/ls/grep.rb +21 -0
  45. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  46. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  47. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  48. data/lib/pry/commands/ls/local_names.rb +35 -0
  49. data/lib/pry/commands/ls/local_vars.rb +39 -0
  50. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  51. data/lib/pry/commands/ls/methods.rb +57 -0
  52. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  53. data/lib/pry/commands/ls/self_methods.rb +32 -0
  54. data/lib/pry/commands/play.rb +44 -10
  55. data/lib/pry/commands/pry_backtrace.rb +1 -2
  56. data/lib/pry/commands/raise_up.rb +2 -2
  57. data/lib/pry/commands/reload_code.rb +16 -19
  58. data/lib/pry/commands/ri.rb +7 -3
  59. data/lib/pry/commands/shell_command.rb +18 -13
  60. data/lib/pry/commands/shell_mode.rb +2 -4
  61. data/lib/pry/commands/show_doc.rb +5 -0
  62. data/lib/pry/commands/show_info.rb +8 -13
  63. data/lib/pry/commands/show_source.rb +15 -3
  64. data/lib/pry/commands/simple_prompt.rb +1 -1
  65. data/lib/pry/commands/toggle_color.rb +8 -4
  66. data/lib/pry/commands/watch_expression.rb +105 -0
  67. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  68. data/lib/pry/commands/whereami.rb +18 -10
  69. data/lib/pry/commands/wtf.rb +3 -3
  70. data/lib/pry/config.rb +20 -254
  71. data/lib/pry/config/behavior.rb +139 -0
  72. data/lib/pry/config/convenience.rb +26 -0
  73. data/lib/pry/config/default.rb +165 -0
  74. data/lib/pry/core_extensions.rb +31 -21
  75. data/lib/pry/editor.rb +107 -103
  76. data/lib/pry/exceptions.rb +77 -0
  77. data/lib/pry/helpers/base_helpers.rb +22 -109
  78. data/lib/pry/helpers/command_helpers.rb +10 -8
  79. data/lib/pry/helpers/documentation_helpers.rb +1 -2
  80. data/lib/pry/helpers/text.rb +4 -5
  81. data/lib/pry/history.rb +46 -45
  82. data/lib/pry/history_array.rb +6 -1
  83. data/lib/pry/hooks.rb +9 -29
  84. data/lib/pry/indent.rb +6 -6
  85. data/lib/pry/input_completer.rb +242 -0
  86. data/lib/pry/input_lock.rb +132 -0
  87. data/lib/pry/inspector.rb +27 -0
  88. data/lib/pry/last_exception.rb +61 -0
  89. data/lib/pry/method.rb +82 -87
  90. data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
  91. data/lib/pry/module_candidate.rb +4 -14
  92. data/lib/pry/object_path.rb +82 -0
  93. data/lib/pry/output.rb +50 -0
  94. data/lib/pry/pager.rb +193 -48
  95. data/lib/pry/plugins.rb +1 -1
  96. data/lib/pry/prompt.rb +26 -0
  97. data/lib/pry/pry_class.rb +149 -230
  98. data/lib/pry/pry_instance.rb +302 -413
  99. data/lib/pry/rbx_path.rb +1 -1
  100. data/lib/pry/repl.rb +202 -0
  101. data/lib/pry/repl_file_loader.rb +20 -26
  102. data/lib/pry/rubygem.rb +13 -5
  103. data/lib/pry/terminal.rb +2 -1
  104. data/lib/pry/test/helper.rb +26 -41
  105. data/lib/pry/version.rb +1 -1
  106. data/lib/pry/wrapped_module.rb +45 -59
  107. metadata +62 -225
  108. data/.document +0 -2
  109. data/.gitignore +0 -16
  110. data/.travis.yml +0 -25
  111. data/.yardopts +0 -1
  112. data/CHANGELOG +0 -534
  113. data/CONTRIBUTORS +0 -55
  114. data/Gemfile +0 -12
  115. data/Rakefile +0 -140
  116. data/TODO +0 -117
  117. data/lib/pry/completion.rb +0 -321
  118. data/lib/pry/custom_completions.rb +0 -6
  119. data/lib/pry/rbx_method.rb +0 -13
  120. data/man/pry.1 +0 -195
  121. data/man/pry.1.html +0 -204
  122. data/man/pry.1.ronn +0 -141
  123. data/pry.gemspec +0 -29
  124. data/spec/Procfile +0 -3
  125. data/spec/cli_spec.rb +0 -78
  126. data/spec/code_object_spec.rb +0 -277
  127. data/spec/code_spec.rb +0 -219
  128. data/spec/command_helpers_spec.rb +0 -29
  129. data/spec/command_integration_spec.rb +0 -644
  130. data/spec/command_set_spec.rb +0 -627
  131. data/spec/command_spec.rb +0 -821
  132. data/spec/commands/amend_line_spec.rb +0 -247
  133. data/spec/commands/bang_spec.rb +0 -19
  134. data/spec/commands/cat_spec.rb +0 -164
  135. data/spec/commands/cd_spec.rb +0 -250
  136. data/spec/commands/disable_pry_spec.rb +0 -25
  137. data/spec/commands/edit_spec.rb +0 -727
  138. data/spec/commands/exit_all_spec.rb +0 -34
  139. data/spec/commands/exit_program_spec.rb +0 -19
  140. data/spec/commands/exit_spec.rb +0 -34
  141. data/spec/commands/find_method_spec.rb +0 -70
  142. data/spec/commands/gem_list_spec.rb +0 -26
  143. data/spec/commands/gist_spec.rb +0 -79
  144. data/spec/commands/help_spec.rb +0 -56
  145. data/spec/commands/hist_spec.rb +0 -181
  146. data/spec/commands/jump_to_spec.rb +0 -15
  147. data/spec/commands/ls_spec.rb +0 -181
  148. data/spec/commands/play_spec.rb +0 -140
  149. data/spec/commands/raise_up_spec.rb +0 -56
  150. data/spec/commands/save_file_spec.rb +0 -177
  151. data/spec/commands/show_doc_spec.rb +0 -510
  152. data/spec/commands/show_input_spec.rb +0 -17
  153. data/spec/commands/show_source_spec.rb +0 -782
  154. data/spec/commands/whereami_spec.rb +0 -203
  155. data/spec/completion_spec.rb +0 -241
  156. data/spec/control_d_handler_spec.rb +0 -58
  157. data/spec/documentation_helper_spec.rb +0 -73
  158. data/spec/editor_spec.rb +0 -79
  159. data/spec/exception_whitelist_spec.rb +0 -21
  160. data/spec/fixtures/candidate_helper1.rb +0 -11
  161. data/spec/fixtures/candidate_helper2.rb +0 -8
  162. data/spec/fixtures/example.erb +0 -5
  163. data/spec/fixtures/example_nesting.rb +0 -33
  164. data/spec/fixtures/show_source_doc_examples.rb +0 -15
  165. data/spec/fixtures/testrc +0 -2
  166. data/spec/fixtures/testrcbad +0 -2
  167. data/spec/fixtures/whereami_helper.rb +0 -6
  168. data/spec/helper.rb +0 -34
  169. data/spec/helpers/bacon.rb +0 -86
  170. data/spec/helpers/mock_pry.rb +0 -43
  171. data/spec/helpers/table_spec.rb +0 -105
  172. data/spec/history_array_spec.rb +0 -67
  173. data/spec/hooks_spec.rb +0 -522
  174. data/spec/indent_spec.rb +0 -301
  175. data/spec/input_stack_spec.rb +0 -90
  176. data/spec/method_spec.rb +0 -482
  177. data/spec/prompt_spec.rb +0 -60
  178. data/spec/pry_defaults_spec.rb +0 -419
  179. data/spec/pry_history_spec.rb +0 -99
  180. data/spec/pry_output_spec.rb +0 -95
  181. data/spec/pry_spec.rb +0 -515
  182. data/spec/run_command_spec.rb +0 -25
  183. data/spec/sticky_locals_spec.rb +0 -157
  184. data/spec/syntax_checking_spec.rb +0 -81
  185. data/spec/wrapped_module_spec.rb +0 -261
  186. data/wiki/Customizing-pry.md +0 -397
  187. data/wiki/Home.md +0 -4
@@ -1,247 +0,0 @@
1
- require 'helper'
2
-
3
- describe "amend-line" do
4
- before do
5
- @t = pry_tester
6
- end
7
-
8
- it 'should amend the last line of input when no line number specified' do
9
- eval_str = unindent(<<-STR)
10
- def hello
11
- puts :bing
12
- STR
13
-
14
- @t.process_command 'amend-line puts :blah', eval_str
15
-
16
- eval_str.should == unindent(<<-STR)
17
- def hello
18
- puts :blah
19
- STR
20
- end
21
-
22
- it 'should amend the specified line of input when line number given' do
23
- eval_str = unindent(<<-STR)
24
- def hello
25
- puts :bing
26
- puts :bang
27
- STR
28
-
29
- @t.process_command 'amend-line 1 def goodbye', eval_str
30
-
31
- eval_str.should == unindent(<<-STR)
32
- def goodbye
33
- puts :bing
34
- puts :bang
35
- STR
36
- end
37
-
38
- it 'should amend the first line of input when 0 given as line number' do
39
- eval_str = unindent(<<-STR)
40
- def hello
41
- puts :bing
42
- puts :bang
43
- STR
44
-
45
- @t.process_command 'amend-line 0 def goodbye', eval_str
46
-
47
- eval_str.should == unindent(<<-STR)
48
- def goodbye
49
- puts :bing
50
- puts :bang
51
- STR
52
- end
53
-
54
- it 'should amend a specified line when negative number given' do
55
- eval_str = unindent(<<-STR)
56
- def hello
57
- puts :bing
58
- puts :bang
59
- STR
60
-
61
- @t.process_command 'amend-line -1 puts :bink', eval_str
62
-
63
- eval_str.should == unindent(<<-STR)
64
- def hello
65
- puts :bing
66
- puts :bink
67
- STR
68
-
69
- @t.process_command 'amend-line -2 puts :bink', eval_str
70
-
71
- eval_str.should == unindent(<<-STR)
72
- def hello
73
- puts :bink
74
- puts :bink
75
- STR
76
- end
77
-
78
- it 'should amend a range of lines of input when negative numbers given' do
79
- eval_str = unindent(<<-STR)
80
- def hello
81
- puts :bing
82
- puts :bang
83
- puts :boat
84
- STR
85
-
86
- @t.process_command 'amend-line -3..-2 puts :bink', eval_str
87
-
88
- eval_str.should == unindent(<<-STR)
89
- def hello
90
- puts :bink
91
- puts :boat
92
- STR
93
- end
94
-
95
- it 'should correctly amend the specified line with interpolated text' do
96
- eval_str = unindent(<<-STR)
97
- def hello
98
- puts :bing
99
- puts :bang
100
- STR
101
-
102
- @t.process_command 'amend-line puts "#{goodbye}"', eval_str
103
-
104
- eval_str.should == unindent(<<-'STR')
105
- def hello
106
- puts :bing
107
- puts "#{goodbye}"
108
- STR
109
- end
110
-
111
- it 'should display error if nothing to amend' do
112
- error = nil
113
-
114
- begin
115
- @t.process_command 'amend-line'
116
- rescue Pry::CommandError => e
117
- error = e
118
- end
119
-
120
- error.should.not.be.nil
121
- error.message.should =~ /No input to amend/
122
- end
123
-
124
- it 'should correctly amend the specified range of lines' do
125
- eval_str = unindent(<<-STR)
126
- def hello
127
- puts :bing
128
- puts :bang
129
- puts :heart
130
- STR
131
-
132
- @t.process_command 'amend-line 2..3 puts :bong', eval_str
133
-
134
- eval_str.should == unindent(<<-STR)
135
- def hello
136
- puts :bong
137
- puts :heart
138
- STR
139
- end
140
-
141
- it 'should correctly delete a specific line using the ! for content' do
142
- eval_str = unindent(<<-STR)
143
- def hello
144
- puts :bing
145
- puts :bang
146
- puts :boast
147
- puts :heart
148
- STR
149
-
150
- @t.process_command 'amend-line 3 !', eval_str
151
-
152
- eval_str.should == unindent(<<-STR)
153
- def hello
154
- puts :bing
155
- puts :boast
156
- puts :heart
157
- STR
158
- end
159
-
160
- it 'should correctly delete a range of lines using the ! for content' do
161
- eval_str = unindent(<<-STR)
162
- def hello
163
- puts :bing
164
- puts :bang
165
- puts :boast
166
- puts :heart
167
- STR
168
-
169
- @t.process_command 'amend-line 2..4 !', eval_str
170
-
171
- eval_str.should == unindent(<<-STR)
172
- def hello
173
- puts :heart
174
- STR
175
- end
176
-
177
- it 'should correctly delete the previous line using the ! for content' do
178
- eval_str = unindent(<<-STR)
179
- def hello
180
- puts :bing
181
- puts :bang
182
- puts :boast
183
- puts :heart
184
- STR
185
-
186
- @t.process_command 'amend-line !', eval_str
187
-
188
- eval_str.should == unindent(<<-STR)
189
- def hello
190
- puts :bing
191
- puts :bang
192
- puts :boast
193
- STR
194
- end
195
-
196
- it 'should amend the specified range of lines, with numbers < 0 in range' do
197
- eval_str = unindent(<<-STR)
198
- def hello
199
- puts :bing
200
- puts :bang
201
- puts :boast
202
- puts :heart
203
- STR
204
-
205
- @t.process_command 'amend-line 2..-2 puts :bong', eval_str
206
-
207
- eval_str.should == unindent(<<-STR)
208
- def hello
209
- puts :bong
210
- puts :heart
211
- STR
212
- end
213
-
214
- it 'should correctly insert a line before a specified line using >' do
215
- eval_str = unindent(<<-STR)
216
- def hello
217
- puts :bing
218
- puts :bang
219
- STR
220
-
221
- @t.process_command 'amend-line 2 > puts :inserted', eval_str
222
-
223
- eval_str.should == unindent(<<-STR)
224
- def hello
225
- puts :inserted
226
- puts :bing
227
- puts :bang
228
- STR
229
- end
230
-
231
- it 'should ignore second value of range with > syntax' do
232
- eval_str = unindent(<<-STR)
233
- def hello
234
- puts :bing
235
- puts :bang
236
- STR
237
-
238
- @t.process_command 'amend-line 2..21 > puts :inserted', eval_str
239
-
240
- eval_str.should == unindent(<<-STR)
241
- def hello
242
- puts :inserted
243
- puts :bing
244
- puts :bang
245
- STR
246
- end
247
- end
@@ -1,19 +0,0 @@
1
- require 'helper'
2
-
3
- describe "!" do
4
- before do
5
- @t = pry_tester
6
- end
7
-
8
- it 'should correctly clear the input buffer ' do
9
- eval_str = unindent(<<-STR)
10
- def hello
11
- puts :bing
12
- STR
13
-
14
- @t.process_command '!', eval_str
15
- @t.last_output.should =~ /Input buffer cleared!/
16
-
17
- eval_str.should == ''
18
- end
19
- end
@@ -1,164 +0,0 @@
1
- require 'helper'
2
-
3
- describe "cat" do
4
- before do
5
- @str_output = StringIO.new
6
-
7
- @t = pry_tester do
8
- def insert_nil_input
9
- @pry.update_input_history(nil)
10
- end
11
-
12
- def last_exception=(e)
13
- @pry.last_exception = e
14
- end
15
- end
16
- end
17
-
18
- describe "on receiving a file that does not exist" do
19
- it 'should display an error message' do
20
- proc {
21
- @t.eval 'cat supercalifragilicious66'
22
- }.should.raise(StandardError).message.should =~ /Cannot open/
23
- end
24
- end
25
-
26
- describe "with --in" do
27
- it 'should display the last few expressions with indices' do
28
- @t.eval('10', '20', 'cat --in').should == unindent(<<-STR)
29
- 1:
30
- 10
31
- 2:
32
- 20
33
- STR
34
- end
35
- end
36
-
37
- describe "with --in 1" do
38
- it 'should display the first expression with no index' do
39
- @t.eval('10', '20', 'cat --in 1').should == "10\n"
40
- end
41
- end
42
-
43
- describe "with --in -1" do
44
- it 'should display the last expression with no index' do
45
- @t.eval('10', '20', 'cat --in -1').should == "20\n"
46
- end
47
- end
48
-
49
- describe "with --in 1..2" do
50
- it 'should display the given range with indices, omitting nils' do
51
- @t.eval '10'
52
- @t.insert_nil_input # normally happens when a command is executed
53
- @t.eval ':hello'
54
-
55
- @t.eval('cat --in 1..3').should == unindent(<<-EOS)
56
- 1:
57
- 10
58
- 3:
59
- :hello
60
- EOS
61
- end
62
- end
63
-
64
- # this doesnt work so well on rbx due to differences in backtrace
65
- # so we currently skip rbx until we figure out a workaround
66
- describe "with --ex" do
67
- before do
68
- @o = Object.new
69
-
70
- # this is to test exception code (cat --ex)
71
- def @o.broken_method
72
- this method is broken
73
- end
74
- end
75
-
76
- if !Pry::Helpers::BaseHelpers.rbx?
77
- it 'cat --ex should display repl code that generated exception' do
78
- @t.eval unindent(<<-EOS)
79
- begin
80
- this raises error
81
- rescue => e
82
- _pry_.last_exception = e
83
- end
84
- EOS
85
- @t.eval('cat --ex').should =~ /\d+:(\s*) this raises error/
86
- end
87
-
88
- it 'cat --ex should correctly display code that generated exception' do
89
- begin
90
- @o.broken_method
91
- rescue => e
92
- @t.last_exception = e
93
- end
94
- @t.eval('cat --ex').should =~ /this method is broken/
95
- end
96
- end
97
- end
98
-
99
- describe "with --ex N" do
100
- it 'should cat first level of backtrace when --ex used with no argument ' do
101
- temp_file do |f|
102
- f << "bt number 1"
103
- f.flush
104
- @t.last_exception = mock_exception("#{f.path}:1", 'x', 'x')
105
- @t.eval('cat --ex').should =~ /bt number 1/
106
- end
107
- end
108
-
109
- it 'should cat first level of backtrace when --ex 0 used ' do
110
- temp_file do |f|
111
- f << "bt number 1"
112
- f.flush
113
- @t.last_exception = mock_exception("#{f.path}:1", 'x', 'x')
114
- @t.eval('cat --ex 0').should =~ /bt number 1/
115
- end
116
- end
117
-
118
- it 'should cat second level of backtrace when --ex 1 used ' do
119
- temp_file do |f|
120
- f << "bt number 2"
121
- f.flush
122
- @t.last_exception = mock_exception('x', "#{f.path}:1", 'x')
123
- @t.eval('cat --ex 1').should =~ /bt number 2/
124
- end
125
- end
126
-
127
- it 'should cat third level of backtrace when --ex 2 used' do
128
- temp_file do |f|
129
- f << "bt number 3"
130
- f.flush
131
- @t.last_exception = mock_exception('x', 'x', "#{f.path}:1")
132
- @t.eval('cat --ex 2').should =~ /bt number 3/
133
- end
134
- end
135
-
136
- it 'should show error when backtrace level out of bounds' do
137
- @t.last_exception = mock_exception('x', 'x', 'x')
138
- proc {
139
- @t.eval('cat --ex 3')
140
- }.should.raise(Pry::CommandError).message.should =~ /out of bounds/
141
- end
142
-
143
- it 'each successive cat --ex should show the next level of backtrace, and going past the final level should return to the first' do
144
- temp_files = []
145
- 3.times do |i|
146
- temp_files << Tempfile.new(['pry', '.rb'])
147
- temp_files.last << "bt number #{i}"
148
- temp_files.last.flush
149
- end
150
-
151
- @t.last_exception = mock_exception(*temp_files.map { |f| "#{f.path}:1" })
152
-
153
- 3.times do |i|
154
- @t.eval('cat --ex').should =~ /bt number #{i}/
155
- end
156
-
157
- @t.eval('cat --ex').should =~ /bt number 0/
158
-
159
- temp_files.each do |file|
160
- file.close(true)
161
- end
162
- end
163
- end
164
- end
@@ -1,250 +0,0 @@
1
- require 'helper'
2
-
3
- describe 'cd' do
4
- before do
5
- @o, @obj = Object.new, Object.new
6
- @obj.instance_variable_set(:@x, 66)
7
- @obj.instance_variable_set(:@y, 79)
8
- @o.instance_variable_set(:@obj, @obj)
9
-
10
- @t = pry_tester(@o) do
11
- def assert_binding_stack(other)
12
- binding_stack.map { |b| b.eval('self') }.should == other
13
- end
14
-
15
- def binding_stack
16
- eval '_pry_.binding_stack.dup'
17
- end
18
-
19
- def command_state
20
- eval '_pry_.command_state["cd"]'
21
- end
22
-
23
- def old_stack
24
- eval '_pry_.command_state["cd"].old_stack.dup'
25
- end
26
- end
27
- end
28
-
29
- describe 'state' do
30
- it 'should not to be set up in fresh instance' do
31
- @t.command_state.should.be.nil
32
- end
33
- end
34
-
35
- describe 'old stack toggling with `cd -`' do
36
- describe 'in fresh pry instance' do
37
- it 'should not toggle when there is no old stack' do
38
- 2.times do
39
- @t.eval 'cd -'
40
- @t.assert_binding_stack [@o]
41
- end
42
- end
43
- end
44
-
45
- describe 'when an error was raised' do
46
- it 'should not toggle and should keep correct stacks' do
47
- proc {
48
- @t.eval 'cd %'
49
- }.should.raise(Pry::CommandError)
50
-
51
- @t.old_stack.should == []
52
- @t.assert_binding_stack [@o]
53
-
54
- @t.eval 'cd -'
55
- @t.old_stack.should == []
56
- @t.assert_binding_stack [@o]
57
- end
58
- end
59
-
60
- describe 'when using simple cd syntax' do
61
- it 'should toggle' do
62
- @t.eval 'cd :mon_dogg', 'cd -'
63
- @t.assert_binding_stack [@o]
64
-
65
- @t.eval 'cd -'
66
- @t.assert_binding_stack [@o, :mon_dogg]
67
- end
68
- end
69
-
70
- describe "when using complex cd syntax" do
71
- it 'should toggle with a complex path (simple case)' do
72
- @t.eval 'cd 1/2/3', 'cd -'
73
- @t.assert_binding_stack [@o]
74
-
75
- @t.eval 'cd -'
76
- @t.assert_binding_stack [@o, 1, 2, 3]
77
- end
78
-
79
- it 'should toggle with a complex path (more complex case)' do
80
- @t.eval 'cd 1/2/3', 'cd ../4', 'cd -'
81
- @t.assert_binding_stack [@o, 1, 2, 3]
82
-
83
- @t.eval 'cd -'
84
- @t.assert_binding_stack [@o, 1, 2, 4]
85
- end
86
- end
87
-
88
- describe 'series of cd calls' do
89
- it 'should toggle with fuzzy `cd -` calls' do
90
- @t.eval 'cd :mon_dogg', 'cd -', 'cd 42', 'cd -'
91
- @t.assert_binding_stack [@o]
92
-
93
- @t.eval 'cd -'
94
- @t.assert_binding_stack [@o, 42]
95
- end
96
- end
97
-
98
- describe 'when using cd ..' do
99
- it 'should toggle with a simple path' do
100
- @t.eval 'cd :john_dogg', 'cd ..'
101
- @t.assert_binding_stack [@o]
102
-
103
- @t.eval 'cd -'
104
- @t.assert_binding_stack [@o, :john_dogg]
105
- end
106
-
107
- it 'should toggle with a complex path' do
108
- @t.eval 'cd 1/2/3/../4', 'cd -'
109
- @t.assert_binding_stack [@o]
110
-
111
- @t.eval 'cd -'
112
- @t.assert_binding_stack [@o, 1, 2, 4]
113
- end
114
- end
115
-
116
- describe 'when using cd ::' do
117
- it 'should toggle' do
118
- @t.eval 'cd ::', 'cd -'
119
- @t.assert_binding_stack [@o]
120
-
121
- @t.eval 'cd -'
122
- @t.assert_binding_stack [@o, TOPLEVEL_BINDING.eval('self')]
123
- end
124
- end
125
-
126
- describe 'when using cd /' do
127
- it 'should toggle' do
128
- @t.eval 'cd /', 'cd -'
129
- @t.assert_binding_stack [@o]
130
-
131
- @t.eval 'cd :john_dogg', 'cd /', 'cd -'
132
- @t.assert_binding_stack [@o, :john_dogg]
133
- end
134
- end
135
-
136
- describe 'when using ^D (Control-D) key press' do
137
- it 'should keep correct old binding' do
138
- @t.eval 'cd :john_dogg', 'cd :mon_dogg', 'cd :kyr_dogg',
139
- 'Pry::DEFAULT_CONTROL_D_HANDLER.call("", _pry_)'
140
- @t.assert_binding_stack [@o, :john_dogg, :mon_dogg]
141
-
142
- @t.eval 'cd -'
143
- @t.assert_binding_stack [@o, :john_dogg, :mon_dogg, :kyr_dogg]
144
-
145
- @t.eval 'cd -'
146
- @t.assert_binding_stack [@o, :john_dogg, :mon_dogg]
147
- end
148
- end
149
- end
150
-
151
- it 'should cd into simple input' do
152
- @t.eval 'cd :mon_ouie'
153
- @t.eval('self').should == :mon_ouie
154
- end
155
-
156
- it 'should break out of session with cd ..' do
157
- @t.eval 'cd :outer', 'cd :inner'
158
- @t.eval('self').should == :inner
159
-
160
- @t.eval 'cd ..'
161
- @t.eval('self').should == :outer
162
- end
163
-
164
- it "should not leave the REPL session when given 'cd ..'" do
165
- @t.eval 'cd ..'
166
- @t.eval('self').should == @o
167
- end
168
-
169
- it 'should break out to outer-most session with cd /' do
170
- @t.eval 'cd :inner'
171
- @t.eval('self').should == :inner
172
-
173
- @t.eval 'cd 5'
174
- @t.eval('self').should == 5
175
-
176
- @t.eval 'cd /'
177
- @t.eval('self').should == @o
178
- end
179
-
180
- it 'should break out to outer-most session with just cd (no args)' do
181
- @t.eval 'cd :inner'
182
- @t.eval('self').should == :inner
183
-
184
- @t.eval 'cd 5'
185
- @t.eval('self').should == 5
186
-
187
- @t.eval 'cd'
188
- @t.eval('self').should == @o
189
- end
190
-
191
- it 'should cd into an object and its ivar using cd obj/@ivar syntax' do
192
- @t.eval 'cd @obj/@x'
193
- @t.assert_binding_stack [@o, @obj, 66]
194
- end
195
-
196
- it 'should cd into an object and its ivar using cd obj/@ivar/ syntax (note following /)' do
197
- @t.eval 'cd @obj/@x/'
198
- @t.assert_binding_stack [@o, @obj, 66]
199
- end
200
-
201
- it 'should cd into previous object and its local using cd ../local syntax' do
202
- @t.eval 'cd @obj', 'local = :local', 'cd @x', 'cd ../local'
203
- @t.assert_binding_stack [@o, @obj, :local]
204
- end
205
-
206
- it 'should cd into an object and its ivar and back again using cd obj/@ivar/.. syntax' do
207
- @t.eval 'cd @obj/@x/..'
208
- @t.assert_binding_stack [@o, @obj]
209
- end
210
-
211
- it 'should cd into an object and its ivar and back and then into another ivar using cd obj/@ivar/../@y syntax' do
212
- @t.eval 'cd @obj/@x/../@y'
213
- @t.assert_binding_stack [@o, @obj, 79]
214
- end
215
-
216
- it 'should cd back to top-level and then into another ivar using cd /@ivar/ syntax' do
217
- @t.eval '@z = 20', 'cd @obj/@x/', 'cd /@z'
218
- @t.assert_binding_stack [@o, 20]
219
- end
220
-
221
- it 'should start a session on TOPLEVEL_BINDING with cd ::' do
222
- @t.eval 'cd ::'
223
- @t.eval('self').should == TOPLEVEL_BINDING.eval('self')
224
- end
225
-
226
- it 'should cd into complex input (with spaces)' do
227
- def @o.hello(x, y, z)
228
- :mon_ouie
229
- end
230
-
231
- @t.eval 'cd hello 1, 2, 3'
232
- @t.eval('self').should == :mon_ouie
233
- end
234
-
235
- it 'should not cd into complex input when it encounters an exception' do
236
- proc {
237
- @t.eval 'cd 1/2/swoop_a_doop/3'
238
- }.should.raise(Pry::CommandError)
239
-
240
- @t.assert_binding_stack [@o]
241
- end
242
-
243
- # Regression test for ticket #516.
244
- # FIXME: This is actually broken.
245
- # it 'should be able to cd into the Object BasicObject' do
246
- # proc {
247
- # @t.eval 'cd BasicObject.new'
248
- # }.should.not.raise
249
- # end
250
- end