Finish of moving the unit tests over to Minitest
This commit is contained in:
parent
4b59eb4175
commit
52c4ce2a5a
1
Gemfile
1
Gemfile
|
@ -26,6 +26,7 @@ gem 'jekyll_test_plugin'
|
|||
gem 'jekyll_test_plugin_malicious'
|
||||
gem 'liquid-c', '~> 0.0.3'
|
||||
gem 'minitest'
|
||||
gem 'minitest-reporters'
|
||||
gem 'test-unit' if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2")
|
||||
|
||||
if ENV['BENCHMARK']
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'set'
|
||||
|
||||
module Jekyll
|
||||
class Site
|
||||
# Handles the cleanup of a site's destination before it is built.
|
||||
class Cleaner
|
||||
attr_reader :site
|
||||
|
@ -100,4 +99,3 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,10 @@ if [ ! -d tmp ]; then
|
|||
mkdir tmp
|
||||
fi
|
||||
|
||||
if [ -d test/dest ]; then
|
||||
rm -r test/dest
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
TEST_FILES=$(ruby -e "puts Dir.glob('test/test_*.rb')")
|
||||
else
|
||||
|
|
|
@ -8,6 +8,7 @@ end
|
|||
require 'rubygems'
|
||||
require 'ostruct'
|
||||
require 'minitest/autorun'
|
||||
require 'minitest/reporters'
|
||||
|
||||
require 'jekyll'
|
||||
|
||||
|
@ -23,6 +24,9 @@ include Jekyll
|
|||
# Send STDERR into the void to suppress program output messages
|
||||
STDERR.reopen(test(?e, '/dev/null') ? '/dev/null' : 'NUL:')
|
||||
|
||||
# Report with color.
|
||||
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(:color => true)]
|
||||
|
||||
class Minitest::Test
|
||||
def fixture_site(overrides = {})
|
||||
Jekyll::Site.new(site_configuration(overrides))
|
||||
|
@ -33,7 +37,10 @@ class Minitest::Test
|
|||
end
|
||||
|
||||
def site_configuration(overrides = {})
|
||||
full_overrides = build_configs(overrides, build_configs({"destination" => dest_dir}))
|
||||
full_overrides = build_configs(overrides, build_configs({
|
||||
"destination" => dest_dir,
|
||||
"full_rebuild" => true
|
||||
}))
|
||||
build_configs({
|
||||
"source" => source_dir
|
||||
}, full_overrides)
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
require 'rubygems'
|
||||
gem 'test-unit'
|
||||
require 'test/unit'
|
||||
|
||||
# for some reason these tests fail when run via TextMate
|
||||
# but succeed when run on the command line.
|
||||
|
||||
tests = Dir[File.expand_path("#{File.dirname(__FILE__)}/test_*.rb")]
|
||||
tests.each do |file|
|
||||
require file
|
||||
end
|
|
@ -12,7 +12,7 @@ class TestCleaner < Minitest::Test
|
|||
@site = fixture_site
|
||||
@site.keep_files = ['to_keep/child_dir']
|
||||
|
||||
@cleaner = Site::Cleaner.new(@site)
|
||||
@cleaner = Cleaner.new(@site)
|
||||
@cleaner.cleanup!
|
||||
end
|
||||
|
||||
|
@ -47,7 +47,7 @@ class TestCleaner < Minitest::Test
|
|||
@site = fixture_site
|
||||
@site.process
|
||||
|
||||
@cleaner = Site::Cleaner.new(@site)
|
||||
@cleaner = Cleaner.new(@site)
|
||||
@cleaner.cleanup!
|
||||
end
|
||||
|
||||
|
|
|
@ -19,16 +19,16 @@ class TestCoffeeScript < Minitest::Test
|
|||
return square(x) * x;
|
||||
};
|
||||
cubes = (function() {
|
||||
var _i, _len, _results;
|
||||
_results = [];
|
||||
for (_i = 0, _len = list.length; _i < _len; _i++) {
|
||||
num = list[_i];
|
||||
_results.push(math.cube(num));
|
||||
var i, len, results;
|
||||
results = [];
|
||||
for (i = 0, len = list.length; i < len; i++) {
|
||||
num = list[i];
|
||||
results.push(math.cube(num));
|
||||
}
|
||||
return _results;
|
||||
return results;
|
||||
})();
|
||||
if (typeof elvis !== \"undefined\" && elvis !== null) {
|
||||
return alert(\"I knew it!\");
|
||||
if (typeof elvis !== "undefined" && elvis !== null) {
|
||||
return alert("I knew it!");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ class TestCollections < Minitest::Test
|
|||
assert @site.collections["methods"].docs.is_a? Array
|
||||
@site.collections["methods"].docs.each do |doc|
|
||||
assert doc.is_a? Jekyll::Document
|
||||
assert_include %w[
|
||||
assert_includes %w[
|
||||
_methods/configuration.md
|
||||
_methods/sanitized_path.md
|
||||
_methods/site/generate.md
|
||||
|
@ -135,16 +135,16 @@ class TestCollections < Minitest::Test
|
|||
end
|
||||
|
||||
should "not include files which start with an underscore in the base collection directory" do
|
||||
refute_include @collection.filtered_entries, "_do_not_read_me.md"
|
||||
refute_includes @collection.filtered_entries, "_do_not_read_me.md"
|
||||
end
|
||||
|
||||
should "not include files which start with an underscore in a subdirectory" do
|
||||
refute_include @collection.filtered_entries, "site/_dont_include_me_either.md"
|
||||
refute_includes @collection.filtered_entries, "site/_dont_include_me_either.md"
|
||||
end
|
||||
|
||||
should "not include the underscored files in the list of docs" do
|
||||
refute_include @collection.docs.map(&:relative_path), "_methods/_do_not_read_me.md"
|
||||
refute_include @collection.docs.map(&:relative_path), "_methods/site/_dont_include_me_either.md"
|
||||
refute_includes @collection.docs.map(&:relative_path), "_methods/_do_not_read_me.md"
|
||||
refute_includes @collection.docs.map(&:relative_path), "_methods/site/_dont_include_me_either.md"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -178,12 +178,12 @@ class TestCollections < Minitest::Test
|
|||
end
|
||||
|
||||
should "not allow symlinks" do
|
||||
refute_include @collection.filtered_entries, "um_hi.md"
|
||||
refute_include @collection.filtered_entries, "/um_hi.md"
|
||||
refute_includes @collection.filtered_entries, "um_hi.md"
|
||||
refute_includes @collection.filtered_entries, "/um_hi.md"
|
||||
end
|
||||
|
||||
should "not include the symlinked file in the list of docs" do
|
||||
refute_include @collection.docs.map(&:relative_path), "_methods/um_hi.md"
|
||||
refute_includes @collection.docs.map(&:relative_path), "_methods/um_hi.md"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -84,14 +84,12 @@ OUTPUT
|
|||
end
|
||||
|
||||
should "acceptable limit post is 0" do
|
||||
refute_raises ArgumentError do
|
||||
clear_dest
|
||||
stub(Jekyll).configuration do
|
||||
Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 0})
|
||||
end
|
||||
|
||||
@site = Site.new(Jekyll.configuration)
|
||||
end
|
||||
assert Site.new(Jekyll.configuration), "Couldn't create a site with the given limit_posts."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -79,9 +79,8 @@ class TestNewCommand < Minitest::Test
|
|||
|
||||
should 'force created folder' do
|
||||
capture_stdout { Jekyll::Commands::New.process(@args) }
|
||||
refute_raises(SystemExit) do
|
||||
capture_stdout {Jekyll::Commands::New.process(@args, '--force') }
|
||||
end
|
||||
output = capture_stdout { Jekyll::Commands::New.process(@args, '--force') }
|
||||
assert_match /New jekyll site installed in/, output
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ class TestRegenerator < Minitest::Test
|
|||
"methods" => {
|
||||
"output" => true
|
||||
}
|
||||
}
|
||||
},
|
||||
"full_rebuild" => false
|
||||
})
|
||||
|
||||
@site.read
|
||||
|
|
|
@ -309,9 +309,7 @@ class TestSite < Minitest::Test
|
|||
|
||||
custom_processor = "CustomMarkdown"
|
||||
s = Site.new(site_configuration('markdown' => custom_processor))
|
||||
refute_raises do
|
||||
s.process
|
||||
end
|
||||
assert !!s.process
|
||||
|
||||
# Do some cleanup, we don't like straggling stuff's.
|
||||
Jekyll::Converters::Markdown.send(:remove_const, :CustomMarkdown)
|
||||
|
@ -344,9 +342,7 @@ class TestSite < Minitest::Test
|
|||
context 'with an invalid markdown processor in the configuration' do
|
||||
should 'not throw an error at initialization time' do
|
||||
bad_processor = 'not a processor name'
|
||||
refute_raises do
|
||||
Site.new(site_configuration('markdown' => bad_processor))
|
||||
end
|
||||
assert Site.new(site_configuration('markdown' => bad_processor))
|
||||
end
|
||||
|
||||
should 'throw FatalException at process time' do
|
||||
|
|
Loading…
Reference in New Issue