pry 0.9.0pre3-i386-mingw32 → 0.9.1-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,11 +13,118 @@ describe "Pry::DefaultCommands::Input" do
13
13
 
14
14
  it 'should correctly amend the specified line of input when line number given ' do
15
15
  str_output = StringIO.new
16
- redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line-0 def goodbye", "show-input", "exit-all"), str_output) do
16
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 1 def goodbye", "show-input", "exit-all"), str_output) do
17
17
  pry
18
18
  end
19
19
  str_output.string.should =~ /\A\d+: def goodbye\n\d+: puts :bing\n\d+: puts :bang/
20
20
  end
21
+
22
+ it 'should correctly amend the specified line of input when line number given, 0 should behave as 1 ' do
23
+ str_output = StringIO.new
24
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 0 def goodbye", "show-input", "exit-all"), str_output) do
25
+ pry
26
+ end
27
+ str_output.string.should =~ /\A\d+: def goodbye\n\d+: puts :bing\n\d+: puts :bang/
28
+ end
29
+
30
+ it 'should correctly amend the specified line of input when line number given (negative number)' do
31
+ str_output = StringIO.new
32
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line -1 puts :bink", "show-input", "exit-all"), str_output) do
33
+ pry
34
+ end
35
+ str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing\n\d+: puts :bink/
36
+
37
+ str_output = StringIO.new
38
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line -2 puts :bink", "show-input", "exit-all"), str_output) do
39
+ pry
40
+ end
41
+ str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bink\n\d+: puts :bang/
42
+ end
43
+
44
+ it 'should correctly amend the specified range of lines of input when range of negative numbers given (negative number)' do
45
+ str_output = StringIO.new
46
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boat", "amend-line -3..-2 puts :bink", "show-input", "exit-all"), str_output) do
47
+ pry
48
+ end
49
+ str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bink\n\d+: puts :boat/
50
+ end
51
+
52
+ it 'should correctly amend the specified line with string interpolated text' do
53
+ str_output = StringIO.new
54
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", 'amend-line puts "#{goodbye}"', "show-input", "exit-all"), str_output) do
55
+ pry
56
+ end
57
+
58
+ str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing\n\d+: puts \"\#{goodbye}\"/
59
+ end
60
+
61
+ it 'should display error if nothing to amend' do
62
+ str_output = StringIO.new
63
+ redirect_pry_io(InputTester.new("amend-line", "exit-all"), str_output) do
64
+ pry
65
+ end
66
+ str_output.string.should =~ /No input to amend/
67
+ end
68
+
69
+
70
+ it 'should correctly amend the specified range of lines' do
71
+ str_output = StringIO.new
72
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :heart", "amend-line 2..3 puts :bong", "show-input", "exit-all"), str_output) do
73
+ pry
74
+ end
75
+ str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bong\n\d+: puts :heart/
76
+ end
77
+
78
+ it 'should correctly delete a specific line using the ! for content' do
79
+ str_output = StringIO.new
80
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line 3 !", "show-input", "exit-all"), str_output) do
81
+ pry
82
+ end
83
+
84
+ str_output.string.should =~ /\d+: def hello\n\d+: puts :bing\n\d+: puts :boast\n\d+: puts :heart/
85
+ end
86
+
87
+ it 'should correctly delete a range of lines using the ! for content' do
88
+ str_output = StringIO.new
89
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line 2..4 !", "show-input", "exit-all"), str_output) do
90
+ pry
91
+ end
92
+
93
+ str_output.string.should =~ /\d+: def hello\n\d+: puts :heart\n\Z/
94
+ end
95
+
96
+ it 'should correctly delete the previous line using the ! for content' do
97
+ str_output = StringIO.new
98
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line !", "show-input", "exit-all"), str_output) do
99
+ pry
100
+ end
101
+
102
+ str_output.string.should =~ /\d+: def hello\n\d+: puts :bing\n\d+: puts :bang\n\d+: puts :boast\n\Z/
103
+ end
104
+
105
+ it 'should correctly amend the specified range of lines, using negative numbers in range' do
106
+ str_output = StringIO.new
107
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line-2..-2 puts :bong", "show-input", "exit-all"), str_output) do
108
+ pry
109
+ end
110
+ str_output.string.should =~ /\d+: def hello\n\d+: puts :bong\n\d+: puts :heart/
111
+ end
112
+
113
+ it 'should correctly insert a new line of input before a specified line using the > syntax' do
114
+ str_output = StringIO.new
115
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 2 >puts :inserted", "show-input", "exit-all"), str_output) do
116
+ pry
117
+ end
118
+ str_output.string.should =~ /\d+: def hello\n\d+: puts :inserted\n\d+: puts :bing\n\d+: puts :bang/
119
+ end
120
+
121
+ it 'should correctly insert a new line of input before a specified line using the > syntax (should ignore second value of range)' do
122
+ str_output = StringIO.new
123
+ redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 2..21 >puts :inserted", "show-input", "exit-all"), str_output) do
124
+ pry
125
+ end
126
+ str_output.string.should =~ /\d+: def hello\n\d+: puts :inserted\n\d+: puts :bing\n\d+: puts :bang/
127
+ end
21
128
  end
