pry 0.9.4pre1-i386-mswin32 → 0.9.4pre2-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/CHANGELOG +23 -0
  2. data/CONTRIBUTORS +13 -11
  3. data/README.markdown +2 -0
  4. data/Rakefile +16 -2
  5. data/TODO +8 -0
  6. data/lib/pry.rb +58 -9
  7. data/lib/pry/command_context.rb +11 -0
  8. data/lib/pry/command_processor.rb +43 -6
  9. data/lib/pry/command_set.rb +14 -4
  10. data/lib/pry/completion.rb +5 -5
  11. data/lib/pry/config.rb +6 -2
  12. data/lib/pry/default_commands/context.rb +83 -35
  13. data/lib/pry/default_commands/documentation.rb +37 -31
  14. data/lib/pry/default_commands/easter_eggs.rb +5 -0
  15. data/lib/pry/default_commands/input.rb +13 -10
  16. data/lib/pry/default_commands/introspection.rb +54 -40
  17. data/lib/pry/default_commands/shell.rb +9 -5
  18. data/lib/pry/helpers/base_helpers.rb +16 -5
  19. data/lib/pry/helpers/command_helpers.rb +41 -17
  20. data/lib/pry/helpers/text.rb +2 -1
  21. data/lib/pry/history.rb +61 -0
  22. data/lib/pry/plugins.rb +19 -8
  23. data/lib/pry/pry_class.rb +25 -62
  24. data/lib/pry/pry_instance.rb +105 -120
  25. data/lib/pry/version.rb +1 -1
  26. data/pry.gemspec +15 -14
  27. data/test/helper.rb +31 -0
  28. data/test/test_command_set.rb +7 -2
  29. data/test/test_completion.rb +7 -3
  30. data/test/test_default_commands/test_context.rb +185 -1
  31. data/test/test_default_commands/test_documentation.rb +10 -0
  32. data/test/test_default_commands/test_input.rb +16 -11
  33. data/test/test_default_commands/test_introspection.rb +10 -0
  34. data/test/test_default_commands/test_shell.rb +18 -0
  35. data/test/test_pry.rb +189 -40
  36. data/test/test_pry_history.rb +13 -13
  37. data/test/test_pry_output.rb +44 -0
  38. data/test/test_special_locals.rb +35 -0
  39. metadata +182 -173
@@ -1,3 +1,3 @@
1
1
  class Pry
2
- VERSION = "0.9.4pre1"
2
+ VERSION = "0.9.4pre2"
3
3
  end
@@ -1,20 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.unshift File.expand_path('../lib', __FILE__)
3
- require 'pry/version'
4
2
 
5
3
  Gem::Specification.new do |s|
6
4
  s.name = %q{pry}
7
- s.version = Pry::VERSION
5
+ s.version = "0.9.4pre1"
8
6
 
9
7
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
8
  s.authors = [%q{John Mair (banisterfiend)}]
11
- s.description = %q{an IRB alternative and runtime developer console}
9
+ s.date = %q{2011-09-07}
10
+ s.description = %q{An IRB alternative and runtime developer console}
12
11
  s.email = %q{jrmair@gmail.com}
13
12
  s.executables = [%q{pry}]
14
- s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.yardopts}, %q{CHANGELOG}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/version.rb}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/testrc}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
15
- s.homepage = %q{http://banisterfiend.wordpress.com}
16
- s.summary = %q{an IRB alternative and runtime developer console}
17
- s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/testrc}]
13
+ s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.yardopts}, %q{CHANGELOG}, %q{CONTRIBUTORS}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/version.rb}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/testrc}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
14
+ s.homepage = %q{http://pry.github.com}
15
+ s.require_paths = [%q{lib}]
16
+ s.rubygems_version = %q{1.8.6}
17
+ s.summary = %q{An IRB alternative and runtime developer console}
18
+ s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/testrc}]
18
19
 
19
20
  if s.respond_to? :specification_version then
20
21
  s.specification_version = 3
@@ -22,23 +23,23 @@ Gem::Specification.new do |s|
22
23
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23
24
  s.add_runtime_dependency(%q<ruby_parser>, [">= 2.0.5"])
24
25
  s.add_runtime_dependency(%q<coderay>, [">= 0.9.8"])
25
- s.add_runtime_dependency(%q<slop>, ["~> 1.7.0"])
26
- s.add_runtime_dependency(%q<method_source>, [">= 0.4.0"])
26
+ s.add_runtime_dependency(%q<slop>, ["~> 2.1.0"])
27
+ s.add_runtime_dependency(%q<method_source>, [">= 0.6.0"])
27
28
  s.add_development_dependency(%q<bacon>, [">= 1.1.0"])
