spec/configurability/config_spec.rb in configurability-1.0.5 vs spec/configurability/config_spec.rb in configurability-1.0.6
- old
+ new
@@ -91,29 +91,51 @@
it "supports both Symbols and Strings for Hash-like access" do
config = Configurability::Config.new( TEST_CONFIG )
config[:section]['subsection'][:subsubsection].should == 'value'
end
+ it "autoloads predicates for its members" do
+ config = Configurability::Config.new( TEST_CONFIG )
+ config.mergekey?.should be_true()
+ config.mergemonkey?.should be_false()
+ config.section?.should be_true()
+ config.section.subsection?.should be_true()
+ config.section.subsection.subsubsection?.should be_true()
+ config.section.monkeysubsection?.should be_false()
+ end
- NIL_KEY_CONFIG = %{
- ---
- trap_on:
- "low disk space alert":
- ~:
- notepad:
- patterns:
- - pattern1
- - pattern2
- }.gsub(/^\t/, '')
- it "handles nil as a key in the configuration (issue #1)" do
- config = Configurability::Config.new( NIL_KEY_CONFIG )
- config[:trap_on]['low disk space alert'][nil][:notepad][:patterns].should == [ 'pattern1', 'pattern2' ]
+ context "a config with nil keys" do
+
+ NIL_KEY_CONFIG = %{
+ ---
+ trap_on:
+ "low disk space alert":
+ ~:
+ notepad:
+ patterns:
+ - pattern1
+ - pattern2
+ }.gsub(/^\t{2}/, '')
+
+ before( :each ) do
+ @config = Configurability::Config.new( NIL_KEY_CONFIG )
+ end
+
+ it "doesn't raise a NoMethodError when loading (issue #1)" do
+ @config[:trap_on]['low disk space alert'][nil][:notepad][:patterns].
+ should == [ 'pattern1', 'pattern2' ]
+ end
+
+ it "knows that it has a nil member" do
+ @config[:trap_on]['low disk space alert'].should have_member( nil )
+ end
+
end
- describe "created with in-memory YAML source" do
+ context "created with in-memory YAML source" do
before(:each) do
@config = Configurability::Config.new( TEST_CONFIG )
end
@@ -181,11 +203,11 @@
end
# saving if changed since loaded
- describe " whose internal values have been changed since loaded" do
+ context " whose internal values have been changed since loaded" do
before(:each) do
@config = Configurability::Config.new( TEST_CONFIG )
@config.section.subsection.anothersection = 11451
end
@@ -201,11 +223,11 @@
end
# loading from a file
- describe " loaded from a file" do
+ context " loaded from a file" do
before(:all) do
@tmpfile = Tempfile.new( 'test.conf', '.' )
@tmpfile.print( TEST_CONFIG )
@tmpfile.close
end
@@ -263,11 +285,11 @@
end
end
# reload if file changes
- describe " whose file changes after loading" do
+ context " whose file changes after loading" do
before(:all) do
@tmpfile = Tempfile.new( 'test.conf', '.' )
@tmpfile.print( TEST_CONFIG )
@tmpfile.close
end
@@ -308,10 +330,10 @@
end
end
# merging
- describe " created by merging two other configs" do
+ context " created by merging two other configs" do
before(:each) do
@config1 = Configurability::Config.new
@config2 = Configurability::Config.new( TEST_CONFIG )
@merged = @config1.merge( @config2 )
end