Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tests for --config

  • Loading branch information...
commit d0e2a0aab7287ba639650c9714515b8ac7489040 1 parent daf33e5
Parker Moore parkr authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 test/test_configuration.rb
27 test/test_configuration.rb
View
@@ -26,4 +26,31 @@ class TestConfiguration < Test::Unit::TestCase
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
end
end
+ context "loading config from external file" do
+ setup do
+ @paths = {
+ :default => File.join(Dir.pwd, '_config.yml'),
+ :other => File.join(Dir.pwd, '_config.live.yml'),
+ :empty => ""
+ }
+ end
+
+ should "load default config if no config_file is set" do
+ mock(YAML).load_file(@paths[:default]) { Hash.new }
+ mock($stdout).puts("Configuration from #{@paths[:default]}")
+ assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
+ end
+
+ should "load different config if specified" do
+ mock(YAML).load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} }
+ mock($stdout).puts("Configuration from #{@paths[:other]}")
+ assert_equal Jekyll::DEFAULTS.deep_merge({ "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] })
+ end
+
+ should "load default config if path passed is empty" do
+ mock(YAML).load_file(@paths[:default]) { Hash.new }
+ mock($stdout).puts("Configuration from #{@paths[:default]}")
+ assert_equal Jekyll::DEFAULTS, Jekyll.configuration({ "config" => @paths[:empty] })
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.