summaryrefslogtreecommitdiff
path: root/spec/config
diff options
context:
space:
mode:
authorstrcmp <28xdb6+fvutuvy4f@grr.la>2015-12-31 15:25:33 -0800
committerstrcmp <28xdb6+fvutuvy4f@grr.la>2015-12-31 15:46:31 -0800
commit6531140f068f639f17b385d9671e36b836643adc (patch)
tree1b975e54877a3c240561fcacc777fb0fb6c15f51 /spec/config
parent398a62bf79d1d9e614438e8153fdd0bdfd05eaa3 (diff)
downloadpry-6531140f068f639f17b385d9671e36b836643adc.tar.gz
add tests
Diffstat (limited to 'spec/config')
-rw-r--r--spec/config/behavior_spec.rb16
-rw-r--r--spec/config/lazy_spec.rb17
2 files changed, 29 insertions, 4 deletions
diff --git a/spec/config/behavior_spec.rb b/spec/config/behavior_spec.rb
new file mode 100644
index 00000000..5f62991f
--- /dev/null
+++ b/spec/config/behavior_spec.rb
@@ -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
diff --git a/spec/config/lazy_spec.rb b/spec/config/lazy_spec.rb
index 7f512333..69884f20 100644
--- a/spec/config/lazy_spec.rb
+++ b/spec/config/lazy_spec.rb
@@ -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