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

last_default might not be a Pry::Config::Memoized

This commit is contained in:
r-obert 2017-06-23 17:42:04 +01:00
parent ba49f4caa6
commit 72a17c5b24
2 changed files with 9 additions and 2 deletions

View file

@ -142,6 +142,7 @@ module Pry::Config::Behavior
def eager_load!
local_last_default = last_default
return if ! local_last_default.respond_to?(:memoized_methods)
local_last_default.memoized_methods.each do |key|
self[key] = local_last_default.public_send(key)
end

View file

@ -5,12 +5,18 @@ RSpec.describe Pry::Config::Behavior do
include Pry::Config::Behavior
end
end
describe "#last_default" do
it "returns the last default in a list of defaults" do
it "returns the last default" do
last = behavior.from_hash({}, nil)
middle = behavior.from_hash({}, last)
expect(behavior.from_hash({}, middle).last_default).to be(last)
end
end
describe "#eager_load!" do
it "returns nil when the default is nil" do
expect(behavior.from_hash({}, nil).eager_load!).to be(nil)
end
end
end