mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Add spec for Pry::Config
This commit is contained in:
parent
7723550d8c
commit
9da6c98fd6
1 changed files with 64 additions and 0 deletions
64
spec/config_spec.rb
Normal file
64
spec/config_spec.rb
Normal file
|
@ -0,0 +1,64 @@
|
|||
require 'helper'
|
||||
|
||||
describe Pry::Config do
|
||||
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
|
Loading…
Reference in a new issue