pry 0.9.12.6-i386-mswin32 → 0.10.0-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +702 -0
- data/LICENSE +2 -2
- data/{README.markdown → README.md} +37 -31
- data/lib/pry.rb +38 -151
- data/lib/pry/cli.rb +35 -17
- data/lib/pry/code.rb +19 -63
- data/lib/pry/code/code_file.rb +103 -0
- data/lib/pry/code/code_range.rb +2 -1
- data/lib/pry/code/loc.rb +2 -2
- data/lib/pry/code_object.rb +40 -21
- data/lib/pry/color_printer.rb +55 -0
- data/lib/pry/command.rb +12 -9
- data/lib/pry/command_set.rb +81 -38
- data/lib/pry/commands.rb +1 -1
- data/lib/pry/commands/amend_line.rb +2 -2
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat.rb +11 -2
- data/lib/pry/commands/cat/exception_formatter.rb +6 -7
- data/lib/pry/commands/cat/file_formatter.rb +15 -32
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cd.rb +14 -3
- data/lib/pry/commands/change_inspector.rb +27 -0
- data/lib/pry/commands/change_prompt.rb +26 -0
- data/lib/pry/commands/code_collector.rb +4 -4
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +10 -22
- data/lib/pry/commands/edit/exception_patcher.rb +2 -2
- data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
- data/lib/pry/commands/exit_program.rb +0 -1
- data/lib/pry/commands/find_method.rb +16 -22
- data/lib/pry/commands/gem_install.rb +5 -2
- data/lib/pry/commands/gem_open.rb +1 -1
- data/lib/pry/commands/gist.rb +10 -11
- data/lib/pry/commands/help.rb +14 -14
- data/lib/pry/commands/hist.rb +27 -8
- data/lib/pry/commands/install_command.rb +14 -12
- data/lib/pry/commands/list_inspectors.rb +35 -0
- data/lib/pry/commands/list_prompts.rb +35 -0
- data/lib/pry/commands/ls.rb +72 -296
- data/lib/pry/commands/ls/constants.rb +47 -0
- data/lib/pry/commands/ls/formatter.rb +49 -0
- data/lib/pry/commands/ls/globals.rb +48 -0
- data/lib/pry/commands/ls/grep.rb +21 -0
- data/lib/pry/commands/ls/instance_vars.rb +39 -0
- data/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/lib/pry/commands/ls/local_names.rb +35 -0
- data/lib/pry/commands/ls/local_vars.rb +39 -0
- data/lib/pry/commands/ls/ls_entity.rb +70 -0
- data/lib/pry/commands/ls/methods.rb +57 -0
- data/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/lib/pry/commands/ls/self_methods.rb +32 -0
- data/lib/pry/commands/play.rb +44 -10
- data/lib/pry/commands/pry_backtrace.rb +1 -2
- data/lib/pry/commands/raise_up.rb +2 -2
- data/lib/pry/commands/reload_code.rb +16 -19
- data/lib/pry/commands/ri.rb +7 -3
- data/lib/pry/commands/shell_command.rb +18 -13
- data/lib/pry/commands/shell_mode.rb +2 -4
- data/lib/pry/commands/show_doc.rb +5 -0
- data/lib/pry/commands/show_info.rb +8 -13
- data/lib/pry/commands/show_source.rb +15 -3
- data/lib/pry/commands/simple_prompt.rb +1 -1
- data/lib/pry/commands/toggle_color.rb +8 -4
- data/lib/pry/commands/watch_expression.rb +105 -0
- data/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/lib/pry/commands/whereami.rb +18 -10
- data/lib/pry/commands/wtf.rb +3 -3
- data/lib/pry/config.rb +20 -254
- data/lib/pry/config/behavior.rb +139 -0
- data/lib/pry/config/convenience.rb +26 -0
- data/lib/pry/config/default.rb +165 -0
- data/lib/pry/core_extensions.rb +31 -21
- data/lib/pry/editor.rb +107 -103
- data/lib/pry/exceptions.rb +77 -0
- data/lib/pry/helpers/base_helpers.rb +22 -109
- data/lib/pry/helpers/command_helpers.rb +10 -8
- data/lib/pry/helpers/documentation_helpers.rb +1 -2
- data/lib/pry/helpers/text.rb +4 -5
- data/lib/pry/history.rb +46 -45
- data/lib/pry/history_array.rb +6 -1
- data/lib/pry/hooks.rb +9 -29
- data/lib/pry/indent.rb +6 -6
- data/lib/pry/input_completer.rb +242 -0
- data/lib/pry/input_lock.rb +132 -0
- data/lib/pry/inspector.rb +27 -0
- data/lib/pry/last_exception.rb +61 -0
- data/lib/pry/method.rb +82 -87
- data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
- data/lib/pry/module_candidate.rb +4 -14
- data/lib/pry/object_path.rb +82 -0
- data/lib/pry/output.rb +50 -0
- data/lib/pry/pager.rb +193 -48
- data/lib/pry/plugins.rb +1 -1
- data/lib/pry/prompt.rb +26 -0
- data/lib/pry/pry_class.rb +149 -230
- data/lib/pry/pry_instance.rb +302 -413
- data/lib/pry/rbx_path.rb +1 -1
- data/lib/pry/repl.rb +202 -0
- data/lib/pry/repl_file_loader.rb +20 -26
- data/lib/pry/rubygem.rb +13 -5
- data/lib/pry/terminal.rb +2 -1
- data/lib/pry/test/helper.rb +26 -41
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +45 -59
- metadata +62 -225
- data/.document +0 -2
- data/.gitignore +0 -16
- data/.travis.yml +0 -25
- data/.yardopts +0 -1
- data/CHANGELOG +0 -534
- data/CONTRIBUTORS +0 -55
- data/Gemfile +0 -12
- data/Rakefile +0 -140
- data/TODO +0 -117
- data/lib/pry/completion.rb +0 -321
- data/lib/pry/custom_completions.rb +0 -6
- data/lib/pry/rbx_method.rb +0 -13
- data/man/pry.1 +0 -195
- data/man/pry.1.html +0 -204
- data/man/pry.1.ronn +0 -141
- data/pry.gemspec +0 -29
- data/spec/Procfile +0 -3
- data/spec/cli_spec.rb +0 -78
- data/spec/code_object_spec.rb +0 -277
- data/spec/code_spec.rb +0 -219
- data/spec/command_helpers_spec.rb +0 -29
- data/spec/command_integration_spec.rb +0 -644
- data/spec/command_set_spec.rb +0 -627
- data/spec/command_spec.rb +0 -821
- data/spec/commands/amend_line_spec.rb +0 -247
- data/spec/commands/bang_spec.rb +0 -19
- data/spec/commands/cat_spec.rb +0 -164
- data/spec/commands/cd_spec.rb +0 -250
- data/spec/commands/disable_pry_spec.rb +0 -25
- data/spec/commands/edit_spec.rb +0 -727
- data/spec/commands/exit_all_spec.rb +0 -34
- data/spec/commands/exit_program_spec.rb +0 -19
- data/spec/commands/exit_spec.rb +0 -34
- data/spec/commands/find_method_spec.rb +0 -70
- data/spec/commands/gem_list_spec.rb +0 -26
- data/spec/commands/gist_spec.rb +0 -79
- data/spec/commands/help_spec.rb +0 -56
- data/spec/commands/hist_spec.rb +0 -181
- data/spec/commands/jump_to_spec.rb +0 -15
- data/spec/commands/ls_spec.rb +0 -181
- data/spec/commands/play_spec.rb +0 -140
- data/spec/commands/raise_up_spec.rb +0 -56
- data/spec/commands/save_file_spec.rb +0 -177
- data/spec/commands/show_doc_spec.rb +0 -510
- data/spec/commands/show_input_spec.rb +0 -17
- data/spec/commands/show_source_spec.rb +0 -782
- data/spec/commands/whereami_spec.rb +0 -203
- data/spec/completion_spec.rb +0 -241
- data/spec/control_d_handler_spec.rb +0 -58
- data/spec/documentation_helper_spec.rb +0 -73
- data/spec/editor_spec.rb +0 -79
- data/spec/exception_whitelist_spec.rb +0 -21
- data/spec/fixtures/candidate_helper1.rb +0 -11
- data/spec/fixtures/candidate_helper2.rb +0 -8
- data/spec/fixtures/example.erb +0 -5
- data/spec/fixtures/example_nesting.rb +0 -33
- data/spec/fixtures/show_source_doc_examples.rb +0 -15
- data/spec/fixtures/testrc +0 -2
- data/spec/fixtures/testrcbad +0 -2
- data/spec/fixtures/whereami_helper.rb +0 -6
- data/spec/helper.rb +0 -34
- data/spec/helpers/bacon.rb +0 -86
- data/spec/helpers/mock_pry.rb +0 -43
- data/spec/helpers/table_spec.rb +0 -105
- data/spec/history_array_spec.rb +0 -67
- data/spec/hooks_spec.rb +0 -522
- data/spec/indent_spec.rb +0 -301
- data/spec/input_stack_spec.rb +0 -90
- data/spec/method_spec.rb +0 -482
- data/spec/prompt_spec.rb +0 -60
- data/spec/pry_defaults_spec.rb +0 -419
- data/spec/pry_history_spec.rb +0 -99
- data/spec/pry_output_spec.rb +0 -95
- data/spec/pry_spec.rb +0 -515
- data/spec/run_command_spec.rb +0 -25
- data/spec/sticky_locals_spec.rb +0 -157
- data/spec/syntax_checking_spec.rb +0 -81
- data/spec/wrapped_module_spec.rb +0 -261
- data/wiki/Customizing-pry.md +0 -397
- data/wiki/Home.md +0 -4
@@ -1,203 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe "whereami" do
|
4
|
-
it 'should work with methods that have been undefined' do
|
5
|
-
class Cor
|
6
|
-
def blimey!
|
7
|
-
Cor.send :undef_method, :blimey!
|
8
|
-
Pad.binding = binding
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
Cor.new.blimey!
|
13
|
-
|
14
|
-
# using [.] so the regex doesn't match itself
|
15
|
-
pry_eval(Pad.binding, 'whereami').should =~ /self[.]blimey!/
|
16
|
-
|
17
|
-
Object.remove_const(:Cor)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should work in objects with no method methods' do
|
21
|
-
class Cor
|
22
|
-
def blimey!
|
23
|
-
pry_eval(binding, 'whereami').should =~ /Cor[#]blimey!/
|
24
|
-
end
|
25
|
-
|
26
|
-
def method; "moo"; end
|
27
|
-
end
|
28
|
-
Cor.new.blimey!
|
29
|
-
Object.remove_const(:Cor)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should properly set _file_, _line_ and _dir_' do
|
33
|
-
class Cor
|
34
|
-
def blimey!
|
35
|
-
pry_eval(binding, 'whereami', '_file_').
|
36
|
-
should == File.expand_path(__FILE__)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
Cor.new.blimey!
|
41
|
-
Object.remove_const(:Cor)
|
42
|
-
end
|
43
|
-
|
44
|
-
if defined?(BasicObject)
|
45
|
-
it 'should work in BasicObjects' do
|
46
|
-
cor = Class.new(BasicObject) do
|
47
|
-
def blimey!
|
48
|
-
::Kernel.binding # omnom
|
49
|
-
end
|
50
|
-
end.new.blimey!
|
51
|
-
|
52
|
-
pry_eval(cor, 'whereami').should =~ /::Kernel.binding [#] omnom/
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should show description and correct code when __LINE__ and __FILE__ are outside @method.source_location' do
|
57
|
-
class Cor
|
58
|
-
def blimey!
|
59
|
-
eval <<-END, binding, "spec/fixtures/example.erb", 1
|
60
|
-
pry_eval(binding, 'whereami')
|
61
|
-
END
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
Cor.instance_method(:blimey!).source.should =~ /pry_eval/
|
66
|
-
Cor.new.blimey!.should =~ /Cor#blimey!.*Look at me/m
|
67
|
-
Object.remove_const(:Cor)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should show description and correct code when @method.source_location would raise an error' do
|
71
|
-
class Cor
|
72
|
-
eval <<-END, binding, "spec/fixtures/example.erb", 1
|
73
|
-
def blimey!
|
74
|
-
pry_eval(binding, 'whereami')
|
75
|
-
end
|
76
|
-
END
|
77
|
-
end
|
78
|
-
|
79
|
-
lambda{
|
80
|
-
Cor.instance_method(:blimey!).source
|
81
|
-
}.should.raise(MethodSource::SourceNotFoundError)
|
82
|
-
|
83
|
-
Cor.new.blimey!.should =~ /Cor#blimey!.*Look at me/m
|
84
|
-
Object.remove_const(:Cor)
|
85
|
-
end
|
86
|
-
|
87
|
-
# Now that we use stagger_output (paging output) we no longer get
|
88
|
-
# the "From: " line, as we output everything in one go (not separate output.puts)
|
89
|
-
# and so the user just gets a single `Error: Cannot open
|
90
|
-
# "not.found.file.erb" for reading.`
|
91
|
-
# which is good enough IMO. Unfortunately we can't test for it
|
92
|
-
# though, as we don't hook stdout.
|
93
|
-
#
|
94
|
-
# it 'should display a description and error if reading the file goes wrong' do
|
95
|
-
# class Cor
|
96
|
-
# def blimey!
|
97
|
-
# eval <<-END, binding, "not.found.file.erb", 7
|
98
|
-
# Pad.tester = pry_tester(binding)
|
99
|
-
# Pad.tester.eval('whereami')
|
100
|
-
# END
|
101
|
-
# end
|
102
|
-
# end
|
103
|
-
|
104
|
-
# proc { Cor.new.blimey! }.should.raise(MethodSource::SourceNotFoundError)
|
105
|
-
|
106
|
-
# Pad.tester.last_output.should =~
|
107
|
-
# /From: not.found.file.erb @ line 7 Cor#blimey!:/
|
108
|
-
# Object.remove_const(:Cor)
|
109
|
-
# end
|
110
|
-
|
111
|
-
it 'should show code window (not just method source) if parameter passed to whereami' do
|
112
|
-
class Cor
|
113
|
-
def blimey!
|
114
|
-
pry_eval(binding, 'whereami 3').should =~ /class Cor/
|
115
|
-
end
|
116
|
-
end
|
117
|
-
Cor.new.blimey!
|
118
|
-
Object.remove_const(:Cor)
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'should show entire method when -m option used' do
|
122
|
-
old_size, Pry.config.default_window_size = Pry.config.default_window_size, 1
|
123
|
-
old_cutoff, Pry::Command::Whereami.method_size_cutoff = Pry::Command::Whereami.method_size_cutoff, 1
|
124
|
-
class Cor
|
125
|
-
def blimey!
|
126
|
-
1
|
127
|
-
2
|
128
|
-
pry_eval(binding, 'whereami -m').should =~ /def blimey/
|
129
|
-
end
|
130
|
-
end
|
131
|
-
Pry::Command::Whereami.method_size_cutoff, Pry.config.default_window_size = old_cutoff, old_size
|
132
|
-
Cor.new.blimey!
|
133
|
-
Object.remove_const(:Cor)
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'should show entire file when -f option used' do
|
137
|
-
class Cor
|
138
|
-
def blimey!
|
139
|
-
1
|
140
|
-
2
|
141
|
-
pry_eval(binding, 'whereami -f').should =~ /show entire file when -f option used/
|
142
|
-
end
|
143
|
-
end
|
144
|
-
Cor.new.blimey!
|
145
|
-
Object.remove_const(:Cor)
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'should show class when -c option used, and locate correct candidate' do
|
149
|
-
require 'fixtures/whereami_helper'
|
150
|
-
class Cor
|
151
|
-
def blimey!
|
152
|
-
1
|
153
|
-
2
|
154
|
-
out = pry_eval(binding, 'whereami -c')
|
155
|
-
out.should =~ /class Cor/
|
156
|
-
out.should =~ /blimey/
|
157
|
-
end
|
158
|
-
end
|
159
|
-
Cor.new.blimey!
|
160
|
-
Object.remove_const(:Cor)
|
161
|
-
end
|
162
|
-
|
163
|
-
it 'should not show line numbers or marker when -n switch is used' do
|
164
|
-
class Cor
|
165
|
-
def blimey!
|
166
|
-
out = pry_eval(binding, 'whereami -n')
|
167
|
-
out.should =~ /^\s*def/
|
168
|
-
out.should.not =~ /\=\>/
|
169
|
-
end
|
170
|
-
end
|
171
|
-
Cor.new.blimey!
|
172
|
-
Object.remove_const(:Cor)
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'should use Pry.config.default_window_size for window size when outside a method context' do
|
176
|
-
old_size, Pry.config.default_window_size = Pry.config.default_window_size, 1
|
177
|
-
:litella
|
178
|
-
:pig
|
179
|
-
out = pry_eval(binding, 'whereami')
|
180
|
-
:punk
|
181
|
-
:sanders
|
182
|
-
|
183
|
-
out.should.not =~ /:litella/
|
184
|
-
out.should =~ /:pig/
|
185
|
-
out.should =~ /:punk/
|
186
|
-
out.should.not =~ /:sanders/
|
187
|
-
|
188
|
-
Pry.config.default_window_size = old_size
|
189
|
-
end
|
190
|
-
|
191
|
-
it "should work at the top level" do
|
192
|
-
pry_eval(Pry.toplevel_binding, 'whereami').should =~
|
193
|
-
/At the top level/
|
194
|
-
end
|
195
|
-
|
196
|
-
it "should work inside a class" do
|
197
|
-
pry_eval(Pry, 'whereami').should =~ /Inside Pry/
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should work inside an object" do
|
201
|
-
pry_eval(Object.new, 'whereami').should =~ /Inside #<Object/
|
202
|
-
end
|
203
|
-
end
|
data/spec/completion_spec.rb
DELETED
@@ -1,241 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
def new_completer(bind, pry=nil)
|
4
|
-
Pry::InputCompleter.build_completion_proc(Pry.binding_for(bind), pry)
|
5
|
-
end
|
6
|
-
|
7
|
-
def completer_test(bind, pry=nil, assert_flag=true)
|
8
|
-
completer = new_completer(bind, pry)
|
9
|
-
test = proc {|symbol| completer.call(symbol[0..-2]).include?(symbol).should == assert_flag}
|
10
|
-
return proc {|*symbols| symbols.each(&test) }
|
11
|
-
end
|
12
|
-
|
13
|
-
Pry.require_readline
|
14
|
-
|
15
|
-
if defined?(Bond) && Readline::VERSION !~ /editline/i
|
16
|
-
describe 'bond-based completion' do
|
17
|
-
it 'should pull in Bond by default' do
|
18
|
-
Pry.config.completer.should == Pry::BondCompleter
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe Pry::InputCompleter do
|
24
|
-
|
25
|
-
before do
|
26
|
-
# The AMQP gem has some classes like this:
|
27
|
-
# pry(main)> AMQP::Protocol::Test::ContentOk.name
|
28
|
-
# => :content_ok
|
29
|
-
module SymbolyName
|
30
|
-
def self.name; :symboly_name; end
|
31
|
-
end
|
32
|
-
|
33
|
-
$default_completer = Pry.config.completer
|
34
|
-
Pry.config.completer = Pry::InputCompleter
|
35
|
-
end
|
36
|
-
|
37
|
-
after do
|
38
|
-
Pry.config.completer = $default_completer
|
39
|
-
Object.remove_const :SymbolyName
|
40
|
-
end
|
41
|
-
|
42
|
-
# another jruby hack :((
|
43
|
-
if !Pry::Helpers::BaseHelpers.jruby?
|
44
|
-
it "should not crash if there's a Module that has a symbolic name." do
|
45
|
-
completer = Pry::InputCompleter.build_completion_proc(Pry.binding_for(Object.new))
|
46
|
-
lambda{ completer.call "a.to_s." }.should.not.raise Exception
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should take parenthesis and other characters into account for symbols' do
|
51
|
-
b = Pry.binding_for(Object.new)
|
52
|
-
completer = Pry::InputCompleter.build_completion_proc(b)
|
53
|
-
|
54
|
-
lambda { completer.call(":class)") }.should.not.raise(RegexpError)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should complete instance variables' do
|
58
|
-
object = Class.new.new
|
59
|
-
|
60
|
-
# set variables in appropriate scope
|
61
|
-
object.instance_variable_set(:'@name', 'Pry')
|
62
|
-
object.class.send(:class_variable_set, :'@@number', 10)
|
63
|
-
|
64
|
-
# check to see if variables are in scope
|
65
|
-
object.instance_variables.
|
66
|
-
map { |v| v.to_sym }.
|
67
|
-
include?(:'@name').should == true
|
68
|
-
|
69
|
-
object.class.class_variables.
|
70
|
-
map { |v| v.to_sym }.
|
71
|
-
include?(:'@@number').should == true
|
72
|
-
|
73
|
-
# Complete instance variables.
|
74
|
-
b = Pry.binding_for(object)
|
75
|
-
completer_test(b).call('@name', '@name.downcase')
|
76
|
-
|
77
|
-
# Complete class variables.
|
78
|
-
b = Pry.binding_for(object.class)
|
79
|
-
completer_test(b).call('@@number', '@@number.class')
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
it 'should complete for stdlib symbols' do
|
85
|
-
|
86
|
-
o = Object.new
|
87
|
-
# Regexp
|
88
|
-
completer_test(o).call('/foo/.extend')
|
89
|
-
|
90
|
-
# Array
|
91
|
-
completer_test(o).call('[1].push')
|
92
|
-
|
93
|
-
# Hash
|
94
|
-
completer_test(o).call('{"a" => "b"}.keys')
|
95
|
-
|
96
|
-
# Proc
|
97
|
-
completer_test(o).call('{2}.call')
|
98
|
-
|
99
|
-
# Symbol
|
100
|
-
completer_test(o).call(':symbol.to_s')
|
101
|
-
|
102
|
-
# Absolute Constant
|
103
|
-
completer_test(o).call('::IndexError')
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'should complete for target symbols' do
|
107
|
-
o = Object.new
|
108
|
-
|
109
|
-
# Constant
|
110
|
-
module Mod
|
111
|
-
Con = 'Constant'
|
112
|
-
module Mod2
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
completer_test(Mod).call('Con')
|
117
|
-
|
118
|
-
# Constants or Class Methods
|
119
|
-
completer_test(o).call('Mod::Con')
|
120
|
-
|
121
|
-
# Symbol
|
122
|
-
foo = :symbol
|
123
|
-
completer_test(o).call(':symbol')
|
124
|
-
|
125
|
-
# Variables
|
126
|
-
class << o
|
127
|
-
attr_accessor :foo
|
128
|
-
end
|
129
|
-
o.foo = 'bar'
|
130
|
-
completer_test(binding).call('o.foo')
|
131
|
-
|
132
|
-
# trailing slash
|
133
|
-
new_completer(Mod).call('Mod2/').include?('Mod2/').should == true
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'should complete for arbitrary scopes' do
|
137
|
-
module Bar
|
138
|
-
@barvar = :bar
|
139
|
-
end
|
140
|
-
|
141
|
-
module Baz
|
142
|
-
@bar = Bar
|
143
|
-
@bazvar = :baz
|
144
|
-
Con = :constant
|
145
|
-
end
|
146
|
-
|
147
|
-
pry = Pry.new()
|
148
|
-
stack = pry.binding_stack
|
149
|
-
stack.push(Pry.binding_for(Baz))
|
150
|
-
stack.push(Pry.binding_for(Bar))
|
151
|
-
|
152
|
-
b = Pry.binding_for(Bar)
|
153
|
-
completer_test(b, pry).call("../@bazvar")
|
154
|
-
completer_test(b, pry).call('/Con')
|
155
|
-
end
|
156
|
-
|
157
|
-
it 'should complete for stdlib symbols' do
|
158
|
-
|
159
|
-
o = Object.new
|
160
|
-
# Regexp
|
161
|
-
completer_test(o).call('/foo/.extend')
|
162
|
-
|
163
|
-
# Array
|
164
|
-
completer_test(o).call('[1].push')
|
165
|
-
|
166
|
-
# Hash
|
167
|
-
completer_test(o).call('{"a" => "b"}.keys')
|
168
|
-
|
169
|
-
# Proc
|
170
|
-
completer_test(o).call('{2}.call')
|
171
|
-
|
172
|
-
# Symbol
|
173
|
-
completer_test(o).call(':symbol.to_s')
|
174
|
-
|
175
|
-
# Absolute Constant
|
176
|
-
completer_test(o).call('::IndexError')
|
177
|
-
end
|
178
|
-
|
179
|
-
it 'should complete for target symbols' do
|
180
|
-
o = Object.new
|
181
|
-
|
182
|
-
# Constant
|
183
|
-
module Mod
|
184
|
-
Con = 'Constant'
|
185
|
-
module Mod2
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
completer_test(Mod).call('Con')
|
190
|
-
|
191
|
-
# Constants or Class Methods
|
192
|
-
completer_test(o).call('Mod::Con')
|
193
|
-
|
194
|
-
# Symbol
|
195
|
-
foo = :symbol
|
196
|
-
completer_test(o).call(':symbol')
|
197
|
-
|
198
|
-
# Variables
|
199
|
-
class << o
|
200
|
-
attr_accessor :foo
|
201
|
-
end
|
202
|
-
o.foo = 'bar'
|
203
|
-
completer_test(binding).call('o.foo')
|
204
|
-
|
205
|
-
# trailing slash
|
206
|
-
new_completer(Mod).call('Mod2/').include?('Mod2/').should == true
|
207
|
-
|
208
|
-
end
|
209
|
-
|
210
|
-
it 'should complete for arbitrary scopes' do
|
211
|
-
module Bar
|
212
|
-
@barvar = :bar
|
213
|
-
end
|
214
|
-
|
215
|
-
module Baz
|
216
|
-
@bar = Bar
|
217
|
-
@bazvar = :baz
|
218
|
-
Con = :constant
|
219
|
-
end
|
220
|
-
|
221
|
-
pry = Pry.new()
|
222
|
-
stack = pry.binding_stack
|
223
|
-
stack.push(Pry.binding_for(Baz))
|
224
|
-
stack.push(Pry.binding_for(Bar))
|
225
|
-
|
226
|
-
b = Pry.binding_for(Bar)
|
227
|
-
completer_test(b, pry).call("../@bazvar")
|
228
|
-
completer_test(b, pry).call('/Con')
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'should not return nil in its output' do
|
232
|
-
pry = Pry.new
|
233
|
-
new_completer(binding, pry).call("pry.").should.not.include nil
|
234
|
-
end
|
235
|
-
|
236
|
-
it "does not raise when complete file paths" do
|
237
|
-
should.not.raise(Pry::CommandError) {
|
238
|
-
new_completer(binding, Pry.new).call("cat lib/p")
|
239
|
-
}
|
240
|
-
end
|
241
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Pry::DEFAULT_CONTROL_D_HANDLER do
|
4
|
-
|
5
|
-
describe "control-d press" do
|
6
|
-
|
7
|
-
before do
|
8
|
-
# Simulates a ^D press.
|
9
|
-
@control_d = "Pry::DEFAULT_CONTROL_D_HANDLER.call('', _pry_)"
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "in an expression" do
|
13
|
-
it "should clear out passed string" do
|
14
|
-
str = 'hello world'
|
15
|
-
Pry::DEFAULT_CONTROL_D_HANDLER.call(str, nil)
|
16
|
-
str.should == ''
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
describe "at top-level session" do
|
22
|
-
it "breaks out of a REPL" do
|
23
|
-
pry_tester(0).simulate_repl do |t|
|
24
|
-
t.eval @control_d
|
25
|
-
end.should == nil
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "in a nested session" do
|
30
|
-
it "pops last binding from the binding stack" do
|
31
|
-
pry_tester(0).simulate_repl { |t|
|
32
|
-
t.eval 'cd :foo'
|
33
|
-
t.eval('_pry_.binding_stack.size').should == 2
|
34
|
-
t.eval(@control_d)
|
35
|
-
t.eval('_pry_.binding_stack.size').should == 1
|
36
|
-
t.eval 'exit-all'
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
it "breaks out of the parent session" do
|
41
|
-
pry_tester(:outer).simulate_repl do |o|
|
42
|
-
o.context = :inner
|
43
|
-
o.simulate_repl { |i|
|
44
|
-
i.eval('_pry_.current_context.eval("self")').should == :inner
|
45
|
-
i.eval('_pry_.binding_stack.size').should == 2
|
46
|
-
i.eval @control_d
|
47
|
-
i.eval('_pry_.binding_stack.size').should == 1
|
48
|
-
i.eval('_pry_.current_context.eval("self")').should == :outer
|
49
|
-
i.eval 'throw :breakout'
|
50
|
-
}
|
51
|
-
o.eval 'exit-all'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|