mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
add tests
This commit is contained in:
parent
398a62bf79
commit
6531140f06
2 changed files with 29 additions and 4 deletions
16
spec/config/behavior_spec.rb
Normal file
16
spec/config/behavior_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'helper'
|
||||
RSpec.describe Pry::Config::Behavior do
|
||||
let(:behavior) do
|
||||
Class.new do
|
||||
include Pry::Config::Behavior
|
||||
end
|
||||
end
|
||||
|
||||
describe "#last_default" do
|
||||
it "returns the last default in a list of defaults" do
|
||||
last = behavior.from_hash({}, nil)
|
||||
middle = behavior.from_hash({}, last)
|
||||
expect(behavior.from_hash({}, middle).last_default).to be(last)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,13 +1,22 @@
|
|||
require 'helper'
|
||||
RSpec.describe Pry::Config::Lazy do
|
||||
let(:lazyobject) do
|
||||
let(:lazyobj) do
|
||||
Class.new do
|
||||
include Pry::Config::Lazy
|
||||
lazy_implement({foo: proc {"bar"}})
|
||||
lazy_implement({foo: proc {"foo"}, bar: proc {"bar"}})
|
||||
end.new
|
||||
end
|
||||
|
||||
it 'memorizes value after first call' do
|
||||
expect(lazyobject.foo).to equal(lazyobject.foo)
|
||||
describe "on call of a lazy method" do
|
||||
it "memoizes the return value" do
|
||||
expect(lazyobj.foo).to be(lazyobj.foo)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#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])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue