changes to stdout and -err - tests and behaviour
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
This commit is contained in:
parent
2f2e45bedf
commit
597c7a7904
|
@ -67,10 +67,10 @@ module Jekyll
|
|||
begin
|
||||
config = YAML.load_file(config_file)
|
||||
raise "Invalid configuration - #{config_file}" if !config.is_a?(Hash)
|
||||
STDOUT.puts "Configuration from #{config_file}"
|
||||
$stdout.puts "Configuration from #{config_file}"
|
||||
rescue => err
|
||||
STDERR.puts "WARNING: Could not read configuration. Using defaults (and options)."
|
||||
STDERR.puts "\t" + err.to_s
|
||||
$stderr.puts "WARNING: Could not read configuration. Using defaults (and options)."
|
||||
$stderr.puts "\t" + err.to_s
|
||||
config = {}
|
||||
end
|
||||
|
||||
|
|
|
@ -8,21 +8,21 @@ class TestConfiguration < Test::Unit::TestCase
|
|||
|
||||
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}")
|
||||
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}")
|
||||
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}")
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue