mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
add tests that cover Object subclasses
This commit is contained in:
parent
4870fcba99
commit
741782b726
1 changed files with 31 additions and 0 deletions
|
@ -12,6 +12,37 @@ describe Pry::ColorPrinter do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'Object subclass' do
|
||||||
|
before do
|
||||||
|
class ObjectF < Object
|
||||||
|
def inspect
|
||||||
|
'foo'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class ObjectG < Object
|
||||||
|
def inspect
|
||||||
|
raise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
Object.send :remove_const, :ObjectF
|
||||||
|
Object.send :remove_const, :ObjectG
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'prints a string' do
|
||||||
|
Pry::ColorPrinter.pp(ObjectF.new, io)
|
||||||
|
expect(str).to eq('foo')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'prints a string, even when an exception is raised' do
|
||||||
|
Pry::ColorPrinter.pp(ObjectG.new, io)
|
||||||
|
expect(str).to match(/\A#<ObjectG:0x\w+>\z/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'BasicObject' do
|
describe 'BasicObject' do
|
||||||
it 'prints a string' do
|
it 'prints a string' do
|
||||||
Pry::ColorPrinter.pp(BasicObject.new, io)
|
Pry::ColorPrinter.pp(BasicObject.new, io)
|
||||||
|
|
Loading…
Add table
Reference in a new issue