spec/optionsful_config_spec.rb in optionsful-0.2.3 vs spec/optionsful_config_spec.rb in optionsful-0.3.0

- old
+ new

@@ -1,40 +1,47 @@ -require File.dirname(__FILE__) + '/spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/spec_helper') + describe Baurets::Optionsful::Config do include Rack::Test::Methods context "Config carries specific settings" do - - describe "try to find the custom configuration file" do - - it "if the custom configuration file exist, try to load settings from it" do - config = Baurets::Optionsful::Config.new( {:file => File.join(File.dirname(__FILE__), 'fixtures', 'optionsful.yml'), :environment => "test" }) - config.base_path.should == "/test" + + describe "when there's no custom config file, use expected default settings" do + + it "the Link header generation must be disabled" do + config = Baurets::Optionsful::Config.new("file_error.txt") + config.link.should be false end - - it "if the custom configuration file exist and is not valid, keep the default settings" do - config = Baurets::Optionsful::Config.new( {:file => File.join(File.dirname(__FILE__), 'fixtures', 'optionsful_bug.yml'), :environment => "test" }) - config.base_path.should == "/optionsful" + + end + + describe "when there is a custom config file, load the settings from it" do + + it "the Link header generation must be disabled" do + file = File.join(File.dirname(__FILE__), 'config', 'optionsful_link_false.yml') + config = Baurets::Optionsful::Config.new(file) + config.link.should be false end - - it "if no configuration file is informed or found, do load the default settings" do - config = Baurets::Optionsful::Config.new - config.base_path.should == "/optionsful" + + it "the Link header generation must be enabled" do + config = Baurets::Optionsful::Config.new(File.join(File.dirname(__FILE__), 'config', 'optionsful.yml')) + config.link.should be true end - - it "if RAILS_ROOT is defined, look for the custom configuration file on its config folder" do - Baurets::Optionsful::Config.const_set(:RAILS_ROOT, File.dirname(__FILE__)) - config = Baurets::Optionsful::Config.new - config.base_path.should == "/optionsful" + + it "if the Link header generation is enabled, host value must be set" do + config = Baurets::Optionsful::Config.new(File.join(File.dirname(__FILE__), 'config', 'optionsful.yml')) + config.link.should be true + config.host.empty?.should_not be true end - - it "and does not exist, keep default settings" do - config = Baurets::Optionsful::Config.new( {:file => File.join(File.dirname(__FILE__), 'fixtures', 'optionsful_xxx.yml'), :environment => "test" }) - config.base_path.should == "/optionsful" + + it "if the Link header generation is enabled, host value accepts 'auto'" do + config = Baurets::Optionsful::Config.new(File.join(File.dirname(__FILE__), 'config', 'optionsful_host_auto.yml')) + config.link.should be true + config.host.should == "auto" end - + end end end \ No newline at end of file