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

cleanup in config_spec.rb

This commit is contained in:
Robert Gleeson 2014-01-31 02:43:13 +01:00
parent 929c3f5aaa
commit 0a25818c6b

View file

@ -2,33 +2,30 @@ require 'helper'
describe Pry::Config do
describe "reserved keys" do
before do
@config = Pry::Config.from_hash({}, nil)
end
it "raises an ArgumentError on assignment of a reserved key" do
local = Pry::Config.from_hash({})
Pry::Config::RESERVED_KEYS.each do |key|
should.raise(ArgumentError) { @config[key] = 1 }
should.raise(ArgumentError) { local[key] = 1 }
end
end
end
describe "traversal to parent" do
it "traverses back to the parent when a local key is not found" do
config = Pry::Config.new Pry::Config.from_hash(foo: 1)
config.foo.should == 1
local = Pry::Config.new Pry::Config.from_hash(foo: 1)
local.foo.should == 1
end
it "stores a local key and prevents traversal to the parent" do
config = Pry::Config.new Pry::Config.from_hash(foo: 1)
config.foo = 2
config.foo.should == 2
local = Pry::Config.new Pry::Config.from_hash(foo: 1)
local.foo = 2
local.foo.should == 2
end
it "duplicates a copy on read from the parent" do
ukraine = "i love"
config = Pry::Config.new Pry::Config.from_hash(home: ukraine)
config.home.equal?(ukraine).should == false
local = Pry::Config.new Pry::Config.from_hash(home: ukraine)
local.home.equal?(ukraine).should == false
end
it "forgets a local copy in favor of the parent's new value" do