fix 'at least one lazy method has to be called before #lazy_keys could ..'
This commit is contained in:
parent
f95d65171e
commit
c584d173a1
|
@ -6,12 +6,12 @@ module Pry::Config::Lazy
|
||||||
method_name_to_func.each do |method_name, func|
|
method_name_to_func.each do |method_name, func|
|
||||||
define_method(method_name) do
|
define_method(method_name) do
|
||||||
if method_name_to_func[method_name].equal?(func)
|
if method_name_to_func[method_name].equal?(func)
|
||||||
LAZY_KEYS[self.class] |= method_name_to_func.keys
|
|
||||||
method_name_to_func[method_name] = instance_eval(&func)
|
method_name_to_func[method_name] = instance_eval(&func)
|
||||||
end
|
end
|
||||||
method_name_to_func[method_name]
|
method_name_to_func[method_name]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
LAZY_KEYS[self] |= method_name_to_func.keys
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ RSpec.describe Pry::Config::Lazy do
|
||||||
|
|
||||||
describe "#lazy_keys" do
|
describe "#lazy_keys" do
|
||||||
it "tracks a list of lazy keys" do
|
it "tracks a list of lazy keys" do
|
||||||
lazyobj.foo # at least one lazy method has to be called before #lazy_keys could return a non-empty array.
|
|
||||||
expect(lazyobj.lazy_keys).to eq([:foo, :bar])
|
expect(lazyobj.lazy_keys).to eq([:foo, :bar])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue