pry 0.9.5 → 0.9.6

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.
@@ -0,0 +1,17 @@
1
+ require 'helper'
2
+
3
+ describe "Pry.config.exception_whitelist" do
4
+ it 'should rescue all exceptions NOT specified on whitelist' do
5
+ Pry.config.exception_whitelist.include?(NameError).should == false
6
+ lambda { Pry.start(self, :input => StringIO.new("raise NameError\nexit"), :output => StringIO.new) }.should.not.raise NameError
7
+ end
8
+
9
+ it 'should NOT rescue exceptions specified on whitelist' do
10
+ old_whitelist = Pry.config.exception_whitelist
11
+ Pry.config.exception_whitelist = [NameError]
12
+ lambda { Pry.start(self, :input => StringIO.new("raise NameError"), :output => StringIO.new) }.should.raise NameError
13
+ Pry.config.exception_whitelist = old_whitelist
14
+ end
15
+ end
16
+
17
+
@@ -0,0 +1,70 @@
1
+ require 'helper'
2
+
3
+ describe "Pry#input_stack" do
4
+ it 'should accept :input_stack as a config option' do
5
+ stack = [StringIO.new("test")]
6
+ Pry.new(:input_stack => stack).input_stack.should == stack
7
+ end
8
+
9
+ it 'should use defaults from Pry.config' do
10
+ Pry.config.input_stack = [StringIO.new("exit")]
11
+ Pry.new.input_stack.should == Pry.config.input_stack
12
+ Pry.config.input_stack = []
13
+ end
14
+
15
+ it 'should read from all input objects on stack and exit session (usingn repl)' do
16
+ stack = [b = StringIO.new(":cloister\nexit\n"), c = StringIO.new(":baron\n")]
17
+ instance = Pry.new(:input => StringIO.new(":alex\n"),
18
+ :output => str_output = StringIO.new,
19
+ :input_stack => stack)
20
+
21
+ instance.repl
22
+ str_output.string.should =~ /:alex/
23
+ str_output.string.should =~ /:baron/
24
+ str_output.string.should =~ /:cloister/
25
+ end
26
+
27
+ it 'input objects should be popped off stack as they are used up' do
28
+ stack = [StringIO.new(":cloister\n"), StringIO.new(":baron\n")]
29
+ instance = Pry.new(:input => StringIO.new(":alex\n"),
30
+ :output => str_output = StringIO.new,
31
+ :input_stack => stack)
32
+
33
+ stack.size.should == 2
34
+
35
+ instance.rep
36
+ str_output.string.should =~ /:alex/
37
+ instance.rep
38
+ str_output.string.should =~ /:baron/
39
+ stack.size.should == 1
40
+ instance.rep
41
+ str_output.string.should =~ /:cloister/
42
+ stack.size.should == 0
43
+ end
44
+
45
+ it 'should revert to Pry.config.input when it runs out of input objects in input_stack' do
46
+ redirect_pry_io(StringIO.new(":rimbaud\nexit\n"), StringIO.new) do
47
+ stack = [StringIO.new(":cloister\n"), StringIO.new(":baron\n")]
48
+ instance = Pry.new(:input => StringIO.new(":alex\n"),
49
+ :output => str_output = StringIO.new,
50
+ :input_stack => stack)
51
+
52
+ instance.repl
53
+ str_output.string.should =~ /:alex/
54
+ str_output.string.should =~ /:baron/
55
+ str_output.string.should =~ /:cloister/
56
+ str_output.string.should =~ /:rimbaud/
57
+ end
58
+ end
59
+
60
+ it 'should display error and throw(:breakout) if at end of input after using up input_stack objects' do
61
+ str_output = StringIO.new
62
+ catch(:breakout) do
63
+ redirect_pry_io(StringIO.new(":rimbaud\n"), str_output) do
64
+ Pry.new(:input_stack => [StringIO.new(":a\n"), StringIO.new(":b\n")]).repl
65
+ end
66
+ end
67
+ str_output.string.should =~ /Error: Pry ran out of things to read/
68
+ end
69
+
70
+ end
@@ -1,10 +1,5 @@
1
1
  require 'helper'
2
2
 
3
- puts "Ruby Version #{RUBY_VERSION}"
4
- puts "Testing Pry #{Pry::VERSION}"
5
- puts "With method_source version #{MethodSource::VERSION}"
6
- puts "--"
7
-
8
3
  describe Pry do
9
4
 
10
5
  if RUBY_PLATFORM !~ /mingw/ && RUBY_PLATFORM !~ /mswin/ && RUBY_PLATFORM != 'java'
@@ -19,7 +14,6 @@ describe Pry do
19
14
 
20
15
  if RUBY_VERSION =~ /1.9/
21
16
  describe "Exotic object support" do
22
-
23
17
  # regression test for exotic object support
24
18
  it "Should not error when return value is a BasicObject instance" do
25
19
 
@@ -64,7 +58,7 @@ describe Pry do
64
58
  o = Object.new
65
59
  pry_tester = Pry.new(:input => StringIO.new(input_string),
66
60
  :output => str_output,
67
- :exception_handler => proc { |_, exception| @excep = exception },
61
+ :exception_handler => proc { |_, exception, _pry_| @excep = exception },
68
62
  :print => proc {}
69
63
  ).rep(o)
70
64
 
@@ -92,16 +86,14 @@ describe Pry do
92
86
  o.instance_variable_get(:@x).should == 10
93
87
  end
94
88
 
95
- it 'should not output anything for no input' do
96
- outp = StringIO.new
97
-
98
- # note i could not use mock_pry() for this test for some
99
- # reason, as i'd always get "\n" as output instead of ""
100
- redirect_pry_io(StringIO.new(""), outp) do
101
- Pry.new.rep(self)
89
+ it 'should display error and throw(:breakout) if Pry instance runs out of input' do
90
+ str_output = StringIO.new
91
+ catch(:breakout) do
92
+ redirect_pry_io(StringIO.new(":nothing\n"), str_output) do
93
+ Pry.new.repl
94
+ end
102
95
  end
103
-
104
- outp.string.empty?.should == true
96
+ str_output.string.should =~ /Error: Pry ran out of things to read/
105
97
  end
106
98
 
107
99
  it 'should make self evaluate to the receiver of the rep session' do
@@ -146,7 +138,6 @@ describe Pry do
146
138
  str_output.string.should == ""
147
139
  end
148
140
 
149
-
150
141
  it 'should suppress output if input ends in a ";" (multi-line)' do
151
142
  o = Object.new
152
143
  str_output = StringIO.new
@@ -189,6 +180,19 @@ describe Pry do
189
180
  end
190
181
  end
191
182
 
183
+ describe "Pry#run_command" do
184
+ it 'should run a command in a specified context' do
185
+ b = Pry.binding_for(7)
186
+ p = Pry.new(:output => StringIO.new)
187
+ p.run_command("ls -m", b)
188
+ p.output.string.should =~ /divmod/
189
+ end
190
+
191
+ it 'should run a command in the context of a session' do
192
+ mock_pry("@session_ivar = 10", "_pry_.run_command('ls')").should =~ /@session_ivar/
193
+ end
194
+ end
195
+
192
196
  describe "repl" do
193
197
  describe "basic functionality" do
194
198
  it 'should set an ivar on an object and exit the repl' do
@@ -559,14 +563,14 @@ describe Pry do
559
563
 
560
564
  it 'should NOT try to interpolate pure ruby code (no commands) ' do
561
565
  str_output = StringIO.new
562
- Pry.new(:input => StringIO.new('puts \'#{aggy}\''), :output => str_output).rep
566
+ Pry.new(:input => StringIO.new('format \'#{aggy}\''), :output => str_output).rep
563
567
  str_output.string.should.not =~ /NameError/
564
568
 
565
- Pry.new(:input => StringIO.new('puts #{aggy}'), :output => str_output).rep
569
+ Pry.new(:input => StringIO.new('format #{aggy}'), :output => str_output).rep
566
570
  str_output.string.should.not =~ /NameError/
567
571
 
568
572
  $test_interpolation = "blah"
569
- Pry.new(:input => StringIO.new('puts \'#{$test_interpolation}\''), :output => str_output).rep
573
+ Pry.new(:input => StringIO.new('format \'#{$test_interpolation}\''), :output => str_output).rep
570
574
 
571
575
  str_output.string.should.not =~ /blah/
572
576
  $test_interpolation = nil
@@ -1136,9 +1140,9 @@ describe Pry do
1136
1140
  end
1137
1141
 
1138
1142
  describe "given the 'main' object" do
1139
- it "returns the #inspect of main (special case)" do
1143
+ it "returns the #to_s of main (special case)" do
1140
1144
  o = TOPLEVEL_BINDING.eval('self')
1141
- Pry.view_clip(o, VC_MAX_LENGTH).should == o.inspect
1145
+ Pry.view_clip(o, VC_MAX_LENGTH).should == o.to_s
1142
1146
  end
1143
1147
  end
1144
1148
 
@@ -16,7 +16,7 @@ describe Pry do
16
16
  it "should display serialization exceptions" do
17
17
  Pry.config.print = lambda { |*a| raise "catch-22" }
18
18
 
19
- mock_pry("1").should =~ /output error: #<RuntimeError: catch-22>/
19
+ mock_pry("1").should =~ /\(pry\) output error: #<RuntimeError: catch-22>/
20
20
  end
21
21
 
22
22
  it "should catch errors serializing exceptions" do
@@ -24,7 +24,7 @@ describe Pry do
24
24
  raise Exception.new("catch-22").tap{ |e| class << e; def inspect; raise e; end; end }
25
25
  end
26
26
 
27
- mock_pry("1").should =~ /output error: failed to show result/
27
+ mock_pry("1").should =~ /\(pry\) output error: failed to show result/
28
28
  end
29
29
  end
30
30
 
@@ -36,9 +36,5 @@ describe Pry do
36
36
  it "should not be phased by un-inspectable things" do
37
37
  mock_pry("class NastyClass; undef pretty_inspect; end", "NastyClass.new").should =~ /#<NastyClass:0x[0-9a-f]+>/
38
38
  end
39
-
40
- it "should warn you about un-inspectable things" do
41
- mock_pry("class NastyClass; undef pretty_inspect; end", "NastyClass.new").should =~ /output error: #<(NoMethodError|NameError): undefined method `pretty_inspect'/
42
- end
43
39
  end
44
40
  end
metadata CHANGED
@@ -1,98 +1,96 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pry
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.6
4
5
  prerelease:
5
- version: 0.9.5
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - John Mair (banisterfiend)
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-09-09 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-09-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: ruby_parser
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70165027600780 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 2.0.5
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: coderay
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70165027600780
25
+ - !ruby/object:Gem::Dependency
26
+ name: coderay
27
+ requirement: &70165027599520 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
34
32
  version: 0.9.8
35
33
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: slop
39
34
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70165027599520
36
+ - !ruby/object:Gem::Dependency
37
+ name: slop
38
+ requirement: &70165027598380 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
40
+ requirements:
43
41
  - - ~>
44
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
45
43
  version: 2.1.0
46
44
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: method_source
50
45
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70165027598380
47
+ - !ruby/object:Gem::Dependency
48
+ name: method_source
49
+ requirement: &70165027597600 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
56
54
  version: 0.6.5
57
55
  type: :runtime
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: bacon
61
56
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70165027597600
58
+ - !ruby/object:Gem::Dependency
59
+ name: bacon
60
+ requirement: &70165027596860 !ruby/object:Gem::Requirement
63
61
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
67
65
  version: 1.1.0
68
66
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: open4
72
67
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *70165027596860
69
+ - !ruby/object:Gem::Dependency
70
+ name: open4
71
+ requirement: &70165027596300 !ruby/object:Gem::Requirement
74
72
  none: false
75
- requirements:
73
+ requirements:
76
74
  - - ~>
77
- - !ruby/object:Gem::Version
75
+ - !ruby/object:Gem::Version
78
76
  version: 1.0.1
79
77
  type: :development
80
- version_requirements: *id006
78
+ prerelease: false
79
+ version_requirements: *70165027596300
81
80
  description: An IRB alternative and runtime developer console
82
81
  email: jrmair@gmail.com
83
- executables:
82
+ executables:
84
83
  - pry
85
84
  extensions: []
86
-
87
85
  extra_rdoc_files: []
88
-
89
- files:
86
+ files:
90
87
  - .document
91
88
  - .gemtest
92
89
  - .gitignore
93
90
  - .yardopts
94
91
  - CHANGELOG
95
92
  - CONTRIBUTORS
93
+ - Gemfile
96
94
  - LICENSE
97
95
  - README.markdown
98
96
  - Rakefile
@@ -152,7 +150,9 @@ files:
152
150
  - test/test_default_commands/test_input.rb
153
151
  - test/test_default_commands/test_introspection.rb
154
152
  - test/test_default_commands/test_shell.rb
153
+ - test/test_exception_whitelist.rb
155
154
  - test/test_history_array.rb
155
+ - test/test_input_stack.rb
156
156
  - test/test_pry.rb
157
157
  - test/test_pry_history.rb
158
158
  - test/test_pry_output.rb
@@ -162,32 +162,29 @@ files:
162
162
  - wiki/Home.md
163
163
  homepage: http://pry.github.com
164
164
  licenses: []
165
-
166
165
  post_install_message:
167
166
  rdoc_options: []
168
-
169
- require_paths:
167
+ require_paths:
170
168
  - lib
171
- required_ruby_version: !ruby/object:Gem::Requirement
169
+ required_ruby_version: !ruby/object:Gem::Requirement
172
170
  none: false
173
- requirements:
174
- - - ">="
175
- - !ruby/object:Gem::Version
176
- version: "0"
177
- required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
176
  none: false
179
- requirements:
180
- - - ">="
181
- - !ruby/object:Gem::Version
182
- version: "0"
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
183
181
  requirements: []
184
-
185
182
  rubyforge_project:
186
- rubygems_version: 1.7.2
183
+ rubygems_version: 1.8.6
187
184
  signing_key:
188
185
  specification_version: 3
189
186
  summary: An IRB alternative and runtime developer console
190
- test_files:
187
+ test_files:
191
188
  - test/helper.rb
192
189
  - test/test_command_helpers.rb
193
190
  - test/test_command_processor.rb
@@ -200,7 +197,9 @@ test_files:
200
197
  - test/test_default_commands/test_input.rb
201
198
  - test/test_default_commands/test_introspection.rb
202
199
  - test/test_default_commands/test_shell.rb
200
+ - test/test_exception_whitelist.rb
203
201
  - test/test_history_array.rb
202
+ - test/test_input_stack.rb
204
203
  - test/test_pry.rb
205
204
  - test/test_pry_history.rb
206
205
  - test/test_pry_output.rb