28
29
  s.add_development_dependency(%q<open4>, ["~> 1.0.1"])
29
30
  else
30
31
  s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
31
32
  s.add_dependency(%q<coderay>, [">= 0.9.8"])
32
- s.add_dependency(%q<slop>, ["~> 1.7.0"])
33
- s.add_dependency(%q<method_source>, [">= 0.4.0"])
33
+ s.add_dependency(%q<slop>, ["~> 2.1.0"])
34
+ s.add_dependency(%q<method_source>, [">= 0.6.0"])
34
35
  s.add_dependency(%q<bacon>, [">= 1.1.0"])
35
36
  s.add_dependency(%q<open4>, ["~> 1.0.1"])
36
37
  end
37
38
  else
38
39
  s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
39
40
  s.add_dependency(%q<coderay>, [">= 0.9.8"])
40
- s.add_dependency(%q<slop>, ["~> 1.7.0"])
41
- s.add_dependency(%q<method_source>, [">= 0.4.0"])
41
+ s.add_dependency(%q<slop>, ["~> 2.1.0"])
42
+ s.add_dependency(%q<method_source>, [">= 0.6.0"])
42
43
  s.add_dependency(%q<bacon>, [">= 1.1.0"])
43
44
  s.add_dependency(%q<open4>, ["~> 1.0.1"])
44
45
  end
@@ -25,13 +25,33 @@ class << Pry
25
25
  end
26
26
  end
27
27
 
28
+ # are we on Jruby platform?
29
+ def jruby?
30
+ defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
31
+ end
32
+
33
+ # are we on rbx platform?
34
+ def rbx?
35
+ defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
36
+ end
37
+
28
38
  Pry.reset_defaults
29
39
 
40
+ # this is to test exception code (cat --ex)
41
+ def broken_method
42
+ this method is broken
43
+ end
44
+
30
45
  # sample doc
31
46
  def sample_method
32
47
  :sample
33
48
  end
34
49
 
50
+ # another sample doc
51
+ def another_sample_method
52
+ :another_sample
53
+ end
54
+
35
55
  def redirect_pry_io(new_in, new_out)
36
56
  old_in = Pry.input
37
57
  old_out = Pry.output
@@ -46,6 +66,17 @@ def redirect_pry_io(new_in, new_out)
46
66
  end
47
67
  end
48
68
 
69
+ def mock_pry(*args)
70
+ input = InputTester.new(*args)
71
+ output = StringIO.new
72
+
73
+ redirect_pry_io(input, output) do
74
+ Pry.start
75
+ end
76
+
77
+ output.string
78
+ end
79
+
49
80
  def redirect_global_pry_input(new_io)
50
81
  old_io = Pry.input
51
82
  Pry.input = new_io
@@ -112,9 +112,9 @@ describe Pry::CommandSet do
112
112
  @set.commands['foo'].description.should == 'baz'
113
113
  end
114
114
 
115
- it 'should return nil for commands by default' do
115
+ it 'should return Pry::CommandContext::VOID_VALUE for commands by default' do
116
116
  @set.command('foo') { 3 }
117
- @set.run_command(nil, 'foo').should == nil
117
+ @set.run_command(nil, 'foo').should == Pry::CommandContext::VOID_VALUE
118
118
  end
119
119
 
120
120
  it 'should be able to keep return values' do
@@ -122,6 +122,11 @@ describe Pry::CommandSet do
122
122
  @set.run_command(nil, 'foo').should == 3
123
123
  end
124
124
 
125
+ it 'should be able to keep return values, even if return value is nil' do
126
+ @set.command('foo', '', :keep_retval => true) { nil }
127
+ @set.run_command(nil, 'foo').should == nil
128
+ end
129
+
125
130
  it 'should be able to have its own helpers' do
126
131
  @set.command('foo') do
127
132
  should.respond_to :my_helper
@@ -15,9 +15,13 @@ describe Pry::InputCompleter do
15
15
  Object.remove_const :SymbolyName
16
16
  end
17
17
 
18
- it "should not crash if there's a Module that has a symbolic name." do
19
- completer = Pry::InputCompleter.build_completion_proc(Pry.binding_for(Object.new))
20
- lambda{ completer.call "a.to_s." }.should.not.raise Exception
18
+ # another jruby hack :((
19
+ if !jruby?
20
+ it "should not crash if there's a Module that has a symbolic name." do
21
+ completer = Pry::InputCompleter.build_completion_proc(Pry.binding_for(Object.new))
22
+ binding.pry
23
+ lambda{ completer.call "a.to_s." }.should.not.raise Exception
24
+ end
21
25
  end
22
26
  end
23
27
 
@@ -1,6 +1,104 @@
1
1
  require 'helper'
2
2
 
3
3
  describe "Pry::DefaultCommands::Context" do
4
+ describe "exit-all" do
5
+ it 'should break out of the repl loop of Pry instance (returning target of session)' do
6
+ redirect_pry_io(InputTester.new("exit-all"), StringIO.new) do
7
+ Pry.new.repl(0).should == 0
8
+ end
9
+ end
10
+
11
+ it 'should break out of the repl loop of Pry instance wth a user specified value' do
12
+ redirect_pry_io(InputTester.new("exit-all 'message'"), StringIO.new) do
13
+ Pry.new.repl(0).should == 'message'
14
+ end
15
+ end
16
+
17
+ it 'should break of the repl loop even if multiple bindings still on stack' do
18
+ ins = nil
19
+ redirect_pry_io(InputTester.new("cd 1", "cd 2", "exit-all 'message'"), StringIO.new) do
20
+ ins = Pry.new.tap { |v| v.repl(0).should == 'message' }
21
+ end
22
+ end
23
+
24
+ it 'binding_stack should be empty after breaking out of the repl loop' do
25
+ ins = nil
26
+ redirect_pry_io(InputTester.new("cd 1", "cd 2", "exit-all"), StringIO.new) do
27
+ ins = Pry.new.tap { |v| v.repl(0) }
28
+ end
29
+
30
+ ins.binding_stack.empty?.should == true
31
+ end
32
+ end
33
+
34
+ describe "exit" do
35
+ it 'should pop a binding with exit' do
36
+ b = Pry.binding_for(:outer)
37
+ b.eval("x = :inner")
38
+
39
+ redirect_pry_io(InputTester.new("cd x", "$inner = self;", "exit", "$outer = self", "exit-all"), StringIO.new) do
40
+ b.pry
41
+ end
42
+ $inner.should == :inner
43
+ $outer.should == :outer
44
+ end
45
+
46
+ it 'should break out of the repl loop of Pry instance when binding_stack has only one binding with exit' do
47
+ Pry.start(0, :input => StringIO.new("exit")).should == 0
48
+ end
49
+
50
+ it 'should break out of the repl loop of Pry instance when binding_stack has only one binding with exit, and return user-given value' do
51
+ Pry.start(0, :input => StringIO.new("exit :john")).should == :john
52
+ end
53
+ end
54
+
55
+ describe "jump-to" do
56
+ it 'should jump to the proper binding index in the stack' do
57
+ outp = StringIO.new
58
+ redirect_pry_io(InputTester.new("cd 1", "cd 2", "jump-to 1", "$blah = self", "exit-all"), outp) do
59
+ Pry.start(0)
60
+ end
61
+
62
+ $blah.should == 1
63
+ end
64
+
65
+ it 'should print error when trying to jump to a non-existent binding index' do
66
+ outp = StringIO.new
67
+ redirect_pry_io(InputTester.new("cd 1", "cd 2", "jump-to 100", "exit-all"), outp) do
68
+ Pry.start(0)
69
+ end
70
+
71
+ outp.string.should =~ /Invalid nest level/
72
+ end
73
+
74
+ it 'should print error when trying to jump to the same binding index' do
75
+ outp = StringIO.new
76
+ redirect_pry_io(InputTester.new("cd 1", "cd 2", "jump-to 2", "exit-all"), outp) do
77
+ Pry.new.repl(0)
78
+ end
79
+
80
+ outp.string.should =~ /Already/
81
+ end
82
+ end
83
+
84
+ describe "exit-program" do
85
+ it 'should raise SystemExit' do
86
+ redirect_pry_io(InputTester.new("exit-program"), StringIO.new) do
87
+ lambda { Pry.new.repl(0).should == 0 }.should.raise SystemExit
88
+ end
89
+ end
90
+
91
+ it 'should exit the program with the provided value' do
92
+ redirect_pry_io(InputTester.new("exit-program 66"), StringIO.new) do
93
+ begin
94
+ Pry.new.repl(0)
95
+ rescue SystemExit => e
96
+ e.status.should == 66
97
+ end
98
+ end
99
+ end
100
+ end
101
+
4
102
  describe "cd" do
5
103
  after do
6
104
  $obj = nil
@@ -28,6 +126,10 @@ describe "Pry::DefaultCommands::Context" do
28
126
  $outer.should == :outer
29
127
  end
30
128
 
129
+ it 'should break out of the repl loop of Pry instance when binding_stack has only one binding with cd ..' do
130
+ Pry.start(0, :input => StringIO.new("cd ..")).should == 0
131
+ end
132
+
31
133
  it 'should break out to outer-most session with cd /' do
32
134
  b = Pry.binding_for(:outer)
33
135
  b.eval("x = :inner")
@@ -40,9 +142,91 @@ describe "Pry::DefaultCommands::Context" do
40
142
  $outer.should == :outer
41
143
  end
42
144
 
43
- it 'should start a session on TOPLEVEL_BINDING with cd ::' do
145
+ it 'should break out to outer-most session with just cd (no args)' do
44
146
  b = Pry.binding_for(:outer)
147
+ b.eval("x = :inner")
148
+
149
+ redirect_pry_io(InputTester.new("cd x", "$inner = self;", "cd 5", "$five = self", "cd", "$outer = self", "exit-all"), StringIO.new) do
150
+ b.pry
151
+ end
152
+ $inner.should == :inner
153
+ $five.should == 5
154
+ $outer.should == :outer
155
+ end
156
+
157
+ it 'should cd into an object and its ivar using cd obj/@ivar syntax' do
158
+ $obj = Object.new
159
+ $obj.instance_variable_set(:@x, 66)
160
+
161
+ redirect_pry_io(InputTester.new("cd $obj/@x", "$result = _pry_.binding_stack.dup", "exit-all"), StringIO.new) do
162
+ Pry.start
163
+ end
164
+ $result.size.should == 3
165
+ $result[1].eval('self').should == $obj
166
+ $result[2].eval('self').should == 66
167
+ end
45
168
 
169
+ it 'should cd into an object and its ivar using cd obj/@ivar/ syntax (note following /)' do
170
+ $obj = Object.new
171
+ $obj.instance_variable_set(:@x, 66)
172
+
173
+ redirect_pry_io(InputTester.new("cd $obj/@x/", "$result = _pry_.binding_stack.dup", "exit-all"), StringIO.new) do
174
+ Pry.start
175
+ end
176
+ $result.size.should == 3
177
+ $result[1].eval('self').should == $obj
178
+ $result[2].eval('self').should == 66
179
+ end
180
+
181
+ it 'should cd into previous object and its local using cd ../local syntax' do
182
+ $obj = Object.new
183
+ $obj.instance_variable_set(:@x, 66)
184
+
185
+ redirect_pry_io(InputTester.new("cd $obj", "local = :local", "cd @x", "cd ../local", "$result = _pry_.binding_stack.dup", "exit-all"), StringIO.new) do
186
+ Pry.start
187
+ end
188
+ $result.size.should == 3
189
+ $result[1].eval('self').should == $obj
190
+ $result[2].eval('self').should == :local
191
+ end
192
+
193
+ it 'should cd into an object and its ivar and back again using cd obj/@ivar/.. syntax' do
194
+ $obj = Object.new
195
+ $obj.instance_variable_set(:@x, 66)
196
+
197
+ redirect_pry_io(InputTester.new("cd $obj/@x/..", "$result = _pry_.binding_stack.dup", "exit-all"), StringIO.new) do
198
+ Pry.start
199
+ end
200
+ $result.size.should == 2
201
+ $result[1].eval('self').should == $obj
202
+ end
203
+
204
+ it 'should cd into an object and its ivar and back and then into another ivar using cd obj/@ivar/../@y syntax' do
205
+ $obj = Object.new
206
+ $obj.instance_variable_set(:@x, 66)
207
+ $obj.instance_variable_set(:@y, 79)
208
+
209
+ redirect_pry_io(InputTester.new("cd $obj/@x/../@y", "$result = _pry_.binding_stack.dup", "exit-all"), StringIO.new) do
210
+ Pry.start
211
+ end
212
+ $result.size.should == 3
213
+ $result[1].eval('self').should == $obj
214
+ $result[2].eval('self').should == 79
215
+ end
216
+
217
+ it 'should cd back to top-level and then into another ivar using cd /@ivar/ syntax' do
218
+ $obj = Object.new
219
+ $obj.instance_variable_set(:@x, 66)
220
+ TOPLEVEL_BINDING.eval('@z = 20')
221
+
222
+ redirect_pry_io(InputTester.new("cd $obj/@x/", "cd /@z", "$result = _pry_.binding_stack.dup", "exit-all"), StringIO.new) do
223
+ Pry.start
224
+ end
225
+ $result.size.should == 2
226
+ $result[1].eval('self').should == 20
227
+ end
228
+
229
+ it 'should start a session on TOPLEVEL_BINDING with cd ::' do
46
230
  redirect_pry_io(InputTester.new("cd ::", "$obj = self", "exit-all"), StringIO.new) do
47
231
  5.pry
48
232
  end
@@ -10,6 +10,16 @@ describe "Pry::DefaultCommands::Documentation" do
10
10
 
11
11
  str_output.string.should =~ /sample doc/
12
12
  end
13
+
14
+ it 'should output multiple methods\' documentation' do
15
+ str_output = StringIO.new
16
+ redirect_pry_io(InputTester.new("show-doc sample_method another_sample_method", "exit-all"), str_output) do
17
+ pry
18
+ end
19
+
20
+ str_output.string.should =~ /sample doc/
21
+ str_output.string.should =~ /another sample doc/
22
+ end
13
23
 
14
24
  it 'should output a method\'s documentation if inside method without needing to use method name' do
15
25
  $str_output = StringIO.new
@@ -150,19 +150,24 @@ describe "Pry::DefaultCommands::Input" do
150
150
  end
151
151
 
152
152
  describe "play" do
153
- it 'should play a string of code (with no args)' do
154
- redirect_pry_io(InputTester.new("play :test_string", "exit-all"), str_output = StringIO.new) do
155
- pry
153
+ it 'should play a string variable (with no args)' do
154
+ b = binding
155
+ b.eval('x = "\"hello\""')
156
+ redirect_pry_io(InputTester.new("play x", "exit-all"), str_output = StringIO.new) do
157
+ Pry.start b, :hooks => {}
156
158
  end
157
- str_output.string.should =~ /:test_string/
159
+ str_output.string.should =~ /hello/
158
160
  end
159
161
 
160
- it 'should play an interpolated string of code (with no args)' do
161
- $obj = ":test_string_interpolated"
162
- redirect_pry_io(InputTester.new('play #{$obj}', "exit-all"), str_output = StringIO.new) do
163
- pry
162
+ it 'should play a string variable (with no args) using --lines to select what to play' do
163
+ b = binding
164
+ b.eval('x = "\"hello\"\n\"goodbye\"\n\"love\""')
165
+ redirect_pry_io(InputTester.new("play x --lines 1", "exit-all"), str_output = StringIO.new) do
166
+ Pry.start b, :hooks => {}
164
167
  end
165
- str_output.string.should =~ /:test_string_interpolated/
168
+ str_output.string.should =~ /hello/
169
+ str_output.string.should.not =~ /love/
170
+ str_output.string.should.not =~ /goodbye/
166
171
  end
167
172
 
168
173
  it 'should play a method with the -m switch (a single line)' do
@@ -202,8 +207,8 @@ describe "Pry::DefaultCommands::Input" do
202
207
  end
203
208
 
204
209
  before do
205
- Readline::HISTORY.shift until Readline::HISTORY.empty?
206
- @hist = Readline::HISTORY
210
+ Pry.history.clear
211
+ @hist = Pry.history
207
212
  end
208
213
 
209
214
  it 'should display the correct history' do
@@ -10,6 +10,16 @@ describe "Pry::DefaultCommands::Introspection" do
10
10
 
11
11
  str_output.string.should =~ /def sample/
12
12
  end
13
+
14
+ it 'should output multiple methods\' sources' do
15
+ str_output = StringIO.new
16
+ redirect_pry_io(InputTester.new("show-method sample_method another_sample_method", "exit-all"), str_output) do
17
+ pry
18
+ end
19
+
20
+ str_output.string.should =~ /def sample/
21
+ str_output.string.should =~ /def another_sample/
22
+ end
13
23
 
14
24
  it 'should output a method\'s source with line numbers' do
15
25
  str_output = StringIO.new
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ describe "Pry::DefaultCommands::Shell" do
4
+ describe "cat" do
5
+
6
+ # this doesnt work so well on rbx due to differences in backtrace
7
+ # so we currently skip rbx until we figure out a workaround
8
+ if !rbx?
9
+ it 'cat --ex should give warning when exception is raised in repl' do
10
+ mock_pry("this raises error", "cat --ex").should =~ /Cannot cat exceptions raised in REPL/
11
+ end
12
+
13
+ it 'cat --ex should correctly display code that generated exception' do
14
+ mock_pry("broken_method", "cat --ex").should =~ /this method is broken/
15
+ end
16
+ end
17
+ end
18
+ end