diff --git a/lib/pry/config/behavior.rb b/lib/pry/config/behavior.rb index 1cb98da5..d2669dde 100644 --- a/lib/pry/config/behavior.rb +++ b/lib/pry/config/behavior.rb @@ -54,7 +54,7 @@ module Pry::Config::Behavior value = @default.public_send(name, *args, &block) # FIXME: refactor Pry::Hook so that it stores config on the config object, # so that we can use the normal strategy. - self[key] = value.dup if key == 'hooks' + self[key] = value = value.dup if key == 'hooks' value else nil diff --git a/spec/config_spec.rb b/spec/config_spec.rb index 228f30dc..054c49a0 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -28,6 +28,14 @@ describe Pry::Config do local3 = Pry::Config.new(local2) local3.foo.should == 21 end + + it "stores a local copy of the parent's hooks upon accessing them" do + parent = Pry::Config.from_hash(hooks: "parent_hooks") + local = Pry::Config.new parent + local.hooks.gsub! 'parent', 'local' + local.hooks.should == 'local_hooks' + parent.hooks.should == 'parent_hooks' + end end describe ".from_hash" do