Skip to content

Commit

Permalink
Tweaked plugin directory handling, tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
simensen committed Jan 23, 2012
1 parent ab08aca commit dcf5462
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/jekyll/site.rb
Expand Up @@ -14,16 +14,19 @@ class Site
# 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.
[File.expand_path(config['plugins'])]
if config['plugins'].nil?
[]
else
[File.expand_path(config['plugins'])]
end
end
self.lsi = config['lsi']
self.pygments = config['pygments']
Expand Down
21 changes: 21 additions & 0 deletions test/test_site.rb
@@ -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
Expand Down

0 comments on commit dcf5462

Please sign in to comment.