optionsful 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +1,46 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
2
3
 
3
4
  describe Baurets::Optionsful::Config do
4
5
 
5
6
  include Rack::Test::Methods
6
7
 
7
8
  context "Config carries specific settings" do
8
-
9
- describe "try to find the custom configuration file" do
10
-
11
- it "if the custom configuration file exist, try to load settings from it" do
12
- config = Baurets::Optionsful::Config.new( {:file => File.join(File.dirname(__FILE__), 'fixtures', 'optionsful.yml'), :environment => "test" })
13
- config.base_path.should == "/test"
9
+
10
+ describe "when there's no custom config file, use expected default settings" do
11
+
12
+ it "the Link header generation must be disabled" do
13
+ config = Baurets::Optionsful::Config.new("file_error.txt")
14
+ config.link.should be false
14
15
  end
15
-
16
- it "if the custom configuration file exist and is not valid, keep the default settings" do
17
- config = Baurets::Optionsful::Config.new( {:file => File.join(File.dirname(__FILE__), 'fixtures', 'optionsful_bug.yml'), :environment => "test" })
18
- config.base_path.should == "/optionsful"
16
+
17
+ end
18
+
19
+ describe "when there is a custom config file, load the settings from it" do
20
+
21
+ it "the Link header generation must be disabled" do
22
+ file = File.join(File.dirname(__FILE__), 'config', 'optionsful_link_false.yml')
23
+ config = Baurets::Optionsful::Config.new(file)
24
+ config.link.should be false
19
25
  end
20
-
21
- it "if no configuration file is informed or found, do load the default settings" do
22
- config = Baurets::Optionsful::Config.new
23
- config.base_path.should == "/optionsful"
26
+
27
+ it "the Link header generation must be enabled" do
28
+ config = Baurets::Optionsful::Config.new(File.join(File.dirname(__FILE__), 'config', 'optionsful.yml'))
29
+ config.link.should be true
24
30
  end
25
-
26
- it "if RAILS_ROOT is defined, look for the custom configuration file on its config folder" do
27
- Baurets::Optionsful::Config.const_set(:RAILS_ROOT, File.dirname(__FILE__))
28
- config = Baurets::Optionsful::Config.new
29
- config.base_path.should == "/optionsful"
31
+
32
+ it "if the Link header generation is enabled, host value must be set" do
33
+ config = Baurets::Optionsful::Config.new(File.join(File.dirname(__FILE__), 'config', 'optionsful.yml'))
34
+ config.link.should be true
35
+ config.host.empty?.should_not be true
30
36
  end
31
-
32
- it "and does not exist, keep default settings" do
33
- config = Baurets::Optionsful::Config.new( {:file => File.join(File.dirname(__FILE__), 'fixtures', 'optionsful_xxx.yml'), :environment => "test" })
34
- config.base_path.should == "/optionsful"
37
+
38
+ it "if the Link header generation is enabled, host value accepts 'auto'" do
39
+ config = Baurets::Optionsful::Config.new(File.join(File.dirname(__FILE__), 'config', 'optionsful_host_auto.yml'))
40
+ config.link.should be true
41
+ config.host.should == "auto"
35
42
  end
36
-
43
+
37
44
  end
38
45
 
39
46
  end