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

75 lines
2 KiB
Ruby
Raw Normal View History

2014-01-21 10:32:03 -05:00
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
should.raise(ArgumentError) { @config.inherited_by = "abc" }
end
end
2014-01-21 10:32:03 -05:00
describe "local config" do
it "should be set" do
t = pry_tester
t.eval "_pry_.config.foobar = 'hello'"
t.eval("_pry_.config.foobar").should == 'hello'
end
it "should be set (array)" do
t = pry_tester
t.eval "_pry_.config.foobar = []"
t.eval "_pry_.config.foobar << 1 << 2"
t.eval("_pry_.config.foobar").should == [1, 2]
end
it "should be global config value when local config is not set" do
Pry.config.foobar = 'hello'
t = pry_tester
t.eval("_pry_.config.foobar").should == 'hello'
Pry.config.foobar = nil
end
it "should be local config value when local config is set" do
Pry.config.foobar = 'hello'
t = pry_tester
t.eval "_pry_.config.foobar = 'goodbye'"
t.eval("_pry_.config.foobar").should == 'goodbye'
Pry.config.foobar = nil
end
end
describe "global config" do
it "should be set" do
Pry.config.foobar = 'hello'
Pry.config.foobar.should == 'hello'
Pry.config.foobar = nil
end
it "should be set (array)" do
Pry.config.foobar = []
Pry.config.foobar << 1 << 2
Pry.config.foobar.should == [1, 2]
Pry.config.foobar = nil
end
it "should keep value when local config is set" do
Pry.config.foobar = 'hello'
t = pry_tester
t.eval "_pry_.config.foobar = 'goodbye'"
Pry.config.foobar.should == 'hello'
Pry.config.foobar = nil
end
it "should keep value when local config is set (array)" do
Pry.config.foobar = [1, 2]
t = pry_tester
t.eval "_pry_.config.foobar << 3 << 4"
Pry.config.foobar.should == [1, 2]
Pry.config.foobar = nil
end
end
end