pry 0.9.8pre2-java → 0.9.8pre3-java

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.
@@ -16,7 +16,7 @@ describe Pry::InputCompleter do
16
16
  end
17
17
 
18
18
  # another jruby hack :((
19
- if !jruby?
19
+ if !Pry::Helpers::BaseHelpers.jruby?
20
20
  it "should not crash if there's a Module that has a symbolic name." do
21
21
  completer = Pry::InputCompleter.build_completion_proc(Pry.binding_for(Object.new))
22
22
  lambda{ completer.call "a.to_s." }.should.not.raise Exception
@@ -7,8 +7,7 @@ describe "Pry::Commands" do
7
7
  redirect_pry_io(InputTester.new("help ls", "exit-all"), str_output) do
8
8
  pry
9
9
  end
10
- str_output.string.each_line.count.should == 1
11
- str_output.string.should =~ /ls --help/
10
+ str_output.string.should =~ /Usage: ls/
12
11
  end
13
12
 
14
13
  it 'should display help for a regex command with a "listing"' do
@@ -53,7 +53,7 @@ describe "Pry::DefaultCommands::Introspection" do
53
53
 
54
54
  mock_pry("edit #{path}", "$rand").should =~ /#{@rand}/
55
55
 
56
- tf.close
56
+ tf.close(true)
57
57
  end
58
58
 
59
59
  it "should not reload the file if it is not a ruby file" do
@@ -62,7 +62,7 @@ describe "Pry::DefaultCommands::Introspection" do
62
62
 
63
63
  mock_pry("edit #{path}", "$rand").should.not =~ /#{@rand}/
64
64
 
65
- tf.close
65
+ tf.close(true)
66
66
  end
67
67
 
68
68
  it "should not reload a ruby file if -n is given" do
@@ -71,7 +71,7 @@ describe "Pry::DefaultCommands::Introspection" do
71
71
 
72
72
  mock_pry("edit -n #{path}", "$rand").should.not =~ /#{@rand}/
73
73
 
74
- tf.close
74
+ tf.close(true)
75
75
  end
76
76
 
77
77
  it "should reload a non-ruby file if -r is given" do
@@ -80,7 +80,7 @@ describe "Pry::DefaultCommands::Introspection" do
80
80
 
81
81
  mock_pry("edit -r #{path}", "$rand").should =~ /#{@rand}/
82
82
 
83
- tf.close
83
+ tf.close(true)
84
84
  end
85
85
  end
86
86
  end
@@ -93,7 +93,7 @@ describe "Pry::DefaultCommands::Introspection" do
93
93
  @tf.flush
94
94
  end
95
95
  after do
96
- @tf.close
96
+ @tf.close(true)
97
97
  File.unlink("#{@path}c") if File.exists?("#{@path}c") #rbx
98
98
  end
99
99
  it "should open the correct file" do
@@ -455,7 +455,7 @@ describe "Pry::DefaultCommands::Introspection" do
455
455
  end
456
456
 
457
457
  after do
458
- @tempfile.close
458
+ @tempfile.close(true)
459
459
  end
460
460
 
461
461
  describe 'without -p' do
@@ -92,7 +92,7 @@ describe "ls" do
92
92
  describe "when no arguments given" do
93
93
  describe "when at the top-level" do
94
94
  # rubinius has a bug that means local_variables of "main" aren't reported inside eval()
95
- unless defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
95
+ unless Pry::Helpers::BaseHelpers.rbx?
96
96
  it "should show local variables" do
97
97
  mock_pry("ls").should =~ /_pry_/
98
98
  mock_pry("arbitrar = 1", "ls").should =~ /arbitrar/
@@ -47,7 +47,7 @@ describe "Pry::DefaultCommands::Shell" do
47
47
  # this doesnt work so well on rbx due to differences in backtrace
48
48
  # so we currently skip rbx until we figure out a workaround
49
49
  describe "with --ex" do
50
- if !rbx?
50
+ if !Pry::Helpers::BaseHelpers.rbx?
51
51
  it 'cat --ex should correctly display code that generated exception even if raised in repl' do
52
52
  mock_pry("this raises error", "cat --ex").should =~ /\d+:(\s*) this raises error/
53
53
  end
@@ -140,7 +140,9 @@ describe "Pry::DefaultCommands::Shell" do
140
140
  pry_instance.rep(self)
141
141
  str_output.string.should =~ /bt number 0/
142
142
 
143
- temp_files.each(&:close)
143
+ temp_files.each do |file|
144
+ file.close(true)
145
+ end
144
146
  end
145
147
 
146
148
  end
data/test/test_hooks.rb CHANGED
@@ -172,4 +172,20 @@ describe Pry::Hooks do
172
172
  @hooks.exec_hook(:test_hook).should == 3
173
173
  end
174
174
  end
175
+
176
+ describe "integration tests" do
177
+ describe "when_started hook" do
178
+ it 'should yield options to the hook' do
179
+ options = nil
180
+ Pry.config.hooks.add_hook(:when_started, :test_hook) { |_, opt, _| options = opt }
181
+
182
+ redirect_pry_io(StringIO.new("exit"), out=StringIO.new) do
183
+ Pry.start binding, :hello => :baby
184
+ end
185
+ options[:hello].should == :baby
186
+
187
+ Pry.config.hooks.delete_hook(:when_started, :test_hook)
188
+ end
189
+ end
190
+ end
175
191
  end
data/test/test_method.rb CHANGED
@@ -74,6 +74,56 @@ describe Pry::Method do
74
74
  end
75
75
  end
76
76
 
77
+ describe '.from_binding' do
78
+ it 'should be able to pick a method out of a binding' do
79
+ Pry::Method.from_binding(Class.new{ def self.foo; binding; end }.foo).name.should == "foo"
80
+ end
81
+
82
+ it 'should NOT find a method from the special pry bindings' do
83
+ Pry::Method.from_binding(5.__binding__).should == nil
84
+ end
85
+
86
+ it 'should NOT find a method from the toplevel binding' do
87
+ Pry::Method.from_binding(TOPLEVEL_BINDING).should == nil
88
+ end
89
+
90
+ it "should find methods that have been undef'd" do
91
+ m = Pry::Method.from_binding(Class.new do
92
+ def self.bar
93
+ class << self; undef bar; end
94
+ binding
95
+ end
96
+ end.bar)
97
+ m.name.should == "bar"
98
+ end
99
+
100
+ # Our source_location trick doesn't work, due to https://github.com/rubinius/rubinius/issues/953
101
+ unless Pry::Helpers::BaseHelpers.rbx?
102
+ it 'should find the super method correctly' do
103
+ a = Class.new{ def gag; binding; end; def self.line; __LINE__; end }
104
+ b = Class.new(a){ def gag; super; end }
105
+
106
+ g = b.new.gag
107
+ m = Pry::Method.from_binding(g)
108
+
109
+ m.owner.should == a
110
+ m.source_line.should == a.line
111
+ m.name.should == "gag"
112
+ end
113
+ end
114
+
115
+ it 'should find the right method if a super method exists' do
116
+ a = Class.new{ def gag; binding; end; }
117
+ b = Class.new(a){ def gag; super; binding; end; def self.line; __LINE__; end }
118
+
119
+ m = Pry::Method.from_binding(b.new.gag)
120
+
121
+ m.owner.should == b
122
+ m.source_line.should == b.line
123
+ m.name.should == "gag"
124
+ end
125
+ end
126
+
77
127
  describe 'all_from_class' do
78
128
  def should_find_method(name)
79
129
  Pry::Method.all_from_class(@class).map(&:name).should.include(name)
data/test/test_pry.rb CHANGED
@@ -2,16 +2,6 @@ require 'helper'
2
2
 
3
3
  describe Pry do
4
4
 
5
- # if RUBY_PLATFORM !~ /mingw/ && RUBY_PLATFORM !~ /mswin/ && RUBY_PLATFORM != 'java'
6
- # describe 'warning emissions' do
7
- # it 'should emit no warnings' do
8
- # Open4.popen4 'ruby -I lib -rubygems -r"pry" -W -e "exit"' do |pid, stdin, stdout, stderr|
9
- # stderr.read.empty?.should == true
10
- # end
11
- # end
12
- # end
13
- # end
14
-
15
5
  if RUBY_VERSION =~ /1.9/
16
6
  describe "Exotic object support" do
17
7
  # regression test for exotic object support
@@ -53,7 +43,7 @@ describe Pry do
53
43
 
54
44
  # bug fix for https://github.com/banister/pry/issues/93
55
45
  it 'should not leak pry constants into Object namespace' do
56
- input_string = "CommandContext"
46
+ input_string = "Command"
57
47
  str_output = StringIO.new
58
48
  o = Object.new
59
49
  pry_tester = Pry.new(:input => StringIO.new(input_string),
@@ -792,7 +782,7 @@ describe Pry do
792
782
  str_output = StringIO.new
793
783
  Pry.new(:input => StringIO.new("hello\n"), :output => str_output, :commands => klass).rep
794
784
  str_output.string.should =~ /nil/
795
- str_output.string.should =~ /=>/
785
+ str_output.string.should =~ /=>/
796
786
  end
797
787
 
798
788
  it 'should define a command that keeps its return value but does not return when value is void' do
@@ -806,7 +796,7 @@ describe Pry do
806
796
  str_output.string.empty?.should == true
807
797
  end
808
798
 
809
- it 'a command (with :keep_retval => false) that replaces eval_string with a valid expression should not have the expression value suppressed' do
799
+ it 'a command (with :keep_retval => false) that replaces eval_string with a valid expression should not have the expression value suppressed' do
810
800
  klass = Pry::CommandSet.new do
811
801
  command "hello", "" do
812
802
  eval_string.replace("6")
@@ -818,45 +808,45 @@ describe Pry do
818
808
  end
819
809
 
820
810
 
821
- it 'a command (with :keep_retval => true) that replaces eval_string with a valid expression should overwrite the eval_string with the return value' do
822
- klass = Pry::CommandSet.new do
823
- command "hello", "", :keep_retval => true do
811
+ it 'a command (with :keep_retval => true) that replaces eval_string with a valid expression should overwrite the eval_string with the return value' do
812
+ klass = Pry::CommandSet.new do
813
+ command "hello", "", :keep_retval => true do
824
814
  eval_string.replace("6")
825
815
  7
816
+ end
826
817
  end
827
- end
828
- str_output = StringIO.new
829
- Pry.new(:input => StringIO.new("def yo\nhello\n"), :output => str_output, :commands => klass).rep
818
+ str_output = StringIO.new
819
+ Pry.new(:input => StringIO.new("def yo\nhello\n"), :output => str_output, :commands => klass).rep
830
820
  str_output.string.should =~ /7/
831
821
  str_output.string.should.not =~ /6/
832
822
  end
833
823
 
834
- it 'a command that return a value in a multi-line expression should clear the expression and return the value' do
835
- klass = Pry::CommandSet.new do
836
- command "hello", "", :keep_retval => true do
837
- 5
824
+ it 'a command that return a value in a multi-line expression should clear the expression and return the value' do
825
+ klass = Pry::CommandSet.new do
826
+ command "hello", "", :keep_retval => true do
827
+ 5
828
+ end
838
829
  end
830
+ str_output = StringIO.new
831
+ Pry.new(:input => StringIO.new("def yo\nhello\n"), :output => str_output, :commands => klass).rep
832
+ str_output.string.should =~ /5/
839
833
  end
840
- str_output = StringIO.new
841
- Pry.new(:input => StringIO.new("def yo\nhello\n"), :output => str_output, :commands => klass).rep
842
- str_output.string.should =~ /5/
843
- end
844
834
 
845
835
 
846
- it 'should set the commands default, and the default should be overridable' do
847
- klass = Pry::CommandSet.new do
848
- command "hello" do
849
- output.puts "hello world"
836
+ it 'should set the commands default, and the default should be overridable' do
837
+ klass = Pry::CommandSet.new do
838
+ command "hello" do
839
+ output.puts "hello world"
840
+ end
850
841
  end
851
- end
852
842
 
853
- Pry.commands = klass
843
+ Pry.commands = klass
854
844
 
855
- str_output = StringIO.new
856
- Pry.new(:input => InputTester.new("hello"), :output => str_output).rep
857
- str_output.string.should =~ /hello world/
845
+ str_output = StringIO.new
846
+ Pry.new(:input => InputTester.new("hello"), :output => str_output).rep
847
+ str_output.string.should =~ /hello world/
858
848
 
859
- other_klass = Pry::CommandSet.new do
849
+ other_klass = Pry::CommandSet.new do
860
850
  command "goodbye", "" do
861
851
  output.puts "goodbye world"
862
852
  end
@@ -1312,7 +1302,7 @@ describe Pry do
1312
1302
  str_output = StringIO.new
1313
1303
  Pry.new(:output => str_output,
1314
1304
  :hooks => Pry::Hooks.new.
1315
- add_hook(:before_session, :my_name) { |out,_,_| out.puts "OPEN" }
1305
+ add_hook(:before_session, :my_name) { |out,_,_| out.puts "OPEN" }
1316
1306
  ).repl
1317
1307
 
1318
1308
  str_output.string.should =~ /OPEN/
@@ -1321,7 +1311,7 @@ describe Pry do
1321
1311
  str_output = StringIO.new
1322
1312
  Pry.new(:output => str_output,
1323
1313
  :hooks => Pry::Hooks.new.
1324
- add_hook(:after_session, :my_name) { |out,_,_| out.puts "CLOSE" }
1314
+ add_hook(:after_session, :my_name) { |out,_,_| out.puts "CLOSE" }
1325
1315
  ).repl
1326
1316
 
1327
1317
  str_output.string.should =~ /CLOSE/
@@ -1332,4 +1322,12 @@ describe Pry do
1332
1322
  end
1333
1323
  end
1334
1324
  end
1325
+
1326
+ describe 'setting custom options' do
1327
+ it 'should not raise for unrecognized options' do
1328
+ should.not.raise?(NoMethodError) {
1329
+ instance = Pry.new(:custom_option => 'custom value')
1330
+ }
1331
+ end
1332
+ end
1335
1333
  end
@@ -26,7 +26,7 @@ describe Pry do
26
26
  ["1 1"],
27
27
  ["puts :"],
28
28
  # in this case the syntax error is "expecting ')'".
29
- ((defined? RUBY_ENGINE && RUBY_ENGINE == "rbx") ? nil : ["def", "method(1"])
29
+ (Pry::Helpers::BaseHelpers.rbx? ? nil : ["def", "method(1"])
30
30
  ].compact.each do |foo|
31
31
  it "should raise an error on invalid syntax like #{foo.inspect}" do
32
32
  output = StringIO.new
metadata CHANGED
@@ -1,103 +1,106 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pry
3
- version: !ruby/object:Gem::Version
4
- version: 0.9.8pre2
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease: 5
5
+ version: 0.9.8pre3
6
6
  platform: java
7
- authors:
7
+ authors:
8
8
  - John Mair (banisterfiend)
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-21 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2012-01-05 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
15
16
  name: coderay
16
- requirement: &70272199888580 !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
17
19
  none: false
18
- requirements:
20
+ requirements:
19
21
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '0.9'
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.5
22
24
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70272199888580
25
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
26
27
  name: slop
27
- requirement: &70272199886940 !ruby/object:Gem::Requirement
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
28
30
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
32
34
  version: 2.4.1
33
35
  - - <
34
- - !ruby/object:Gem::Version
35
- version: '3'
36
+ - !ruby/object:Gem::Version
37
+ version: "3"
36
38
  type: :runtime
37
- prerelease: false
38
- version_requirements: *70272199886940
39
- - !ruby/object:Gem::Dependency
39
+ version_requirements: *id002
40
+ - !ruby/object:Gem::Dependency
40
41
  name: method_source
41
- requirement: &70272199900240 !ruby/object:Gem::Requirement
42
+ prerelease: false
43
+ requirement: &id003 !ruby/object:Gem::Requirement
42
44
  none: false
43
- requirements:
45
+ requirements:
44
46
  - - ~>
45
- - !ruby/object:Gem::Version
46
- version: '0.6'
47
+ - !ruby/object:Gem::Version
48
+ version: "0.7"
47
49
  type: :runtime
48
- prerelease: false
49
- version_requirements: *70272199900240
50
- - !ruby/object:Gem::Dependency
50
+ version_requirements: *id003
51
+ - !ruby/object:Gem::Dependency
51
52
  name: bacon
52
- requirement: &70272199898260 !ruby/object:Gem::Requirement
53
+ prerelease: false
54
+ requirement: &id004 !ruby/object:Gem::Requirement
53
55
  none: false
54
- requirements:
56
+ requirements:
55
57
  - - ~>
56
- - !ruby/object:Gem::Version
57
- version: '1.1'
58
+ - !ruby/object:Gem::Version
59
+ version: "1.1"
58
60
  type: :development
59
- prerelease: false
60
- version_requirements: *70272199898260
61
- - !ruby/object:Gem::Dependency
61
+ version_requirements: *id004
62
+ - !ruby/object:Gem::Dependency
62
63
  name: open4
63
- requirement: &70272199896820 !ruby/object:Gem::Requirement
64
+ prerelease: false
65
+ requirement: &id005 !ruby/object:Gem::Requirement
64
66
  none: false
65
- requirements:
67
+ requirements:
66
68
  - - ~>
67
- - !ruby/object:Gem::Version
68
- version: '1.3'
69
+ - !ruby/object:Gem::Version
70
+ version: "1.3"
69
71
  type: :development
70
- prerelease: false
71
- version_requirements: *70272199896820
72
- - !ruby/object:Gem::Dependency
72
+ version_requirements: *id005
73
+ - !ruby/object:Gem::Dependency
73
74
  name: rake
74
- requirement: &70272199895580 !ruby/object:Gem::Requirement
75
+ prerelease: false
76
+ requirement: &id006 !ruby/object:Gem::Requirement
75
77
  none: false
76
- requirements:
78
+ requirements:
77
79
  - - ~>
78
- - !ruby/object:Gem::Version
79
- version: '0.9'
80
+ - !ruby/object:Gem::Version
81
+ version: "0.9"
80
82
  type: :development
81
- prerelease: false
82
- version_requirements: *70272199895580
83
- - !ruby/object:Gem::Dependency
83
+ version_requirements: *id006
84
+ - !ruby/object:Gem::Dependency
84
85
  name: spoon
85
- requirement: &70272199893920 !ruby/object:Gem::Requirement
86
+ prerelease: false
87
+ requirement: &id007 !ruby/object:Gem::Requirement
86
88
  none: false
87
- requirements:
89
+ requirements:
88
90
  - - ~>
89
- - !ruby/object:Gem::Version
90
- version: '0.0'
91
+ - !ruby/object:Gem::Version
92
+ version: "0.0"
91
93
  type: :runtime
92
- prerelease: false
93
- version_requirements: *70272199893920
94
+ version_requirements: *id007
94
95
  description: An IRB alternative and runtime developer console
95
96
  email: jrmair@gmail.com
96
- executables:
97
+ executables:
97
98
  - pry
98
99
  extensions: []
100
+
99
101
  extra_rdoc_files: []
100
- files:
102
+
103
+ files:
101
104
  - .document
102
105
  - .gemtest
103
106
  - .gitignore
@@ -124,8 +127,7 @@ files:
124
127
  - examples/helper.rb
125
128
  - lib/pry.rb
126
129
  - lib/pry/cli.rb
127
- - lib/pry/command_context.rb
128
- - lib/pry/command_processor.rb
130
+ - lib/pry/command.rb
129
131
  - lib/pry/command_set.rb
130
132
  - lib/pry/commands.rb
131
133
  - lib/pry/completion.rb
@@ -166,8 +168,8 @@ files:
166
168
  - pry.gemspec
167
169
  - test/helper.rb
168
170
  - test/test_cli.rb
171
+ - test/test_command.rb
169
172
  - test/test_command_helpers.rb
170
- - test/test_command_processor.rb
171
173
  - test/test_command_set.rb
172
174
  - test/test_completion.rb
173
175
  - test/test_default_commands.rb
@@ -196,33 +198,36 @@ files:
196
198
  - wiki/Home.md
197
199
  homepage: http://pry.github.com
198
200
  licenses: []
201
+
199
202
  post_install_message:
200
203
  rdoc_options: []
201
- require_paths:
204
+
205
+ require_paths:
202
206
  - lib
203
- required_ruby_version: !ruby/object:Gem::Requirement
207
+ required_ruby_version: !ruby/object:Gem::Requirement
204
208
  none: false
205
- requirements:
206
- - - ! '>='
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- required_rubygems_version: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: "0"
213
+ required_rubygems_version: !ruby/object:Gem::Requirement
210
214
  none: false
211
- requirements:
212
- - - ! '>'
213
- - !ruby/object:Gem::Version
215
+ requirements:
216
+ - - ">"
217
+ - !ruby/object:Gem::Version
214
218
  version: 1.3.1
215
219
  requirements: []
220
+
216
221
  rubyforge_project:
217
- rubygems_version: 1.8.10
222
+ rubygems_version: 1.8.11
218
223
  signing_key:
219
224
  specification_version: 3
220
225
  summary: An IRB alternative and runtime developer console
221
- test_files:
226
+ test_files:
222
227
  - test/helper.rb
223
228
  - test/test_cli.rb
229
+ - test/test_command.rb
224
230
  - test/test_command_helpers.rb
225
- - test/test_command_processor.rb
226
231
  - test/test_command_set.rb
227
232
  - test/test_completion.rb
228
233
  - test/test_default_commands.rb