1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Stop using rep in pry_spec.rb

This commit is contained in:
Conrad Irwin 2012-12-15 15:51:02 -08:00
parent 26307d5a63
commit ed3d043f25

View file

@ -81,34 +81,21 @@ describe Pry do
# bug fix for https://github.com/banister/pry/issues/93 # bug fix for https://github.com/banister/pry/issues/93
it 'should not leak pry constants into Object namespace' do it 'should not leak pry constants into Object namespace' do
input_string = "Command" lambda{
o = Object.new pry_eval(Object.new, "Command")
pry_tester = Pry.new(:input => StringIO.new(input_string), }.should.raise(NameError)
:output => @str_output,
:exception_handler => proc { |_, exception, _pry_| @excep = exception },
:print => proc {}
).rep(o)
@excep.is_a?(NameError).should == true
end end
if defined?(BasicObject) if defined?(BasicObject)
it 'should be able to operate inside the BasicObject class' do it 'should be able to operate inside the BasicObject class' do
redirect_pry_io(InputTester.new(":foo", "Pad.obj = _", "exit-all")) do pry_eval(BasicObject, ":foo", "Pad.obj = _")
BasicObject.pry
end
Pad.obj.should == :foo Pad.obj.should == :foo
end end
end end
it 'should set an ivar on an object' do it 'should set an ivar on an object' do
input_string = "@x = 10"
input = InputTester.new(input_string)
o = Object.new o = Object.new
pry_eval(o, "@x = 10")
pry_tester = Pry.new(:input => input, :output => StringIO.new)
pry_tester.rep(o)
o.instance_variable_get(:@x).should == 10 o.instance_variable_get(:@x).should == 10
end end
@ -121,10 +108,7 @@ describe Pry do
it 'should make self evaluate to the receiver of the rep session' do it 'should make self evaluate to the receiver of the rep session' do
o = :john o = :john
pry_eval(o, "self").should == o
pry_tester = Pry.new(:input => InputTester.new("self"), :output => @str_output)
pry_tester.rep(o)
@str_output.string.should =~ /:john/
end end
it 'should work with multi-line input' do it 'should work with multi-line input' do
@ -417,24 +401,20 @@ describe Pry do
describe "defining methods" do describe "defining methods" do
it 'should define a method on the singleton class of an object when performing "def meth;end" inside the object' do it 'should define a method on the singleton class of an object when performing "def meth;end" inside the object' do
[Object.new, {}, []].each do |val| [Object.new, {}, []].each do |val|
str_input = StringIO.new("def hello;end") pry_eval(val, 'def hello; end')
Pry.new(:input => str_input, :output => StringIO.new).rep(val)
val.methods(false).map(&:to_sym).include?(:hello).should == true val.methods(false).map(&:to_sym).include?(:hello).should == true
end end
end end
it 'should define an instance method on the module when performing "def meth;end" inside the module' do it 'should define an instance method on the module when performing "def meth;end" inside the module' do
str_input = StringIO.new("def hello;end")
hello = Module.new hello = Module.new
Pry.new(:input => str_input, :output => StringIO.new).rep(hello) pry_eval(hello, "def hello; end")
hello.instance_methods(false).map(&:to_sym).include?(:hello).should == true hello.instance_methods(false).map(&:to_sym).include?(:hello).should == true
end end
it 'should define an instance method on the class when performing "def meth;end" inside the class' do it 'should define an instance method on the class when performing "def meth;end" inside the class' do
str_input = StringIO.new("def hello;end")
hello = Class.new hello = Class.new
Pry.new(:input => str_input, :output => StringIO.new).rep(hello) pry_eval(hello, "def hello; end")
hello.instance_methods(false).map(&:to_sym).include?(:hello).should == true hello.instance_methods(false).map(&:to_sym).include?(:hello).should == true
end end
@ -442,8 +422,7 @@ describe Pry do
# should include float in here, but test fails for some reason # should include float in here, but test fails for some reason
# on 1.8.7, no idea why! # on 1.8.7, no idea why!
[:test, 0, true, false, nil].each do |val| [:test, 0, true, false, nil].each do |val|
str_input = StringIO.new("def hello;end") pry_eval(val, "def hello; end");
Pry.new(:input => str_input, :output => StringIO.new).rep(val)
val.class.instance_methods(false).map(&:to_sym).include?(:hello).should == true val.class.instance_methods(false).map(&:to_sym).include?(:hello).should == true
end end
end end