Test JEKYLL_NO_BUNDLER_REQUIRE.
This commit is contained in:
parent
8ee1b2a1fd
commit
5a350788e7
|
@ -26,16 +26,21 @@ module Jekyll
|
|||
def require_gems
|
||||
site.gems.each do |gem|
|
||||
if plugin_allowed?(gem)
|
||||
Jekyll.logger.debug("PluginManager:", "Requiring #{gem}")
|
||||
require gem
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.require_from_bundler
|
||||
unless ENV["JEKYLL_NO_BUNDLER_REQUIRE"]
|
||||
if ENV["JEKYLL_NO_BUNDLER_REQUIRE"]
|
||||
false
|
||||
else
|
||||
require "bundler"
|
||||
Bundler.require(:jekyll_plugins)
|
||||
required_gems = Bundler.require(:jekyll_plugins)
|
||||
Jekyll.logger.debug("PluginManager:", "Required #{required_gems.map(&:name).join(', ')}")
|
||||
ENV["JEKYLL_NO_BUNDLER_REQUIRE"] = "true"
|
||||
true
|
||||
end
|
||||
rescue LoadError
|
||||
false
|
||||
|
|
|
@ -58,6 +58,13 @@ class Test::Unit::TestCase
|
|||
File.open("#{path}/index.html", "w"){ |f| f.write("I was previously generated.") }
|
||||
end
|
||||
|
||||
def with_env(key, value)
|
||||
old_value = ENV[key]
|
||||
ENV[key] = value
|
||||
yield
|
||||
ENV[key] = old_value
|
||||
end
|
||||
|
||||
def capture_stdout
|
||||
$old_stdout = $stdout
|
||||
$stdout = StringIO.new
|
||||
|
|
|
@ -2,7 +2,15 @@ require 'helper'
|
|||
|
||||
class TestPluginManager < Test::Unit::TestCase
|
||||
def test_requiring_from_bundler
|
||||
Jekyll::PluginManager.require_from_bundler
|
||||
assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"], 'Gemfile plugins were not required.'
|
||||
with_env("JEKYLL_NO_BUNDLER_REQUIRE", nil) do
|
||||
Jekyll::PluginManager.require_from_bundler
|
||||
assert ENV["JEKYLL_NO_BUNDLER_REQUIRE"], 'Gemfile plugins were not required.'
|
||||
end
|
||||
end
|
||||
|
||||
def test_blocking_requiring_from_bundler
|
||||
with_env("JEKYLL_NO_BUNDLER_REQUIRE", "true") do
|
||||
assert_equal false, Jekyll::PluginManager.require_from_bundler, "Gemfile plugins were required but shouldn't have been"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue