mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Config#forget recursively removes a key from self and its default (#1899)
The following example should return 'Readline' after 'input' has been forgotten: # .pryrc Pry.config.input = RbReadline # Pry session pry(main)> _pry_.config.forget(:input) # This will unexpectedly return RbReadline instead of Pry's default, 'Readline' pry(main)> _pry_.config.input => RbReadline This commit fixes the above example to return 'Readline' after the 'input' option has been forgotten, allowing it to be restored to Pry's default.
This commit is contained in:
parent
dc8a191cae
commit
0d08ca3f8a
2 changed files with 8 additions and 7 deletions
|
@ -187,6 +187,7 @@ class Pry
|
|||
def forget(key)
|
||||
key = key.to_s
|
||||
__remove(key)
|
||||
default.forget(key) if default && default != last_default
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -155,13 +155,13 @@ RSpec.describe Pry::Config do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#forget" do
|
||||
it "forgets a local key" do
|
||||
local = described_class.new described_class.from_hash(foo: 1)
|
||||
local.foo = 2
|
||||
expect(local.foo).to eq 2
|
||||
local.forget(:foo)
|
||||
expect(local.foo).to eq(1)
|
||||
describe '#forget' do
|
||||
it 'restores a key to its default value' do
|
||||
last_default = described_class.from_hash(a: 'c')
|
||||
middle_default = described_class.from_hash({a: 'b'}, last_default)
|
||||
c = described_class.from_hash({a: 'a'}, middle_default)
|
||||
c.forget(:a)
|
||||
expect(c.a).to eq('c')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue