Tweaked plugin directory handling, tests.
This commit is contained in:
parent
ab08acace9
commit
dcf546275b
|
@ -14,17 +14,20 @@ module Jekyll
|
|||
# config - A Hash containing site configuration details.
|
||||
def initialize(config)
|
||||
self.config = config.clone
|
||||
|
||||
self.safe = config['safe']
|
||||
self.source = File.expand_path(config['source'])
|
||||
self.dest = File.expand_path(config['destination'])
|
||||
self.plugins = if config['plugins'].respond_to?('each')
|
||||
# If plugins is an array, process it.
|
||||
config['plugins'].each { |directory| File.expand_path(directory) }
|
||||
Array(config['plugins']).map { |d| File.expand_path(d) }
|
||||
else
|
||||
# Otherwise process a single entry as an array.
|
||||
if config['plugins'].nil?
|
||||
[]
|
||||
else
|
||||
[File.expand_path(config['plugins'])]
|
||||
end
|
||||
end
|
||||
self.lsi = config['lsi']
|
||||
self.pygments = config['pygments']
|
||||
self.permalink_style = config['permalink'].to_sym
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
require 'helper'
|
||||
|
||||
class TestSite < Test::Unit::TestCase
|
||||
context "configuring sites" do
|
||||
should "have an array for plugins by default" do
|
||||
site = Site.new(Jekyll::DEFAULTS)
|
||||
assert_equal [File.join(Dir.pwd, '_plugins')], site.plugins
|
||||
end
|
||||
|
||||
should "have an array for plugins if passed as a string" do
|
||||
site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => '/tmp/plugins'}))
|
||||
assert_equal ['/tmp/plugins'], site.plugins
|
||||
end
|
||||
|
||||
should "have an array for plugins if passed as an array" do
|
||||
site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => ['/tmp/plugins', '/tmp/otherplugins']}))
|
||||
assert_equal ['/tmp/plugins', '/tmp/otherplugins'], site.plugins
|
||||
end
|
||||
|
||||
should "have an array for plugins if nothing is passed" do
|
||||
site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => []}))
|
||||
assert_equal [], site.plugins
|
||||
end
|
||||
end
|
||||
context "creating sites" do
|
||||
setup do
|
||||
stub(Jekyll).configuration do
|
||||
|
|
Loading…
Reference in New Issue