22
129
 
23
130
  describe "show-input" do
@@ -42,6 +149,53 @@ describe "Pry::DefaultCommands::Input" do
42
149
  end
43
150
  end
44
151
 
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
156
+ end
157
+ str_output.string.should =~ /:test_string/
158
+ end
159
+
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
164
+ end
165
+ str_output.string.should =~ /:test_string_interpolated/
166
+ end
167
+
168
+ it 'should play a method with the -m switch (a single line)' do
169
+ $o = Object.new
170
+ def $o.test_method
171
+ :test_method_content
172
+ end
173
+
174
+ redirect_pry_io(InputTester.new('play -m $o.test_method --lines 2', "exit-all"), str_output = StringIO.new) do
175
+ pry
176
+ end
177
+
178
+ str_output.string.should =~ /:test_method_content/
179
+ $o = nil
180
+ end
181
+
182
+ it 'should play a method with the -m switch (multiple line)' do
183
+ $o = Object.new
184
+ def $o.test_method
185
+ 1 + 102
186
+ 5 * 6
187
+ end
188
+
189
+ redirect_pry_io(InputTester.new('play -m $o.test_method --lines 2..3', "exit-all"), str_output = StringIO.new) do
190
+ pry
191
+ end
192
+
193
+ str_output.string.should =~ /103\n.*30/
194
+ $o = nil
195
+ end
196
+
197
+ end
198
+
45
199
  describe "hist" do
46
200
  push_first_hist_line = lambda do |hist, line|
47
201
  hist.push line
@@ -94,13 +248,29 @@ describe "Pry::DefaultCommands::Input" do
94
248
  @hist.push "pepper"
95
249
  @hist.push "orange"
96
250
  @hist.push "grape"
251
+ @hist.push "def blah 1"
252
+ @hist.push "def boink 2"
253
+ @hist.push "place holder"
97
254
 
98
255
  str_output = StringIO.new
99
256
  redirect_pry_io(InputTester.new("hist --grep o", "exit-all"), str_output) do
100
257
  pry
101
258
  end
102
-
103
259
  str_output.string.should =~ /\d:.*?box\n\d:.*?button\n\d:.*?orange/
260
+
261
+ # test more than one word in a regex match (def blah)
262
+ str_output = StringIO.new
263
+ redirect_pry_io(InputTester.new("hist --grep def blah", "exit-all"), str_output) do
264
+ pry
265
+ end
266
+ str_output.string.should =~ /def blah 1/
267
+
268
+ # test more than one word with leading white space in a regex match (def boink)
269
+ str_output = StringIO.new
270
+ redirect_pry_io(InputTester.new("hist --grep def boink", "exit-all"), str_output) do
271
+ pry
272
+ end
273
+ str_output.string.should =~ /def boink 2/
104
274
  end
105
275
 
106
276
  it 'should return last N lines in history with --tail switch' do
@@ -20,6 +20,15 @@ describe "Pry::DefaultCommands::Introspection" do
20
20
  str_output.string.should =~ /\d+: def sample/
21
21
  end
22
22
 
23
+ it 'should output a method\'s source with line numbers starting at 1' do
24
+ str_output = StringIO.new
25
+ redirect_pry_io(InputTester.new("show-method -b sample_method", "exit-all"), str_output) do
26
+ pry
27
+ end
28
+
29
+ str_output.string.should =~ /1: def sample/
30
+ end
31
+
23
32
  it 'should output a method\'s source if inside method without needing to use method name' do
24
33
  $str_output = StringIO.new
25
34
 
data/test/test_pry.rb CHANGED
@@ -7,10 +7,12 @@ puts "--"
7
7
 
8
8
  describe Pry do
9
9
 
