forked from jekyll/jekyll
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validating the configuration loads properly and is a hash, based on j…
…rk's implementation. Closes jekyll#22.
- Loading branch information
Showing
3 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require File.dirname(__FILE__) + '/helper' | ||
|
||
class TestConfiguration < Test::Unit::TestCase | ||
context "loading configuration" do | ||
setup do | ||
@path = './_config.yml' | ||
end | ||
|
||
should "fire warning with no _config.yml" do | ||
mock(YAML).load_file(@path) { raise "No such file or directory - #{@path}" } | ||
mock(STDERR).puts("WARNING: Could not read configuration. Using defaults (and options).") | ||
mock(STDERR).puts("\tNo such file or directory - #{@path}") | ||
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({}) | ||
end | ||
|
||
should "load configuration as hash" do | ||
mock(YAML).load_file(@path) { Hash.new } | ||
mock(STDOUT).puts("Configuration from #{@path}") | ||
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({}) | ||
end | ||
|
||
should "fire warning with bad config" do | ||
mock(YAML).load_file(@path) { Array.new } | ||
mock(STDERR).puts("WARNING: Could not read configuration. Using defaults (and options).") | ||
mock(STDERR).puts("\tInvalid configuration - #{@path}") | ||
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({}) | ||
end | ||
end | ||
end |