From 9da6c98fd6cf0a7d6ec00c7d09d9939da68a6d92 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Wed, 22 Jan 2014 00:32:03 +0900 Subject: [PATCH] Add spec for Pry::Config --- spec/config_spec.rb | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 spec/config_spec.rb diff --git a/spec/config_spec.rb b/spec/config_spec.rb new file mode 100644 index 00000000..7829ca81 --- /dev/null +++ b/spec/config_spec.rb @@ -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