More tests are passing. Hooray.

This commit is contained in:
Parker Moore 2014-09-07 12:47:33 -07:00
parent 0bc88975c8
commit 461e16f8bc
8 changed files with 32 additions and 16 deletions

View File

@ -88,7 +88,9 @@ module Jekyll
def configuration(override)
config = Configuration[Configuration::DEFAULTS]
override = Configuration[override].stringify_keys
unless override.delete('skip_config_files')
config = config.read_config_files(config.config_files(override))
end
# Merge DEFAULTS < _config.yml < override
config = Utils.deep_merge_hashes(config, override).stringify_keys

View File

@ -36,6 +36,7 @@ module Jekyll
def read
filtered_entries.each do |file_path|
full_path = collection_dir(file_path)
next if File.directory?(full_path)
if Utils.has_yaml_header? full_path
doc = Jekyll::Document.new(full_path, { site: site, collection: self })
doc.read
@ -86,7 +87,8 @@ module Jekyll
@directory ||= site.in_source_dir(relative_directory)
end
# The full path to the directory containing the collection.
# The full path to the directory containing the collection, with
# optional subpaths.
#
# *files - (optional) any other path pieces relative to the
# directory to append to the path

View File

@ -159,7 +159,8 @@ module Jekyll
#
# Returns the full path to the output file of this document.
def destination(base_directory)
path = site.in_dest_dir(base_directory, url)
dest = site.in_dest_dir(base_directory)
path = Jekyll.sanitized_path(dest, url)
path = File.join(path, "index.html") if url =~ /\/$/
path
end

View File

@ -140,7 +140,8 @@ module Jekyll
#
# Returns the destination file path String.
def destination(dest)
path = site.in_dest_dir(dest, URL.unescape_path(url))
dest = site.in_dest_dir(dest)
path = Jekyll.sanitized_path(dest, URL.unescape_path(url))
path = File.join(path, "index.html") if url =~ /\/$/
path
end

View File

@ -268,7 +268,8 @@ module Jekyll
# Returns destination file path String.
def destination(dest)
# The url needs to be unescaped in order to preserve the correct filename
path = site.in_dest_dir(dest, URL.unescape_path(url))
dest = site.in_dest_dir(dest)
path = Jekyll.sanitized_path(dest, URL.unescape_path(url))
path = File.join(path, "index.html") if path[/\.html$/].nil?
path
end

View File

@ -3,12 +3,12 @@ require 'csv'
module Jekyll
class Site
attr_reader :source, :dest
attr_accessor :config, :layouts, :posts, :pages, :static_files,
:exclude, :include, :lsi, :highlighter,
:permalink_style, :time, :future, :unpublished, :safe, :plugins, :limit_posts,
:show_drafts, :keep_files, :baseurl, :data, :file_read_opts, :gems,
:plugin_manager
attr_reader :source, :dest, :config
attr_accessor :layouts, :posts, :pages, :static_files,
:exclude, :include, :lsi, :highlighter, :permalink_style,
:time, :future, :unpublished, :safe, :plugins, :limit_posts,
:show_drafts, :keep_files, :baseurl, :data, :file_read_opts,
:gems, :plugin_manager
attr_accessor :converters, :generators
@ -16,7 +16,7 @@ module Jekyll
#
# config - A Hash containing site configuration details.
def initialize(config)
self.config = config.clone
@config = config.clone
%w[safe lsi highlighter baseurl exclude include future unpublished
show_drafts limit_posts keep_files gems].each do |opt|

View File

@ -10,9 +10,14 @@ class TestDocument < Test::Unit::TestCase
"destination" => dest_dir
}))
@site.process
p @site.collections["methods"]
@document = @site.collections["methods"].docs.first
end
should "exist" do
assert !@document.nil?
end
should "know its relative path" do
assert_equal "_methods/configuration.md", @document.relative_path
end
@ -220,6 +225,7 @@ class TestDocument < Test::Unit::TestCase
"destination" => dest_dir
}))
@site.process
p @site.collections["slides"]
@document = @site.collections["slides"].docs[3]
@document_without_title = @site.collections["slides"].docs[4]
end

View File

@ -15,8 +15,11 @@ class TestPost < Test::Unit::TestCase
context "A Post" do
setup do
clear_dest
stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS }
@site = Site.new(Jekyll.configuration)
@site = Site.new(Jekyll.configuration({
"skip_config_files" => true,
"source" => source_dir,
"destination" => dest_dir
}))
end
should "ensure valid posts are valid" do
@ -145,7 +148,7 @@ class TestPost < Test::Unit::TestCase
do_render(post)
post.write(dest_dir)
assert !File.exist?(unexpected)
assert !File.exist?(unexpected), "../../../baddie.html should not exist."
assert File.exist?(File.expand_path("baddie.html", dest_dir))
end
@ -606,7 +609,7 @@ class TestPost < Test::Unit::TestCase
should "include templates" do
post = setup_post("2008-12-13-include.markdown")
post.site.source = File.join(File.dirname(__FILE__), 'source')
post.site.instance_variable_set(:@source, File.join(File.dirname(__FILE__), 'source'))
do_render(post)
assert_equal "<<< <hr />\n<p>Tom Preston-Werner\ngithub.com/mojombo</p>\n\n<p>This <em>is</em> cool</p>\n >>>", post.output