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

add tests

This commit is contained in:
strcmp 2015-12-31 15:25:33 -08:00
parent 398a62bf79
commit 6531140f06
2 changed files with 29 additions and 4 deletions

View 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

View file

@ -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