spec/jeckyl_spec.rb in jeckyl-0.2.7 vs spec/jeckyl_spec.rb in jeckyl-0.3.7

- old
+ new

@@ -5,10 +5,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../test/test_class') require File.expand_path(File.dirname(__FILE__) + '/../test/test_subclass') conf_path = File.expand_path(File.dirname(__FILE__) + '/../test/conf.d') + describe "Jeckyl" do # general tests it "should return the defaults" do @@ -28,10 +29,13 @@ conf[:log_level].should == :verbose conf[:log_rotation].should == 5 conf[:email].should == "robert@osburn-sharp.ath.cx" conf.has_key?(:sieve).should be_true conf[:config_files].length.should == 1 + conf[:option_set][:peter].should == 37 + conf[:offset].should == 134 + conf[:start_day].should == 6 end # general exceptions @@ -87,10 +91,15 @@ it "should raise an exception if it gets an integer instead of a float" do conf_file = conf_path + '/not_a_float' lambda{conf = TestJeckyl.new(conf_file)}.should raise_error(Jeckyl::ConfigError, /^\[pi\]:.*value is not of required type: Float$/) end + it "should raise an exception if it gets a negative instead of a positive" do + conf_file = conf_path + '/not_positive.rb' + lambda{conf = TestJeckyl.new(conf_file)}.should raise_error(Jeckyl::ConfigError, /^\[offset\]:.*value is not a positive number: \-\d+$/) + end + end describe "Boolean Parameters" do it "should raise an exception if it gets a string instead of a boolean" do @@ -112,11 +121,11 @@ lambda{conf = TestJeckyl.new(conf_file)}.should raise_error(Jeckyl::ConfigError, /^\[collection\]:.*value is not an Array$/) end it "should raise an exception if it gets a string instead of a hash" do conf_file = conf_path + '/not_a_hash' - lambda{conf = TestJeckyl.new(conf_file)}.should raise_error(Jeckyl::ConfigError, /^\[options\]:.*value is not a Hash$/) + lambda{conf = TestJeckyl.new(conf_file)}.should raise_error(Jeckyl::ConfigError, /^\[option_set\]:.*value is not a Hash$/) end it "should raise an exception if it gets an array of strings instead of a integers" do conf_file = conf_path + '/not_an_integer_array' lambda{conf = TestJeckyl.new(conf_file)}.should raise_error(Jeckyl::ConfigError, /^\[sieve\]:.*element of array is not of type: Integer$/) @@ -194,9 +203,24 @@ conf[:log_level].should == :debug conf[:log_rotation].should == 6 conf[:email].should == "robert@osburn-associates.ath.cx" conf[:config_files].length.should == 2 conf[:pi].should == 3.14592 + end + + it "should merge another hash" do + conf_file = conf_path + '/jeckyl' + conf = TestJeckyl.new(conf_file) + merge_file = File.join(conf_path, 'merger.rb') + merge = TestJeckyl.new(merge_file) + conf.merge(merge) + conf[:log_dir].should match(/reports$/) + conf[:log_level].should == :debug + conf[:log_rotation].should == 6 + conf[:email].should == "robert@osburn-associates.ath.cx" + conf[:config_files].length.should == 1 + conf[:pi].should == 3.14592 + end end end