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

add Pry::Config::Behavior#default.

This commit is contained in:
Robert Gleeson 2014-03-14 05:40:09 +01:00
parent 74135c1890
commit d0faf8b2d0
2 changed files with 25 additions and 5 deletions

View file

@ -24,6 +24,14 @@ module Pry::Config::Behavior
@writes = {}
end
#
# @return [Pry::Config::Behavior]
# returns the fallback used when a key is not found locally.
#
def default
@default
end
def [](key)
@writes[key.to_s]
end

View file

@ -1,5 +1,4 @@
require_relative 'helper'
describe Pry::Config do
describe "reserved keys" do
it "raises an ArgumentError on assignment of a reserved key" do
@ -38,19 +37,32 @@ describe Pry::Config do
end
describe ".from_hash" do
it "returns an object without a default when given 1 argument" do
it "returns an object without a default" do
local = Pry::Config.from_hash({})
local.instance_variable_get(:@default).should == nil
local.default.should == nil
end
it "returns an object with a default when given 2 arguments" do
it "returns an object with a default" do
default = Pry::Config.new(nil)
local = Pry::Config.from_hash({}, default)
local.instance_variable_get(:@default).should == default
local.default.should == local
end
end
describe "#default" do
it "returns nil" do
local = Pry::Config.new(nil)
local.default.should == nil
end
it "returns the default" do
default = Pry::Config.new(nil)
local = Pry::Config.new(default)
local.default.should == default
end
end
describe "#keys" do
it "returns an array of local keys" do
root = Pry::Config.from_hash({zoo: "boo"}, nil)