pry 0.9.8pre5-java → 0.9.8pre6-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +36 -0
- data/Rakefile +2 -2
- data/lib/pry.rb +3 -2
- data/lib/pry/code.rb +344 -0
- data/lib/pry/command.rb +22 -21
- data/lib/pry/command_set.rb +28 -15
- data/lib/pry/commands.rb +0 -1
- data/lib/pry/config.rb +2 -2
- data/lib/pry/default_commands/context.rb +100 -86
- data/lib/pry/default_commands/documentation.rb +20 -1
- data/lib/pry/default_commands/gems.rb +65 -37
- data/lib/pry/default_commands/input.rb +107 -154
- data/lib/pry/default_commands/introspection.rb +154 -102
- data/lib/pry/default_commands/shell.rb +89 -91
- data/lib/pry/helpers/command_helpers.rb +14 -76
- data/lib/pry/hooks.rb +12 -1
- data/lib/pry/pry_class.rb +3 -3
- data/lib/pry/pry_instance.rb +40 -15
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +16 -16
- data/test/helper.rb +9 -23
- data/test/test_code.rb +201 -0
- data/test/test_command.rb +10 -0
- data/test/test_default_commands/test_input.rb +11 -11
- data/test/test_default_commands/test_introspection.rb +5 -5
- data/test/test_default_commands/test_shell.rb +10 -10
- data/test/test_hooks.rb +36 -0
- metadata +19 -17
- data/lib/pry/extended_commands/user_command_api.rb +0 -122
data/lib/pry/version.rb
CHANGED
data/pry.gemspec
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "0.9.
|
4
|
+
s.name = "pry"
|
5
|
+
s.version = "0.9.8pre4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = [
|
9
|
-
s.date =
|
10
|
-
s.description =
|
11
|
-
s.email =
|
12
|
-
s.executables = [
|
13
|
-
s.files = [
|
14
|
-
s.homepage =
|
15
|
-
s.require_paths = [
|
16
|
-
s.rubygems_version =
|
17
|
-
s.summary =
|
18
|
-
s.test_files = [
|
8
|
+
s.authors = ["John Mair (banisterfiend)"]
|
9
|
+
s.date = "2012-01-16"
|
10
|
+
s.description = "An IRB alternative and runtime developer console"
|
11
|
+
s.email = "jrmair@gmail.com"
|
12
|
+
s.executables = ["pry"]
|
13
|
+
s.files = [".document", ".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "CONTRIBUTORS", "Gemfile", "LICENSE", "README.markdown", "Rakefile", "TODO", "bin/pry", "examples/example_basic.rb", "examples/example_command_override.rb", "examples/example_commands.rb", "examples/example_hooks.rb", "examples/example_image_edit.rb", "examples/example_input.rb", "examples/example_input2.rb", "examples/example_output.rb", "examples/example_print.rb", "examples/example_prompt.rb", "examples/helper.rb", "lib/pry.rb", "lib/pry/cli.rb", "lib/pry/code.rb", "lib/pry/command.rb", "lib/pry/command_set.rb", "lib/pry/commands.rb", "lib/pry/completion.rb", "lib/pry/config.rb", "lib/pry/core_extensions.rb", "lib/pry/custom_completions.rb", "lib/pry/default_commands/basic.rb", "lib/pry/default_commands/context.rb", "lib/pry/default_commands/documentation.rb", "lib/pry/default_commands/easter_eggs.rb", "lib/pry/default_commands/gems.rb", "lib/pry/default_commands/input.rb", "lib/pry/default_commands/introspection.rb", "lib/pry/default_commands/ls.rb", "lib/pry/default_commands/shell.rb", "lib/pry/extended_commands/experimental.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/helpers/options_helpers.rb", "lib/pry/helpers/text.rb", "lib/pry/history.rb", "lib/pry/history_array.rb", "lib/pry/hooks.rb", "lib/pry/indent.rb", "lib/pry/method.rb", "lib/pry/plugins.rb", "lib/pry/pry_class.rb", "lib/pry/pry_instance.rb", "lib/pry/rbx_method.rb", "lib/pry/rbx_path.rb", "lib/pry/version.rb", "lib/pry/wrapped_module.rb", "man/pry.1", "man/pry.1.html", "man/pry.1.ronn", "pry.gemspec", "test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_special_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad", "wiki/Customizing-pry.md", "wiki/Home.md"]
|
14
|
+
s.homepage = "http://pry.github.com"
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
s.rubygems_version = "1.8.11"
|
17
|
+
s.summary = "An IRB alternative and runtime developer console"
|
18
|
+
s.test_files = ["test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_special_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad"]
|
19
19
|
|
20
20
|
if s.respond_to? :specification_version then
|
21
21
|
s.specification_version = 3
|
22
22
|
|
23
23
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
24
24
|
s.add_runtime_dependency(%q<coderay>, ["~> 1.0.5"])
|
25
|
-
s.add_runtime_dependency(%q<slop>, ["< 3", ">= 2.4.
|
25
|
+
s.add_runtime_dependency(%q<slop>, ["< 3", ">= 2.4.3"])
|
26
26
|
s.add_runtime_dependency(%q<method_source>, ["~> 0.7"])
|
27
27
|
s.add_development_dependency(%q<bacon>, ["~> 1.1"])
|
28
28
|
s.add_development_dependency(%q<open4>, ["~> 1.3"])
|
29
29
|
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
30
30
|
else
|
31
31
|
s.add_dependency(%q<coderay>, ["~> 1.0.5"])
|
32
|
-
s.add_dependency(%q<slop>, ["< 3", ">= 2.4.
|
32
|
+
s.add_dependency(%q<slop>, ["< 3", ">= 2.4.3"])
|
33
33
|
s.add_dependency(%q<method_source>, ["~> 0.7"])
|
34
34
|
s.add_dependency(%q<bacon>, ["~> 1.1"])
|
35
35
|
s.add_dependency(%q<open4>, ["~> 1.3"])
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
end
|
38
38
|
else
|
39
39
|
s.add_dependency(%q<coderay>, ["~> 1.0.5"])
|
40
|
-
s.add_dependency(%q<slop>, ["< 3", ">= 2.4.
|
40
|
+
s.add_dependency(%q<slop>, ["< 3", ">= 2.4.3"])
|
41
41
|
s.add_dependency(%q<method_source>, ["~> 0.7"])
|
42
42
|
s.add_dependency(%q<bacon>, ["~> 1.1"])
|
43
43
|
s.add_dependency(%q<open4>, ["~> 1.3"])
|
data/test/helper.rb
CHANGED
@@ -30,23 +30,12 @@ class << Pry
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def initialize(*backtrace)
|
38
|
-
@backtrace = backtrace
|
39
|
-
@bt_index = 0
|
40
|
-
end
|
41
|
-
|
42
|
-
def message
|
43
|
-
"mock exception"
|
44
|
-
end
|
45
|
-
|
46
|
-
def bt_source_location_for(index)
|
47
|
-
backtrace[index] =~ /(.*):(\d+)/
|
48
|
-
[$1, $2.to_i]
|
33
|
+
def mock_exception(*mock_backtrace)
|
34
|
+
e = StandardError.new("mock exception")
|
35
|
+
(class << e; self; end).class_eval do
|
36
|
+
define_method(:backtrace) { mock_backtrace }
|
49
37
|
end
|
38
|
+
e
|
50
39
|
end
|
51
40
|
|
52
41
|
Pry.reset_defaults
|
@@ -132,15 +121,12 @@ end
|
|
132
121
|
|
133
122
|
class InputTester
|
134
123
|
def initialize(*actions)
|
135
|
-
if actions.last.is_a?(Hash) && actions.last.keys == [:history]
|
136
|
-
@hist = actions.pop[:history]
|
137
|
-
end
|
138
124
|
@orig_actions = actions.dup
|
139
125
|
@actions = actions
|
140
126
|
end
|
141
127
|
|
142
128
|
def readline(*)
|
143
|
-
@actions.shift
|
129
|
+
@actions.shift
|
144
130
|
end
|
145
131
|
|
146
132
|
def rewind
|
@@ -159,11 +145,11 @@ end
|
|
159
145
|
|
160
146
|
# Open a temp file and yield it to the block, closing it after
|
161
147
|
# @return [String] The path of the temp file
|
162
|
-
def temp_file
|
163
|
-
file = Tempfile.new('pry')
|
148
|
+
def temp_file(ext='.rb')
|
149
|
+
file = Tempfile.new(['pry', ext])
|
164
150
|
yield file
|
165
151
|
ensure
|
166
|
-
file.close(true)
|
152
|
+
file.close(true) if file
|
167
153
|
end
|
168
154
|
|
169
155
|
|
data/test/test_code.rb
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Pry::Code do
|
4
|
+
describe '.from_file' do
|
5
|
+
should 'read lines from a file on disk' do
|
6
|
+
Pry::Code.from_file('lib/pry.rb').length.should > 0
|
7
|
+
end
|
8
|
+
|
9
|
+
should 'read lines from Pry\'s line buffer' do
|
10
|
+
mock_pry(':hay_guys')
|
11
|
+
Pry::Code.from_file('(pry)').grep(/:hay_guys/).length.should == 1
|
12
|
+
end
|
13
|
+
|
14
|
+
should 'default to Ruby' do
|
15
|
+
temp_file('') do |f|
|
16
|
+
Pry::Code.from_file(f.path).code_type.should == :ruby
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'check the extension' do
|
21
|
+
temp_file('.c') do |f|
|
22
|
+
Pry::Code.from_file(f.path).code_type.should == :c
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'raise an error if the file doesn\'t exist' do
|
27
|
+
proc do
|
28
|
+
Pry::Code.from_file('/knalkjsdnalsd/alkjdlkq')
|
29
|
+
end.should.raise(Pry::CommandError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.from_method' do
|
34
|
+
should 'read lines from a method\'s definition' do
|
35
|
+
m = Pry::Method.from_obj(Pry, :load_history)
|
36
|
+
Pry::Code.from_method(m).length.should > 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#initialize' do
|
41
|
+
before do
|
42
|
+
@str = Pry::Helpers::CommandHelpers.unindent <<-CODE
|
43
|
+
def hay
|
44
|
+
:guys
|
45
|
+
end
|
46
|
+
CODE
|
47
|
+
|
48
|
+
@array = ['def hay', ' :guys', 'end']
|
49
|
+
end
|
50
|
+
|
51
|
+
should 'break a string into lines' do
|
52
|
+
Pry::Code.new(@str).length.should == 3
|
53
|
+
end
|
54
|
+
|
55
|
+
should 'accept an array' do
|
56
|
+
Pry::Code.new(@array).length.should == 3
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'an array or string should produce an equivalent object' do
|
60
|
+
Pry::Code.new(@str).should == Pry::Code.new(@array)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'filters and formatters' do
|
65
|
+
before do
|
66
|
+
@code = Pry::Code(Pry::Helpers::CommandHelpers.unindent <<-STR)
|
67
|
+
class MyProgram
|
68
|
+
def self.main
|
69
|
+
puts 'Hello, world!'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
STR
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'filters' do
|
76
|
+
describe '#between' do
|
77
|
+
should 'work with an inclusive range' do
|
78
|
+
@code = @code.between(1..3)
|
79
|
+
@code.length.should == 3
|
80
|
+
@code.should =~ /\Aclass MyProgram/
|
81
|
+
@code.should =~ /world!'\Z/
|
82
|
+
end
|
83
|
+
|
84
|
+
should 'default to an inclusive range' do
|
85
|
+
@code = @code.between(3, 5)
|
86
|
+
@code.length.should == 3
|
87
|
+
end
|
88
|
+
|
89
|
+
should 'work with an exclusive range' do
|
90
|
+
@code = @code.between(2...4)
|
91
|
+
@code.length.should == 2
|
92
|
+
@code.should =~ /\A def self/
|
93
|
+
@code.should =~ /world!'\Z/
|
94
|
+
end
|
95
|
+
|
96
|
+
should 'use real line numbers for positive indices' do
|
97
|
+
@code = @code.after(3, 3)
|
98
|
+
@code = @code.between(4, 4)
|
99
|
+
@code.length.should == 1
|
100
|
+
@code.should =~ /\A end\Z/
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#before' do
|
105
|
+
should 'work' do
|
106
|
+
@code = @code.before(3, 1)
|
107
|
+
@code.should =~ /\A def self\.main\Z/
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#around' do
|
112
|
+
should 'work' do
|
113
|
+
@code = @code.around(3, 1)
|
114
|
+
@code.length.should == 3
|
115
|
+
@code.should =~ /\A def self/
|
116
|
+
@code.should =~ / end\Z/
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#after' do
|
121
|
+
should 'work' do
|
122
|
+
@code = @code.after(3, 1)
|
123
|
+
@code.should =~ /\A end\Z/
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#grep' do
|
128
|
+
should 'work' do
|
129
|
+
@code = @code.grep(/end/)
|
130
|
+
@code.length.should == 2
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe 'formatters' do
|
136
|
+
describe '#with_line_numbers' do
|
137
|
+
should 'show line numbers' do
|
138
|
+
@code = @code.with_line_numbers
|
139
|
+
@code.should =~ /1:/
|
140
|
+
end
|
141
|
+
|
142
|
+
should 'disable line numbers when falsy' do
|
143
|
+
@code = @code.with_line_numbers
|
144
|
+
@code = @code.with_line_numbers(false)
|
145
|
+
@code.should.not =~ /1:/
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe '#with_marker' do
|
150
|
+
should 'show a marker in the right place' do
|
151
|
+
@code = @code.with_marker(2)
|
152
|
+
@code.should =~ /^ => def self/
|
153
|
+
end
|
154
|
+
|
155
|
+
should 'disable the marker when falsy' do
|
156
|
+
@code = @code.with_marker(2)
|
157
|
+
@code = @code.with_marker(false)
|
158
|
+
@code.should =~ /^ def self/
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#with_indentation' do
|
163
|
+
should 'indent the text' do
|
164
|
+
@code = @code.with_indentation(2)
|
165
|
+
@code.should =~ /^ def self/
|
166
|
+
end
|
167
|
+
|
168
|
+
should 'disable the indentation when falsy' do
|
169
|
+
@code = @code.with_indentation(2)
|
170
|
+
@code = @code.with_indentation(false)
|
171
|
+
@code.should =~ /^ def self/
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe 'composition' do
|
177
|
+
describe 'grep and with_line_numbers' do
|
178
|
+
should 'work' do
|
179
|
+
@code = @code.grep(/end/).with_line_numbers
|
180
|
+
@code.should =~ /\A4: end/
|
181
|
+
@code.should =~ /5: end\Z/
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe 'grep and before and with_line_numbers' do
|
186
|
+
should 'work' do
|
187
|
+
@code = @code.grep(/e/).before(5, 5).with_line_numbers
|
188
|
+
@code.should =~ /\A2: def self.main\n3:/
|
189
|
+
@code.should =~ /4: end\Z/
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe 'before and after' do
|
194
|
+
should 'work' do
|
195
|
+
@code = @code.before(4, 2).after(2)
|
196
|
+
@code.should == " puts 'Hello, world!'"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
data/test/test_command.rb
CHANGED
@@ -223,6 +223,16 @@ describe "Pry::Command" do
|
|
223
223
|
|
224
224
|
mock_command(cmd, %w(--four 4 four))
|
225
225
|
end
|
226
|
+
|
227
|
+
it 'should allow overriding options after definition' do
|
228
|
+
cmd = @set.command_class /number-(one|two)/, "Lieutenants of the Golgafrinchan Captain", :shellwords => false do
|
229
|
+
|
230
|
+
command_options :listing => 'number-one'
|
231
|
+
end
|
232
|
+
|
233
|
+
cmd.command_options[:shellwords].should == false
|
234
|
+
cmd.command_options[:listing].should == 'number-one'
|
235
|
+
end
|
226
236
|
end
|
227
237
|
|
228
238
|
describe 'tokenize' do
|
@@ -235,7 +235,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
235
235
|
@hist.push "hello"
|
236
236
|
@hist.push "world"
|
237
237
|
str_output = StringIO.new
|
238
|
-
redirect_pry_io(InputTester.new("hist", "exit-all"
|
238
|
+
redirect_pry_io(InputTester.new("hist", "exit-all"), str_output) do
|
239
239
|
pry
|
240
240
|
end
|
241
241
|
str_output.string.should =~ /hello\n.*world/
|
@@ -246,7 +246,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
246
246
|
@hist.push ":bucket"
|
247
247
|
@hist.push ":ostrich"
|
248
248
|
str_output = StringIO.new
|
249
|
-
redirect_pry_io(InputTester.new("hist --replay -1", "exit-all"
|
249
|
+
redirect_pry_io(InputTester.new("hist --replay -1", "exit-all"), str_output) do
|
250
250
|
pry
|
251
251
|
end
|
252
252
|
str_output.string.should =~ /ostrich/
|
@@ -256,7 +256,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
256
256
|
@hist.push ":hello"
|
257
257
|
@hist.push ":carl"
|
258
258
|
str_output = StringIO.new
|
259
|
-
redirect_pry_io(InputTester.new("hist --replay 0..2", "exit-all"
|
259
|
+
redirect_pry_io(InputTester.new("hist --replay 0..2", "exit-all"), str_output) do
|
260
260
|
pry
|
261
261
|
end
|
262
262
|
str_output.string.should =~ /:hello\n.*:carl/
|
@@ -274,21 +274,21 @@ describe "Pry::DefaultCommands::Input" do
|
|
274
274
|
@hist.push "place holder"
|
275
275
|
|
276
276
|
str_output = StringIO.new
|
277
|
-
redirect_pry_io(InputTester.new("hist --grep o", "exit-all"
|
277
|
+
redirect_pry_io(InputTester.new("hist --grep o", "exit-all"), str_output) do
|
278
278
|
pry
|
279
279
|
end
|
280
280
|
str_output.string.should =~ /\d:.*?box\n\d:.*?button\n\d:.*?orange/
|
281
281
|
|
282
282
|
# test more than one word in a regex match (def blah)
|
283
283
|
str_output = StringIO.new
|
284
|
-
redirect_pry_io(InputTester.new("hist --grep def blah", "exit-all"
|
284
|
+
redirect_pry_io(InputTester.new("hist --grep def blah", "exit-all"), str_output) do
|
285
285
|
pry
|
286
286
|
end
|
287
287
|
str_output.string.should =~ /def blah 1/
|
288
288
|
|
289
289
|
# test more than one word with leading white space in a regex match (def boink)
|
290
290
|
str_output = StringIO.new
|
291
|
-
redirect_pry_io(InputTester.new("hist --grep def boink", "exit-all"
|
291
|
+
redirect_pry_io(InputTester.new("hist --grep def boink", "exit-all"), str_output) do
|
292
292
|
pry
|
293
293
|
end
|
294
294
|
str_output.string.should =~ /def boink 2/
|
@@ -300,7 +300,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
300
300
|
end
|
301
301
|
|
302
302
|
str_output = StringIO.new
|
303
|
-
redirect_pry_io(InputTester.new("hist --tail 3", "exit-all"
|
303
|
+
redirect_pry_io(InputTester.new("hist --tail 3", "exit-all"), str_output) do
|
304
304
|
pry
|
305
305
|
end
|
306
306
|
|
@@ -316,7 +316,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
316
316
|
end
|
317
317
|
|
318
318
|
str_output = StringIO.new
|
319
|
-
redirect_pry_io(InputTester.new("hist --head 4", "exit-all"
|
319
|
+
redirect_pry_io(InputTester.new("hist --head 4", "exit-all"), str_output) do
|
320
320
|
pry
|
321
321
|
end
|
322
322
|
|
@@ -332,7 +332,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
332
332
|
end
|
333
333
|
|
334
334
|
str_output = StringIO.new
|
335
|
-
redirect_pry_io(InputTester.new("hist --show 1..4", "exit-all"
|
335
|
+
redirect_pry_io(InputTester.new("hist --show 1..4", "exit-all"), str_output) do
|
336
336
|
pry
|
337
337
|
end
|
338
338
|
|
@@ -342,7 +342,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
342
342
|
|
343
343
|
it "should not contain duplicated lines" do
|
344
344
|
str_output = StringIO.new
|
345
|
-
redirect_pry_io(InputTester.new("3", "_ += 1", "_ += 1", "hist", "exit-all"
|
345
|
+
redirect_pry_io(InputTester.new("3", "_ += 1", "_ += 1", "hist", "exit-all"), str_output) do
|
346
346
|
pry
|
347
347
|
end
|
348
348
|
|
@@ -351,7 +351,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
351
351
|
|
352
352
|
it "should not contain duplicated lines" do
|
353
353
|
str_output = StringIO.new
|
354
|
-
redirect_pry_io(InputTester.new(":place_holder", "2 + 2", "", "", "3 + 3", "hist", "exit-all"
|
354
|
+
redirect_pry_io(InputTester.new(":place_holder", "2 + 2", "", "", "3 + 3", "hist", "exit-all"), str_output) do
|
355
355
|
pry
|
356
356
|
end
|
357
357
|
|
@@ -133,7 +133,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
133
133
|
|
134
134
|
it 'should start editor on first level of backtrace when --ex used with no argument ' do
|
135
135
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex"), :output => StringIO.new)
|
136
|
-
pry_instance.last_exception =
|
136
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
137
137
|
pry_instance.rep(self)
|
138
138
|
@__ex_file__.should == "a"
|
139
139
|
@__ex_line__.should == 1
|
@@ -141,7 +141,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
141
141
|
|
142
142
|
it 'should start editor on first level of backtrace when --ex 0 used ' do
|
143
143
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 0"), :output => StringIO.new)
|
144
|
-
pry_instance.last_exception =
|
144
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
145
145
|
pry_instance.rep(self)
|
146
146
|
@__ex_file__.should == "a"
|
147
147
|
@__ex_line__.should == 1
|
@@ -149,7 +149,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
149
149
|
|
150
150
|
it 'should start editor on second level of backtrace when --ex 1 used' do
|
151
151
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 1"), :output => StringIO.new)
|
152
|
-
pry_instance.last_exception =
|
152
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
153
153
|
pry_instance.rep(self)
|
154
154
|
@__ex_file__.should == "b"
|
155
155
|
@__ex_line__.should == 2
|
@@ -157,7 +157,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
157
157
|
|
158
158
|
it 'should start editor on third level of backtrace when --ex 2 used' do
|
159
159
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 2"), :output => StringIO.new)
|
160
|
-
pry_instance.last_exception =
|
160
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
161
161
|
pry_instance.rep(self)
|
162
162
|
@__ex_file__.should == "c"
|
163
163
|
@__ex_line__.should == 3
|
@@ -165,7 +165,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
165
165
|
|
166
166
|
it 'should display error message when backtrace level is out of bounds (using --ex 4)' do
|
167
167
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 4"), :output => str_output = StringIO.new)
|
168
|
-
pry_instance.last_exception =
|
168
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
169
169
|
pry_instance.rep(self)
|
170
170
|
str_output.string.should =~ /Exception has no associated file/
|
171
171
|
end
|