mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-31 17:58:29 -05:00
By using $stdin adn $stderr instead of STDIN and STDERR it is possible to capture or redirect them using in process ruby code without the need to manage pipes and external processes
30 lines
1.1 KiB
Ruby
30 lines
1.1 KiB
Ruby
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
|