pry 0.9.12.2 → 0.14.2
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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +1141 -0
- data/LICENSE +2 -2
- data/README.md +466 -0
- data/bin/pry +4 -7
- data/lib/pry/basic_object.rb +10 -0
- data/lib/pry/block_command.rb +22 -0
- data/lib/pry/class_command.rb +194 -0
- data/lib/pry/cli.rb +97 -92
- data/lib/pry/code/code_file.rb +114 -0
- data/lib/pry/code/code_range.rb +7 -4
- data/lib/pry/code/loc.rb +27 -14
- data/lib/pry/code.rb +62 -90
- data/lib/pry/code_object.rb +83 -39
- data/lib/pry/color_printer.rb +66 -0
- data/lib/pry/command.rb +202 -371
- data/lib/pry/command_set.rb +151 -133
- data/lib/pry/command_state.rb +31 -0
- data/lib/pry/commands/amend_line.rb +86 -82
- data/lib/pry/commands/bang.rb +18 -14
- data/lib/pry/commands/bang_pry.rb +15 -11
- data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
- data/lib/pry/commands/cat/exception_formatter.rb +85 -73
- data/lib/pry/commands/cat/file_formatter.rb +56 -63
- data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
- data/lib/pry/commands/cat.rb +64 -47
- data/lib/pry/commands/cd.rb +42 -26
- data/lib/pry/commands/change_inspector.rb +34 -0
- data/lib/pry/commands/change_prompt.rb +51 -0
- data/lib/pry/commands/clear_screen.rb +20 -0
- data/lib/pry/commands/code_collector.rb +148 -131
- data/lib/pry/commands/disable_pry.rb +23 -19
- data/lib/pry/commands/easter_eggs.rb +23 -34
- data/lib/pry/commands/edit/exception_patcher.rb +21 -17
- data/lib/pry/commands/edit/file_and_line_locator.rb +33 -24
- data/lib/pry/commands/edit.rb +183 -167
- data/lib/pry/commands/exit.rb +40 -35
- data/lib/pry/commands/exit_all.rb +24 -20
- data/lib/pry/commands/exit_program.rb +20 -17
- data/lib/pry/commands/find_method.rb +167 -167
- data/lib/pry/commands/fix_indent.rb +16 -12
- data/lib/pry/commands/help.rb +140 -133
- data/lib/pry/commands/hist.rb +153 -132
- data/lib/pry/commands/import_set.rb +20 -15
- data/lib/pry/commands/jump_to.rb +25 -21
- data/lib/pry/commands/list_inspectors.rb +42 -0
- data/lib/pry/commands/ls/constants.rb +75 -0
- data/lib/pry/commands/ls/formatter.rb +55 -0
- data/lib/pry/commands/ls/globals.rb +50 -0
- data/lib/pry/commands/ls/grep.rb +23 -0
- data/lib/pry/commands/ls/instance_vars.rb +40 -0
- data/lib/pry/commands/ls/interrogatable.rb +24 -0
- data/lib/pry/commands/ls/jruby_hacks.rb +55 -0
- data/lib/pry/commands/ls/local_names.rb +37 -0
- data/lib/pry/commands/ls/local_vars.rb +47 -0
- data/lib/pry/commands/ls/ls_entity.rb +65 -0
- data/lib/pry/commands/ls/methods.rb +55 -0
- data/lib/pry/commands/ls/methods_helper.rb +50 -0
- data/lib/pry/commands/ls/self_methods.rb +34 -0
- data/lib/pry/commands/ls.rb +100 -303
- data/lib/pry/commands/nesting.rb +21 -17
- data/lib/pry/commands/play.rb +93 -49
- data/lib/pry/commands/pry_backtrace.rb +22 -18
- data/lib/pry/commands/pry_version.rb +15 -11
- data/lib/pry/commands/raise_up.rb +33 -27
- data/lib/pry/commands/reload_code.rb +57 -48
- data/lib/pry/commands/reset.rb +16 -12
- data/lib/pry/commands/ri.rb +57 -38
- data/lib/pry/commands/save_file.rb +45 -43
- data/lib/pry/commands/shell_command.rb +66 -34
- data/lib/pry/commands/shell_mode.rb +22 -20
- data/lib/pry/commands/show_doc.rb +80 -65
- data/lib/pry/commands/show_info.rb +193 -159
- data/lib/pry/commands/show_input.rb +16 -11
- data/lib/pry/commands/show_source.rb +113 -33
- data/lib/pry/commands/stat.rb +35 -31
- data/lib/pry/commands/switch_to.rb +21 -15
- data/lib/pry/commands/toggle_color.rb +21 -13
- data/lib/pry/commands/watch_expression/expression.rb +43 -0
- data/lib/pry/commands/watch_expression.rb +110 -0
- data/lib/pry/commands/whereami.rb +157 -134
- data/lib/pry/commands/wtf.rb +78 -40
- data/lib/pry/config/attributable.rb +22 -0
- data/lib/pry/config/lazy_value.rb +29 -0
- data/lib/pry/config/memoized_value.rb +34 -0
- data/lib/pry/config/value.rb +24 -0
- data/lib/pry/config.rb +290 -220
- data/lib/pry/control_d_handler.rb +28 -0
- data/lib/pry/core_extensions.rb +50 -27
- data/lib/pry/editor.rb +130 -102
- data/lib/pry/env.rb +18 -0
- data/lib/pry/exception_handler.rb +43 -0
- data/lib/pry/exceptions.rb +73 -0
- data/lib/pry/forwardable.rb +27 -0
- data/lib/pry/helpers/base_helpers.rb +22 -151
- data/lib/pry/helpers/command_helpers.rb +55 -63
- data/lib/pry/helpers/documentation_helpers.rb +21 -13
- data/lib/pry/helpers/options_helpers.rb +15 -8
- data/lib/pry/helpers/platform.rb +55 -0
- data/lib/pry/helpers/table.rb +44 -32
- data/lib/pry/helpers/text.rb +96 -86
- data/lib/pry/helpers.rb +3 -0
- data/lib/pry/history.rb +101 -70
- data/lib/pry/hooks.rb +67 -137
- data/lib/pry/indent.rb +79 -73
- data/lib/pry/input_completer.rb +283 -0
- data/lib/pry/input_lock.rb +129 -0
- data/lib/pry/inspector.rb +39 -0
- data/lib/pry/last_exception.rb +61 -0
- data/lib/pry/method/disowned.rb +19 -5
- data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +51 -42
- data/lib/pry/method/weird_method_locator.rb +80 -44
- data/lib/pry/method.rb +225 -176
- data/lib/pry/object_path.rb +91 -0
- data/lib/pry/output.rb +136 -0
- data/lib/pry/pager.rb +227 -68
- data/lib/pry/prompt.rb +214 -0
- data/lib/pry/pry_class.rb +216 -289
- data/lib/pry/pry_instance.rb +438 -500
- data/lib/pry/repl.rb +256 -0
- data/lib/pry/repl_file_loader.rb +34 -35
- data/lib/pry/ring.rb +89 -0
- data/lib/pry/slop/LICENSE +20 -0
- data/lib/pry/slop/commands.rb +190 -0
- data/lib/pry/slop/option.rb +210 -0
- data/lib/pry/slop.rb +672 -0
- data/lib/pry/syntax_highlighter.rb +26 -0
- data/lib/pry/system_command_handler.rb +17 -0
- data/lib/pry/testable/evalable.rb +24 -0
- data/lib/pry/testable/mockable.rb +22 -0
- data/lib/pry/testable/pry_tester.rb +88 -0
- data/lib/pry/testable/utility.rb +34 -0
- data/lib/pry/testable/variables.rb +52 -0
- data/lib/pry/testable.rb +68 -0
- data/lib/pry/version.rb +3 -1
- data/lib/pry/warning.rb +20 -0
- data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +36 -43
- data/lib/pry/wrapped_module.rb +102 -103
- data/lib/pry.rb +135 -261
- metadata +94 -283
- data/.document +0 -2
- data/.gitignore +0 -16
- data/.travis.yml +0 -21
- data/.yardopts +0 -1
- data/CHANGELOG +0 -534
- data/CONTRIBUTORS +0 -55
- data/Gemfile +0 -9
- data/Guardfile +0 -62
- data/README.markdown +0 -400
- data/Rakefile +0 -140
- data/TODO +0 -117
- data/lib/pry/commands/disabled_commands.rb +0 -2
- data/lib/pry/commands/gem_cd.rb +0 -26
- data/lib/pry/commands/gem_install.rb +0 -29
- data/lib/pry/commands/gem_list.rb +0 -33
- data/lib/pry/commands/gem_open.rb +0 -29
- data/lib/pry/commands/gist.rb +0 -102
- data/lib/pry/commands/install_command.rb +0 -51
- data/lib/pry/commands/simple_prompt.rb +0 -22
- data/lib/pry/commands.rb +0 -6
- data/lib/pry/completion.rb +0 -304
- data/lib/pry/custom_completions.rb +0 -6
- data/lib/pry/history_array.rb +0 -116
- data/lib/pry/plugins.rb +0 -103
- data/lib/pry/rbx_method.rb +0 -13
- data/lib/pry/rbx_path.rb +0 -22
- data/lib/pry/rubygem.rb +0 -74
- data/lib/pry/terminal.rb +0 -78
- data/lib/pry/test/helper.rb +0 -185
- data/man/pry.1 +0 -195
- data/man/pry.1.html +0 -204
- data/man/pry.1.ronn +0 -141
- data/pry.gemspec +0 -30
- 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 -239
- 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 -504
- 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
data/spec/indent_spec.rb
DELETED
@@ -1,301 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
# Please keep in mind that any hash signs ("#") in the heredoc strings are
|
4
|
-
# placed on purpose. Without these editors might remove the whitespace on empty
|
5
|
-
# lines.
|
6
|
-
describe Pry::Indent do
|
7
|
-
before do
|
8
|
-
@indent = Pry::Indent.new
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should indent an array' do
|
12
|
-
input = "array = [\n10,\n15\n]"
|
13
|
-
output = "array = [\n 10,\n 15\n]"
|
14
|
-
|
15
|
-
@indent.indent(input).should == output
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should indent a hash' do
|
19
|
-
input = "hash = {\n:name => 'Ruby'\n}"
|
20
|
-
output = "hash = {\n :name => 'Ruby'\n}"
|
21
|
-
|
22
|
-
@indent.indent(input).should == output
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should indent a function' do
|
26
|
-
input = "def\nreturn 10\nend"
|
27
|
-
output = "def\n return 10\nend"
|
28
|
-
|
29
|
-
@indent.indent(input).should == output
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should indent a module and class' do
|
33
|
-
input = "module Foo\n# Hello world\nend"
|
34
|
-
output = "module Foo\n # Hello world\nend"
|
35
|
-
input_class = "class Foo\n# Hello world\nend"
|
36
|
-
output_class = "class Foo\n # Hello world\nend"
|
37
|
-
|
38
|
-
@indent.indent(input).should == output
|
39
|
-
@indent.indent(input_class).should == output_class
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should indent separate lines' do
|
43
|
-
@indent.indent('def foo').should == 'def foo'
|
44
|
-
@indent.indent('return 10').should == ' return 10'
|
45
|
-
@indent.indent('end').should == 'end'
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should not indent single line statements' do
|
49
|
-
input = <<TXT.strip
|
50
|
-
def hello; end
|
51
|
-
puts "Hello"
|
52
|
-
TXT
|
53
|
-
|
54
|
-
@indent.indent(input).should == input
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should handle multiple open and closing tokens on a line' do
|
58
|
-
input = <<TXT.strip
|
59
|
-
[10, 15].each do |num|
|
60
|
-
puts num
|
61
|
-
end
|
62
|
-
TXT
|
63
|
-
|
64
|
-
output = <<TXT.strip
|
65
|
-
[10, 15].each do |num|
|
66
|
-
puts num
|
67
|
-
end
|
68
|
-
TXT
|
69
|
-
|
70
|
-
@indent.indent(input).should == output
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should properly indent nested code' do
|
74
|
-
input = <<TXT.strip
|
75
|
-
module A
|
76
|
-
module B
|
77
|
-
class C
|
78
|
-
attr_accessor :test
|
79
|
-
# keep
|
80
|
-
def number
|
81
|
-
return 10
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
TXT
|
87
|
-
|
88
|
-
output = <<TXT.strip
|
89
|
-
module A
|
90
|
-
module B
|
91
|
-
class C
|
92
|
-
attr_accessor :test
|
93
|
-
# keep
|
94
|
-
def number
|
95
|
-
return 10
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
TXT
|
101
|
-
|
102
|
-
@indent.indent(input).should == output
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'should indent statements such as if, else, etc' do
|
106
|
-
input = <<TXT.strip
|
107
|
-
if a == 10
|
108
|
-
#
|
109
|
-
elsif a == 15
|
110
|
-
#
|
111
|
-
else
|
112
|
-
#
|
113
|
-
end
|
114
|
-
#
|
115
|
-
while true
|
116
|
-
#
|
117
|
-
end
|
118
|
-
#
|
119
|
-
for num in [10, 15, 20]
|
120
|
-
#
|
121
|
-
end
|
122
|
-
#
|
123
|
-
for num in [10, 15, 20] do
|
124
|
-
#
|
125
|
-
end
|
126
|
-
TXT
|
127
|
-
|
128
|
-
output = <<TXT.strip
|
129
|
-
if a == 10
|
130
|
-
#
|
131
|
-
elsif a == 15
|
132
|
-
#
|
133
|
-
else
|
134
|
-
#
|
135
|
-
end
|
136
|
-
#
|
137
|
-
while true
|
138
|
-
#
|
139
|
-
end
|
140
|
-
#
|
141
|
-
for num in [10, 15, 20]
|
142
|
-
#
|
143
|
-
end
|
144
|
-
#
|
145
|
-
for num in [10, 15, 20] do
|
146
|
-
#
|
147
|
-
end
|
148
|
-
TXT
|
149
|
-
|
150
|
-
@indent.indent(input).should == output
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should correctly handle while <foo> do" do
|
154
|
-
input = "while 5 do\n5\nend"
|
155
|
-
@indent.indent(input).should == "while 5 do\n 5\nend"
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should ident case statements" do
|
159
|
-
input = <<TXT.strip
|
160
|
-
case foo
|
161
|
-
when 1
|
162
|
-
2
|
163
|
-
when 2
|
164
|
-
if 3
|
165
|
-
4
|
166
|
-
end
|
167
|
-
when 5
|
168
|
-
#
|
169
|
-
else
|
170
|
-
#
|
171
|
-
end
|
172
|
-
TXT
|
173
|
-
|
174
|
-
output = <<TXT.strip
|
175
|
-
case foo
|
176
|
-
when 1
|
177
|
-
2
|
178
|
-
when 2
|
179
|
-
if 3
|
180
|
-
4
|
181
|
-
end
|
182
|
-
when 5
|
183
|
-
#
|
184
|
-
else
|
185
|
-
#
|
186
|
-
end
|
187
|
-
TXT
|
188
|
-
|
189
|
-
@indent.indent(input).should == output
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should indent correctly with nesting" do
|
193
|
-
@indent.indent("[[\n[]]\n]").should == "[[\n []]\n]"
|
194
|
-
@indent.reset.indent("[[\n[]]\n]").should == "[[\n []]\n]"
|
195
|
-
@indent.reset.indent("[[{\n[] =>\n[]}]\n]").should == "[[{\n [] =>\n []}]\n]"
|
196
|
-
end
|
197
|
-
|
198
|
-
it "should not indent single-line ifs" do
|
199
|
-
@indent.indent("foo if bar\n#").should == "foo if bar\n#"
|
200
|
-
@indent.reset.indent("foo() if bar\n#").should == "foo() if bar\n#"
|
201
|
-
@indent.reset.indent("foo 'hi' if bar\n#").should == "foo 'hi' if bar\n#"
|
202
|
-
@indent.reset.indent("foo 1 while bar\n#").should == "foo 1 while bar\n#"
|
203
|
-
@indent.reset.indent("super if true\n#").should == "super if true\n#"
|
204
|
-
@indent.reset.indent("true if false\n#").should == "true if false\n#"
|
205
|
-
@indent.reset.indent("String if false\n#").should == "String if false\n#"
|
206
|
-
end
|
207
|
-
|
208
|
-
it "should indent cunningly disguised ifs" do
|
209
|
-
@indent.indent("{1 => if bar\n#").should == "{1 => if bar\n #"
|
210
|
-
@indent.reset.indent("foo(if bar\n#").should == "foo(if bar\n #"
|
211
|
-
@indent.reset.indent("bar(baz, if bar\n#").should == "bar(baz, if bar\n #"
|
212
|
-
@indent.reset.indent("[if bar\n#").should == "[if bar\n #"
|
213
|
-
@indent.reset.indent("true; while bar\n#").should == "true; while bar\n #"
|
214
|
-
end
|
215
|
-
|
216
|
-
it "should differentiate single/multi-line unless" do
|
217
|
-
@indent.indent("foo unless bar\nunless foo\nbar\nend").should == "foo unless bar\nunless foo\n bar\nend"
|
218
|
-
end
|
219
|
-
|
220
|
-
it "should not indent single/multi-line until" do
|
221
|
-
@indent.indent("%w{baz} until bar\nuntil foo\nbar\nend").should == "%w{baz} until bar\nuntil foo\n bar\nend"
|
222
|
-
end
|
223
|
-
|
224
|
-
it "should indent begin rescue end" do
|
225
|
-
input = <<INPUT.strip
|
226
|
-
begin
|
227
|
-
doo :something => :wrong
|
228
|
-
rescue => e
|
229
|
-
doit :right
|
230
|
-
end
|
231
|
-
INPUT
|
232
|
-
output = <<OUTPUT.strip
|
233
|
-
begin
|
234
|
-
doo :something => :wrong
|
235
|
-
rescue => e
|
236
|
-
doit :right
|
237
|
-
end
|
238
|
-
OUTPUT
|
239
|
-
|
240
|
-
@indent.indent(input).should == output
|
241
|
-
end
|
242
|
-
|
243
|
-
it "should not indent inside strings" do
|
244
|
-
@indent.indent(%(def a\n"foo\nbar"\n end)).should == %(def a\n "foo\nbar"\nend)
|
245
|
-
@indent.indent(%(def a\nputs %w(foo\nbar), 'foo\nbar'\n end)).should == %(def a\n puts %w(foo\nbar), 'foo\nbar'\nend)
|
246
|
-
end
|
247
|
-
|
248
|
-
it "should not indent inside HEREDOCs" do
|
249
|
-
@indent.indent(%(def a\nputs <<FOO\n bar\nFOO\nbaz\nend)).should == %(def a\n puts <<FOO\n bar\nFOO\n baz\nend)
|
250
|
-
@indent.indent(%(def a\nputs <<-'^^'\n bar\n\t^^\nbaz\nend)).should == %(def a\n puts <<-'^^'\n bar\n\t^^\n baz\nend)
|
251
|
-
end
|
252
|
-
|
253
|
-
it "should not indent nested HEREDOCs" do
|
254
|
-
input = <<INPUT.strip
|
255
|
-
def a
|
256
|
-
puts <<FOO, <<-BAR, "baz", <<-':p'
|
257
|
-
foo
|
258
|
-
FOO
|
259
|
-
bar
|
260
|
-
BAR
|
261
|
-
tongue
|
262
|
-
:p
|
263
|
-
puts :p
|
264
|
-
end
|
265
|
-
INPUT
|
266
|
-
|
267
|
-
output = <<OUTPUT.strip
|
268
|
-
def a
|
269
|
-
puts <<FOO, <<-BAR, "baz", <<-':p'
|
270
|
-
foo
|
271
|
-
FOO
|
272
|
-
bar
|
273
|
-
BAR
|
274
|
-
tongue
|
275
|
-
:p
|
276
|
-
puts :p
|
277
|
-
end
|
278
|
-
OUTPUT
|
279
|
-
|
280
|
-
@indent.indent(input).should == output
|
281
|
-
end
|
282
|
-
|
283
|
-
describe "nesting" do
|
284
|
-
test = File.read("spec/fixtures/example_nesting.rb")
|
285
|
-
|
286
|
-
test.lines.each_with_index do |line, i|
|
287
|
-
result = line.split("#").last.strip
|
288
|
-
if result == ""
|
289
|
-
it "should fail to parse nesting on line #{i + 1} of example_nesting.rb" do
|
290
|
-
lambda {
|
291
|
-
Pry::Indent.nesting_at(test, i + 1)
|
292
|
-
}.should.raise(Pry::Indent::UnparseableNestingError)
|
293
|
-
end
|
294
|
-
else
|
295
|
-
it "should parse nesting on line #{i + 1} of example_nesting.rb" do
|
296
|
-
Pry::Indent.nesting_at(test, i + 1).should == eval(result)
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
301
|
-
end
|
data/spec/input_stack_spec.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
describe "Pry#input_stack" do
|
5
|
-
before do
|
6
|
-
@str_output = StringIO.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should accept :input_stack as a config option' do
|
10
|
-
stack = [StringIO.new("test")]
|
11
|
-
Pry.new(:input_stack => stack).input_stack.should == stack
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should use defaults from Pry.config' do
|
15
|
-
Pry.config.input_stack = [StringIO.new("exit")]
|
16
|
-
Pry.new.input_stack.should == Pry.config.input_stack
|
17
|
-
Pry.config.input_stack = []
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should read from all input objects on stack and exit session (usingn repl)' do
|
21
|
-
stack = [b = StringIO.new(":cloister\nexit\n"), c = StringIO.new(":baron\n")]
|
22
|
-
instance = Pry.new(:input => StringIO.new(":alex\n"),
|
23
|
-
:output => @str_output,
|
24
|
-
:input_stack => stack)
|
25
|
-
|
26
|
-
instance.repl
|
27
|
-
@str_output.string.should =~ /:alex/
|
28
|
-
@str_output.string.should =~ /:baron/
|
29
|
-
@str_output.string.should =~ /:cloister/
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'input objects should be popped off stack as they are used up' do
|
33
|
-
stack = [StringIO.new(":cloister\n"), StringIO.new(":baron\n")]
|
34
|
-
instance = Pry.new(:input => StringIO.new(":alex\n"),
|
35
|
-
:output => @str_output,
|
36
|
-
:input_stack => stack)
|
37
|
-
|
38
|
-
stack.size.should == 2
|
39
|
-
|
40
|
-
instance.rep
|
41
|
-
@str_output.string.should =~ /:alex/
|
42
|
-
instance.rep
|
43
|
-
@str_output.string.should =~ /:baron/
|
44
|
-
stack.size.should == 1
|
45
|
-
instance.rep
|
46
|
-
@str_output.string.should =~ /:cloister/
|
47
|
-
stack.size.should == 0
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should revert to Pry.config.input when it runs out of input objects in input_stack' do
|
51
|
-
redirect_pry_io(StringIO.new(":rimbaud\nexit\n"), StringIO.new) do
|
52
|
-
stack = [StringIO.new(":cloister\n"), StringIO.new(":baron\n")]
|
53
|
-
instance = Pry.new(:input => StringIO.new(":alex\n"),
|
54
|
-
:output => @str_output,
|
55
|
-
:input_stack => stack)
|
56
|
-
|
57
|
-
instance.repl
|
58
|
-
@str_output.string.should =~ /:alex/
|
59
|
-
@str_output.string.should =~ /:baron/
|
60
|
-
@str_output.string.should =~ /:cloister/
|
61
|
-
@str_output.string.should =~ /:rimbaud/
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should display error and throw(:breakout) if at end of input after using up input_stack objects' do
|
66
|
-
catch(:breakout) do
|
67
|
-
redirect_pry_io(StringIO.new(":rimbaud\n"), @str_output) do
|
68
|
-
Pry.new(:input_stack => [StringIO.new(":a\n"), StringIO.new(":b\n")]).repl
|
69
|
-
end
|
70
|
-
end
|
71
|
-
@str_output.string.should =~ /Error: Pry ran out of things to read/
|
72
|
-
end
|
73
|
-
|
74
|
-
if "".respond_to?(:encoding)
|
75
|
-
after do
|
76
|
-
Pry.line_buffer = [""]
|
77
|
-
Pry.current_line = 1
|
78
|
-
end
|
79
|
-
it "should pass strings to Pry in the right encoding" do
|
80
|
-
input1 = "'f。。'.encoding.name" # utf-8, see coding declaration
|
81
|
-
input2 = input1.encode('Shift_JIS')
|
82
|
-
|
83
|
-
mock_pry(input1, input2).should == %{=> "UTF-8"\n=> "Shift_JIS"\n\n}
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should be able to use unicode regexes on a UTF-8 terminal" do
|
87
|
-
mock_pry('":-Þ" =~ /þ/i').should == %{=> 2\n\n}
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|