10
- describe 'warning emissions' do
11
- it 'should emit no warnings' do
12
- Open4.popen4 'ruby -I lib -rubygems -r"pry" -W -e "exit"' do |pid, stdin, stdout, stderr|
13
- stderr.read.empty?.should == true
10
+ if RUBY_PLATFORM !~ /mingw/ && RUBY_PLATFORM !~ /mswin/
11
+ describe 'warning emissions' do
12
+ it 'should emit no warnings' do
13
+ Open4.popen4 'ruby -I lib -rubygems -r"pry" -W -e "exit"' do |pid, stdin, stdout, stderr|
14
+ stderr.read.empty?.should == true
15
+ end
14
16
  end
15
17
  end
16
18
  end
@@ -40,6 +42,17 @@ describe Pry do
40
42
  @excep.is_a?(NameError).should == true
41
43
  end
42
44
 
45
+ if defined?(BasicObject)
46
+ it 'should be able to operate inside the BasicObject class' do
47
+ $obj = nil
48
+ redirect_pry_io(InputTester.new(":foo", "$obj = _", "exit-all"), StringIO.new) do
49
+ BasicObject.pry
50
+ end
51
+ $obj.should == :foo
52
+ $obj = nil
53
+ end
54
+ end
55
+
43
56
  it 'should set an ivar on an object' do
44
57
  input_string = "@x = 10"
45
58
  input = InputTester.new(input_string)
@@ -51,12 +64,12 @@ describe Pry do
51
64
  end
52
65
 
53
66
  it 'should make self evaluate to the receiver of the rep session' do
54
- o = Object.new
67
+ o = :john
55
68
  str_output = StringIO.new
56
69
 
57
70
  pry_tester = Pry.new(:input => InputTester.new("self"), :output => str_output)
58
71
  pry_tester.rep(o)
59
- str_output.string.should =~ /#{o.to_s}/
72
+ str_output.string.should =~ /:john/
60
73
  end
61
74
 
62
75
  it 'should work with multi-line input' do
@@ -488,6 +501,21 @@ describe Pry do
488
501
  $test_interpolation = nil
489
502
  end
490
503
 
504
+ it 'should NOT try to interpolate pure ruby code (no commands) ' do
505
+ str_output = StringIO.new
506
+ Pry.new(:input => StringIO.new('puts \'#{aggy}\''), :output => str_output).rep
507
+ str_output.string.should.not =~ /NameError/
508
+
509
+ Pry.new(:input => StringIO.new('puts #{aggy}'), :output => str_output).rep
510
+ str_output.string.should.not =~ /NameError/
511
+
512
+ $test_interpolation = "blah"
513
+ Pry.new(:input => StringIO.new('puts \'#{$test_interpolation}\''), :output => str_output).rep
514
+
515
+ str_output.string.should.not =~ /blah/
516
+ $test_interpolation = nil
517
+ end
518
+
491
519
  it 'should create a command with a space in its name' do
492
520
  set = Pry::CommandSet.new do
493
521
  command "hello baby", "" do
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 5
5
- version: 0.9.0pre3
4
+ prerelease:
5
+ version: 0.9.1
6
6
  platform: i386-mingw32
7
7
  authors:
8
8
  - John Mair (banisterfiend)
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-09 00:00:00 Z
13
+ date: 2011-06-17 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby_parser
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 1.6.0
45
+ version: 1.9.0
46
46
  type: :runtime
47
47
  version_requirements: *id003
48
48
  - !ruby/object:Gem::Dependency
@@ -53,7 +53,7 @@ dependencies:
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 0.4.0
56
+ version: 0.6.0
57
57
  type: :runtime
58
58
  version_requirements: *id004
59
59
  - !ruby/object:Gem::Dependency
@@ -148,6 +148,7 @@ files:
148
148
  - lib/pry/pry_class.rb
149
149
  - lib/pry/pry_instance.rb
150
150
  - lib/pry/version.rb
151
+ - pry.gemspec
151
152
  - test/helper.rb
152
153
  - test/test_command_helpers.rb
153
154
  - test/test_command_processor.rb
@@ -180,9 +181,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
181
  required_rubygems_version: !ruby/object:Gem::Requirement
181
182
  none: false
182
183
  requirements:
183
- - - ">"
184
+ - - ">="
184
185
  - !ruby/object:Gem::Version
185
- version: 1.3.1
186
+ version: "0"
186
187
  requirements: []
187
188
 
188
189
  rubyforge_project: