mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Fix a bug where Method objects were not returned for setters inherited (#1688)
from a default (Pry::Config::Default). Eg, this is no longer an error: [1] pry(main)> Pry.config.method(:exception_whitelist=)
This commit is contained in:
parent
f422ccc8ca
commit
62c6183b9c
3 changed files with 16 additions and 8 deletions
|
@ -16,6 +16,14 @@
|
|||
|
||||
#### Bug fixes
|
||||
|
||||
* Fix a bug where Method objects were not returned for setters inherited
|
||||
from a default (Pry::Config::Default). Eg, this is no longer an error:
|
||||
|
||||
pry(main)> d = Pry::Config.from_hash({}, Pry::Config::Default.new)
|
||||
pry(main)> d.method(:exception_whitelist=) # Error
|
||||
|
||||
See pull request [#1688](https://github.com/pry/pry/pull/1688).
|
||||
|
||||
* Do not capture unused Proc objects in Text helper methods `no_color` and `no_paging`,
|
||||
for performance reasons. Improve the documentation of both methods.
|
||||
|
||||
|
|
|
@ -188,6 +188,7 @@ module Pry::Config::Behavior
|
|||
end
|
||||
|
||||
def respond_to_missing?(key, include_all=false)
|
||||
key = key.to_s.chomp(ASSIGNMENT)
|
||||
key?(key) or @default.respond_to?(key) or super(key, include_all)
|
||||
end
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ describe Pry::Config do
|
|||
expect(local3.foo).to eq(21)
|
||||
end
|
||||
|
||||
it "stores a local copy of the parent's hooks upon accessing them" do
|
||||
it "stores a local copy of the parents hooks upon accessing them" do
|
||||
parent = Pry::Config.from_hash(hooks: "parent_hooks")
|
||||
local = Pry::Config.new parent
|
||||
local.hooks.gsub! 'parent', 'local'
|
||||
|
@ -67,13 +67,7 @@ describe Pry::Config do
|
|||
end
|
||||
|
||||
it "recursively builds Pry::Config objects from a Hash" do
|
||||
h = {
|
||||
'foo1' => {
|
||||
'foo2' => {
|
||||
'foo3' => 'foobar'
|
||||
}
|
||||
}
|
||||
}
|
||||
h = {'foo1' => {'foo2' => {'foo3' => 'foobar'}}}
|
||||
default = Pry::Config.from_hash(h)
|
||||
expect(default.foo1).to be_instance_of(described_class)
|
||||
expect(default.foo1.foo2).to be_instance_of(described_class)
|
||||
|
@ -92,6 +86,11 @@ describe Pry::Config do
|
|||
expect(method_obj.name).to eq :key
|
||||
expect(method_obj.call).to eq(1)
|
||||
end
|
||||
|
||||
it "returns a Method object for a setter on a parent" do
|
||||
config = described_class.from_hash({}, described_class.from_hash(foo: 1))
|
||||
expect(config.method(:foo=)).to be_an_instance_of(Method)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#respond_to?" do
|
||||
|
|
Loading…
Add table
Reference in a new issue