Compare commits

..

5 Commits

Author SHA1 Message Date
Parker Moore
29d1f21df7 specs: use subject 2016-03-31 13:48:00 -07:00
Parker Moore
07c8e3e333 Try to get --trace working properly. 2016-03-31 13:43:56 -07:00
Parker Moore
b0c42090ea Add 2 more errors
- ConversionError
- LiquidRenderError
2016-03-31 13:43:56 -07:00
Parker Moore
de8547b208 Add 5 errors for config, render, doctor errors
- UnhealthySiteError is thrown when a site doesn’t pass all the `jekyll
doctor` tests
- InvalidConfigurationError is thrown if a configuration file returns
an invalid value (e.g. false) or when the configuration has set a value
that requires human intervention to change (e.g. using maruku and
setting to kramdown would cause problems so site needs to be audited
for upgrade to work properly
- InvalidFileFormatError is thrown when a non-.toml/.y(a)ml file is
given as a config file to be read in. It may be used later for invalid
source files.
- FileNotFoundError is thrown when a configuration file could not be
found. It will be used later for other errors, including trying to
include a file that’s not there.
- IncorrectDependencyError is thrown when a dependency is activated
that is not a valid version, e.g. a version of rouge that is < 1.3.0 is
activated.

Specs are also added.
2016-03-31 13:43:56 -07:00
Parker Moore
4db922d95e Add rspec to script/test and enable script/spec 2016-03-31 13:43:56 -07:00
40 changed files with 249 additions and 126 deletions

View File

@@ -6,8 +6,8 @@ Hi there! Interested in contributing to Jekyll? We'd love your help. Jekyll is a
* If you have a question about using Jekyll, start a discussion on [Jekyll Talk](https://talk.jekyllrb.com).
* If you think you've found a bug within a Jekyll plugin, open an issue in that plugin's repository.
* If you think you've found a bug within Jekyll itself, [open an issue](https://github.com/jekyll/jekyll/issues/new).
* More resources are listed on our [Help page](https://jekyllrb.com/help/).
* If you think you've found a bug within Jekyll itself, [open an issue](https://github.com/jekyll/jekyll/issues/new)
* More resources are listed on our [Help page](https://jekyllrb.com/help/)
## Ways to contribute
@@ -28,7 +28,7 @@ Whether you're a developer, a designer, or just a Jekyll devotee, there are lots
* The more information, the better. Make judicious use of the pull request body. Describe what changes were made, why you made them, and what impact they will have for users.
* Pull request are easy and fun. If this is your first pull request, it may help to [understand GitHub Flow](https://guides.github.com/introduction/flow/).
* Pull request are easy and fun. If this is your first pull request, it may help to [understand GitHub Flow](https://guides.github.com/introduction/flow/)
* If you're submitting a code contribution, be sure to read the [code contributions](#code-contributions) section below.
@@ -36,7 +36,7 @@ Whether you're a developer, a designer, or just a Jekyll devotee, there are lots
Many small changes can be made entirely through the github.com web interface.
1. Navigate to the file within [`jekyll/jekyll`](https://github.com/jekyll/jekyll) that you'd like to edit.
1. Navigate to the file within [`jekyll/jekyll`](https://github.com/jekyll/jekyll) that you'd like to edit
2. Click the pencil icon in the top right corner to edit the file
3. Make your proposed changes
4. Click "Propose file change"
@@ -48,13 +48,13 @@ That's it! You'll be automatically subscribed to receive updates as others revie
### Submitting a pull request via Git command line
1. Fork the project by clicking "Fork" in the top right corner of [`jekyll/jekyll`](https://github.com/jekyll/jekyll).
2. Clone the repository lcoally `git clone https://github.com/<you-username>/jekyll`.
1. Fork the project by clicking "Fork" in the top right corner of [`jekyll/jekyll`](https://github.com/jekyll/jekyll)
2. Clone the repository lcoally `git clone https://github.com/<you-username>/jekyll`
3. Create a new, descriptively named branch to contain your change ( `git checkout -b my-awesome-feature` ).
4. Hack away, add tests. Not necessarily in that order.
5. Make sure everything still passes by running `script/cibuild` (see [the tests section](#running-tests-locally) below)
6. Push the branch up ( `git push origin my-awesome-feature` ).
7. Create a pull request by visiting `https://github.com/<your-username>/jekyll` and following the instructions at the top of the screen.
7. Create a pull request by visiting https://github.com/<your-username>/jekyll/ and following the instructions at the top of the screen.
## Proposing updates to the documentation
@@ -84,7 +84,7 @@ If your contribution changes any Jekyll behavior, make sure to update the docume
#### Tests
* If you're creating a small fix or patch to an existing feature, a simple test is more than enough. You can usually copy/paste from an existing example in the `tests` folder, but if you need you can find out about our tests suites [Shoulda](https://github.com/thoughtbot/shoulda/tree/master) and [RSpec-Mocks](https://github.com/rspec/rspec-mocks).
* If you're creating a small fix or patch to an existing feature, a simple test if more than enough. You can usually copy/paste from an existing example in the `tests` folder, but if you need to can find out about our tests suites [Shoulda](https://github.com/thoughtbot/shoulda/tree/master) and [RSpec-Mocks](https://github.com/rspec/rspec-mocks).
* If it's a brand new feature, create a new [Cucumber](https://github.com/cucumber/cucumber/) feature, reusing existing steps where appropriate.

View File

@@ -1,7 +1,7 @@
source "https://rubygems.org"
gemspec :name => "jekyll"
gem "rake", "~> 11.0"
gem "rake", "~> 10.1"
group :development do
gem "launchy", "~> 2.3"
gem "rubocop", :branch => :master, :github => "bbatsov/rubocop"

View File

@@ -18,7 +18,6 @@
* Adds `link` Liquid tag to make generation of URL's easier (#4624)
* Allow static files to be symlinked in unsafe mode or non-prod environments (#4640)
* Add `:after_init` hook & add `Site#config=` to make resetting config easy (#4703)
* DocumentDrop: add `#<=>` which sorts by date (falling back to path) (#4741)
### Bug Fixes
@@ -38,9 +37,6 @@
* Unify method for copying special files from repo to site (#4601)
* Refresh the contributing file (#4596)
* change smartify doc from copy/paste of mardownify doc (#4653)
* Update Rake & disable warnings when running tests (#4720)
* Fix many warnings (#4537)
* Don't blindly assume the last system when determining "open" cmd (#4717)
### Site Enhancements
@@ -62,9 +58,6 @@
* Add jekyll-paspagon plugin (#4700)
* Bold-italicize note in assets documentation about needing yaml front matter (#4706)
* Highlight the `script/` calls in the Contributing documentation (#4712)
* Add Hawkins to the list of third-party plugins (#4755)
* Fix a typo in pagination doc (#4763)
* Switch second GitHub Pages link to HTTPS (#4760)
## 3.1.2 / 2016-02-19

View File

@@ -1,6 +1,8 @@
module Jekyll
class Command
class << self
attr_accessor :trace
# A list of subclasses of Jekyll::Command
def subclasses
@subclasses ||= []
@@ -26,8 +28,15 @@ module Jekyll
site.process
rescue Jekyll::Errors::FatalException => e
Jekyll.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
Jekyll.logger.error "", "------------------------------------"
Jekyll.logger.error "", "------------------------------------------"
Jekyll.logger.error "", e.message
if self.class.trace
Jekyll.logger.error "", "------------------------------------------"
Jekyll.logger.error "Stacktrace:", e.backtrace.join("\n")
else
Jekyll.logger.error "", ""
Jekyll.logger.error "", "Run jekyll with --trace for more information."
end
exit(1)
end

View File

@@ -13,6 +13,7 @@ module Jekyll
c.action do |_, options|
options["serving"] = false
self.class.trace = c.trace
Jekyll::Commands::Build.process(options)
end
end

View File

@@ -23,7 +23,7 @@ module Jekyll
if healthy?(site)
Jekyll.logger.info "Your test results", "are in. Everything looks fine."
else
abort
raise Jekyll::Errors::UnhealthySiteError
end
end

View File

@@ -33,6 +33,7 @@ module Jekyll
cmd.action do |_, opts|
opts["serving"] = true
opts["watch" ] = true unless opts.key?("watch")
self.class.trace = cmd.trace
Build.process(opts)
Serve.process(opts)
end
@@ -127,12 +128,15 @@ module Jekyll
private
def launch_browser(server, opts)
address = server_address(server, opts)
return system "start", address if Utils::Platforms.windows?
return system "xdg-open", address if Utils::Platforms.linux?
return system "open", address if Utils::Platforms.osx?
Jekyll.logger.error "Refusing to launch browser; " \
"Platform launcher unknown."
command =
if Utils::Platforms.windows?
"start"
elsif Utils::Platforms.osx?
"open"
else
"xdg-open"
end
system command, server_address(server, opts)
end
# Keep in our area with a thread or detach the server as requested

View File

@@ -2,6 +2,8 @@
module Jekyll
class Configuration < Hash
attr_accessor :default_config_file
# Default options. Overridden by values in _config.yml.
# Strings rather than symbols are used for compatibility with YAML.
DEFAULTS = Configuration[{
@@ -74,6 +76,10 @@ module Jekyll
}
}]
def self.from(other_hash = {})
Jekyll::Utils.deep_merge_hashes DEFAULTS, other_hash
end
# Public: Turn all keys into string
#
# Return a copy of the hash where all its keys are strings
@@ -112,7 +118,8 @@ module Jekyll
when /\.ya?ml/i
SafeYAML.load_file(filename) || {}
else
raise ArgumentError, "No parser for '#{filename}' is available. Use a .toml or .y(a)ml file instead."
raise Jekyll::Errors::InvalidFileFormatError,
"No parser for '#{filename}' is available. Use a .toml or .y(a)ml file instead."
end
end
@@ -132,7 +139,7 @@ module Jekyll
File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}"))
end
config_files = Jekyll.sanitized_path(source(override), "_config.#{default}")
@default_config_file = true
self.default_config_file = true
end
config_files = [config_files] unless config_files.is_a? Array
config_files
@@ -148,13 +155,13 @@ module Jekyll
check_config_is_hash!(next_config, file)
Jekyll.logger.info "Configuration file:", file
next_config
rescue SystemCallError
if @default_config_file ||= nil
rescue SystemCallError, Errno::ENOENT
if default_config_file
Jekyll.logger.warn "Configuration file:", "none"
{}
else
Jekyll.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
raise LoadError, "The Configuration file '#{file}' could not be found."
raise Jekyll::Errors::FileNotFoundError,
"The configuration file '#{file}' could not be found."
end
end
@@ -246,7 +253,7 @@ module Jekyll
end
if config.fetch('markdown', 'kramdown').to_s.downcase.eql?("maruku")
Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " \
raise Jekyll::Errors::InvalidConfigurationError, "You're using the 'maruku' " \
"Markdown processor, which has been removed as of 3.0.0. " \
"We recommend you switch to Kramdown. To do this, replace " \
"`markdown: maruku` with `markdown: kramdown` in your " \
@@ -317,7 +324,8 @@ module Jekyll
# Raises an ArgumentError if given config is not a hash
def check_config_is_hash!(extracted_config, file)
unless extracted_config.is_a?(Hash)
raise ArgumentError.new("Configuration file: (INVALID) #{file}".yellow)
raise Jekyll::Errors::InvalidConfigurationError,
"The configuration file '#{file}' is invalid: it is not a Hash."
end
end
end

View File

@@ -8,9 +8,7 @@ module Jekyll
#
# Returns the String prefix.
def self.highlighter_prefix(highlighter_prefix = nil)
if !defined?(@highlighter_prefix) || !highlighter_prefix.nil?
@highlighter_prefix = highlighter_prefix
end
@highlighter_prefix = highlighter_prefix if highlighter_prefix
@highlighter_prefix
end
@@ -22,9 +20,7 @@ module Jekyll
#
# Returns the String suffix.
def self.highlighter_suffix(highlighter_suffix = nil)
if !defined?(@highlighter_suffix) || !highlighter_suffix.nil?
@highlighter_suffix = highlighter_suffix
end
@highlighter_suffix = highlighter_suffix if highlighter_suffix
@highlighter_suffix
end

View File

@@ -6,7 +6,7 @@ module Jekyll
safe true
def setup
return if @setup ||= false
return if @setup
unless (@parser = get_processor)
Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
Jekyll.logger.info "", "Custom processors are not loaded in safe mode" if @config["safe"]

View File

@@ -18,7 +18,6 @@ module Jekyll
Jekyll::External.require_with_graceful_fail "kramdown"
@main_fallback_highlighter = config["highlighter"] || "rouge"
@config = config["kramdown"] || {}
@highlighter = nil
setup
end

View File

@@ -76,7 +76,8 @@ module Jekyll
))
unless Gem::Version.new(Rouge.version) > Gem::Version.new("1.3.0")
abort "Please install Rouge 1.3.0 or greater and try running Jekyll again."
raise Jekyll::Errors::IncorrectDependencyError,
"Please install Rouge 1.3.0 or greater and try running Jekyll again."
end
include Rouge::Plugins::Redcarpet

View File

@@ -79,9 +79,9 @@ module Jekyll
begin
converter.convert output
rescue => e
Jekyll.logger.error "Conversion error:", "#{converter.class} encountered an error while converting '#{path}':"
Jekyll.logger.error("", e.to_s)
raise e
raise Jekyll::Errors::ConversionError, "" \
"#{converter.class} encountered an error while converting '#{path}':" \
"\n#{e.to_s}"
end
end
end
@@ -112,11 +112,17 @@ module Jekyll
def render_liquid(content, payload, info, path)
site.liquid_renderer.file(path).parse(content).render!(payload, info)
rescue Tags::IncludeTagError => e
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}, included in #{path || self.path}"
raise e
rescue Exception => e
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{path || self.path}"
raise e
raise Jekyll::Errors::LiquidRenderError,
"Liquid exception in #{e.path} included in #{path || self.path}:" \
"\n#{e.message}"
rescue Liquid::Error => e
raise Jekyll::Errors::LiquidRenderError,
"Liquid exception on line #{e.line_number} in #{path || self.path}:" \
"\n#{e.message}"
rescue => e
raise Jekyll::Errors::LiquidRenderError,
"Liquid exception in #{path || self.path}:" \
"\n#{e.message}"
end
# Convert this Convertible's data to a Hash suitable for use by Liquid.

View File

@@ -20,13 +20,6 @@ module Jekyll
fallback_data['excerpt'].to_s
end
def <=>(other)
return nil unless other.is_a? DocumentDrop
cmp = self['date'] <=> other['date']
cmp = self['path'] <=> other['path'] if cmp.nil? || cmp == 0
cmp
end
private
def_delegator :@obj, :data, :fallback_data
end

View File

@@ -2,11 +2,26 @@ module Jekyll
module Errors
FatalException = Class.new(::RuntimeError)
# Errors for commands
UnhealthySiteError = Class.new(FatalException)
# Configuration errors
InvalidConfigurationError = Class.new(FatalException)
InvalidFileFormatError = Class.new(FatalException)
# IO Errors
FileNotFoundError = Class.new(FatalException)
# Render errors
DropMutationException = Class.new(FatalException)
InvalidPermalinkError = Class.new(FatalException)
InvalidYAMLFrontMatterError = Class.new(FatalException)
MissingDependencyException = Class.new(FatalException)
MissingDependencyError = Class.new(FatalException)
IncorrectDependencyError = Class.new(FatalException)
ConversionError = Class.new(FatalException)
LiquidRenderError = Class.new(FatalException)
# post_url tag errors
InvalidDateError = Class.new(FatalException)
InvalidPostNameError = Class.new(FatalException)
PostURLError = Class.new(FatalException)

View File

@@ -94,8 +94,8 @@ module Jekyll
return true if !scope.key?('path') || scope['path'].empty?
scope_path = Pathname.new(scope['path'])
Pathname.new(sanitize_path(path)).ascend do |ascended_path|
if ascended_path.to_s == scope_path.to_s
Pathname.new(sanitize_path(path)).ascend do |path|
if path.to_s == scope_path.to_s
return true
end
end

View File

@@ -98,7 +98,11 @@ module Jekyll
#
# Returns the formatted message
def message(topic, message)
msg = formatted_topic(topic) + message.to_s.gsub(/\s+/, ' ')
lines = message.to_s.split("\n")
first_line = formatted_topic(topic) + lines.shift.to_s
msg = ([first_line] + lines.map {|line|
formatted_topic("") + line.gsub(/[ ]+/, ' ')
}).join("\n")
messages << msg
msg
end

View File

@@ -60,7 +60,7 @@ module Jekyll
#
# Returns the safety Boolean.
def self.safe(safe = nil)
if !defined?(@safe) || !safe.nil?
if safe
@safe = safe
end
@safe || false

View File

@@ -1,8 +1,6 @@
module Jekyll
class Regenerator
attr_reader :site, :metadata, :cache
attr_accessor :disabled
private :disabled, :disabled=
def initialize(site)
@site = site
@@ -117,7 +115,7 @@ module Jekyll
#
# Returns nothing.
def add_dependency(path, dependency)
return if metadata[path].nil? || disabled
return if metadata[path].nil? || @disabled
unless metadata[path]["deps"].include? dependency
metadata[path]["deps"] << dependency
@@ -146,8 +144,8 @@ module Jekyll
#
# Returns a Boolean (true for disabled, false for enabled).
def disabled?
self.disabled = !site.incremental? if disabled.nil?
disabled
@disabled = !site.incremental? if @disabled.nil?
@disabled
end
private

View File

@@ -107,11 +107,17 @@ module Jekyll
def render_liquid(content, payload, info, path = nil)
site.liquid_renderer.file(path).parse(content).render!(payload, info)
rescue Tags::IncludeTagError => e
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}, included in #{path || document.relative_path}"
raise e
rescue Exception => e
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{path || document.relative_path}"
raise e
raise Jekyll::Errors::LiquidRenderError,
"Liquid exception in #{e.path} included in #{path || self.path}:" \
"\n#{e.message}"
rescue Liquid::Error => e
raise Jekyll::Errors::LiquidRenderError,
"Liquid exception on line #{e.line_number} in #{path || self.path}:" \
"\n#{e.message}"
rescue => e
raise Jekyll::Errors::LiquidRenderError,
"Liquid exception in #{path || self.path}:" \
"\n#{e.message}"
end
# Checks if the layout specified in the document actually exists

View File

@@ -300,11 +300,12 @@ module Jekyll
# Returns
def relative_permalinks_are_deprecated
if config['relative_permalinks']
Jekyll.logger.abort_with "Since v3.0, permalinks for pages" \
" in subfolders must be relative to the" \
" site source directory, not the parent" \
" directory. Check http://jekyllrb.com/docs/upgrading/"\
" for more info."
raise Jekyll::Errors::InvalidConfigurationError,
"Since v3.0, permalinks for pages" \
" in subfolders must be relative to the" \
" site source directory, not the parent" \
" directory. Check http://jekyllrb.com/docs/upgrading/"\
" for more info."
end
end

2
script/spec Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
bundle exec rspec --color --require spec_helper $@

View File

@@ -48,9 +48,13 @@ for ruby in $rubies; do
set -x
time $ruby -S bundle exec \
rake TESTOPTS='--profile' test
time $ruby -S bundle exec rspec --color \
--require spec_helper
else
set -x
time $ruby -S bundle exec ruby -Itest \
"$@" --profile
time $ruby -S bundle exec rspec --color \
--require spec_helper --profile
fi
done

View File

@@ -230,4 +230,4 @@ This entire guide is open-source. Go ahead and [edit it][3] if you have a
fix or [ask for help][4] if you run into trouble and need some help.
[3]: https://github.com/jekyll/jekyll/edit/master/site/_docs/continuous-integration.md
[4]: https://jekyllrb.com/help/
[4]: http://jekyllrb.com/help/

View File

@@ -89,7 +89,7 @@ If your contribution changes any Jekyll behavior, make sure to update the docume
#### Tests
* If you're creating a small fix or patch to an existing feature, a simple test is more than enough. You can usually copy/paste from an existing example in the `tests` folder, but if you need you can find out about our tests suites [Shoulda](https://github.com/thoughtbot/shoulda/tree/master) and [RSpec-Mocks](https://github.com/rspec/rspec-mocks).
* If you're creating a small fix or patch to an existing feature, a simple test if more than enough. You can usually copy/paste from an existing example in the `tests` folder, but if you need to can find out about our tests suites [Shoulda](https://github.com/thoughtbot/shoulda/tree/master) and [RSpec-Mocks](https://github.com/rspec/rspec-mocks).
* If it's a brand new feature, create a new [Cucumber](https://github.com/cucumber/cucumber/) feature, reusing existing steps where appropriate.

View File

@@ -898,7 +898,6 @@ LESS.js files during generation.
- [Jekyll Deploy](https://github.com/vwochnik/jekyll-deploy): Adds a `deploy` sub-command to Jekyll.
- [Official Contentful Jekyll Plugin](https://github.com/contentful/jekyll-contentful-data-import): Adds a `contentful` sub-command to Jekyll to import data from Contentful.
- [jekyll-paspagon](https://github.com/KrzysiekJ/jekyll-paspagon): Sell your posts in various formats for cryptocurrencies.
- [Hawkins](https://github.com/awood/hawkins): Adds a `liveserve` sub-command to Jekyll that incorporates [LiveReload](http://livereload.com/) into your pages while you preview them. No more hitting the refresh button in your browser!
#### Editors

View File

@@ -353,7 +353,7 @@ following is a reference of the available data.
</tr>
<tr>
<td><p><code>paginator.total_pages</code></p></td>
<td><p>Total number of pages.</p></td>
<td><p>Total number of Pages.</p></td>
</tr>
<tr>
<td><p><code>paginator.page</code></p></td>

View File

@@ -79,7 +79,7 @@ overview: true
<div class="pane-content">
<h2 class="center-on-mobiles"><strong>Free hosting</strong> with GitHub Pages</h2>
<p>Sick of dealing with hosting companies? <a href="https://pages.github.com/">GitHub Pages</a> are <em>powered by Jekyll</em>, so you can easily deploy your site using GitHub for free&mdash;<a href="https://help.github.com/articles/about-supported-custom-domains/">custom domain name</a> and&nbsp;all.</p>
<a href="https://pages.github.com/">Learn more about GitHub Pages &rarr;</a>
<a href="http://pages.github.com/">Learn more about GitHub Pages &rarr;</a>
</div>
</div>
<div class="clear"></div>

View File

@@ -1,20 +0,0 @@
---
layout: page
title: Roadmap
---
This is a high-level roadmap for Jekyll. It is a list of things we're
planning for each release. While plans are subject to change, this should
offer a bit of an overview for anyone interested in future features.
If you'd like to discuss any of the items, visit the link next to each
item and leave us a comment! We'd love to hear your thoughts.
- [v3.2](#v32)
- [v3.3](#v33)
## v3.2
For v3.2, we're interested in shipping:
1. **Gem-based themes.** This will allow users to ship layouts, includes, and sass (to start with) in a way that is more easily consumable and versionable. ([discuss]({{ site.repository }}/issues/4510))

View File

@@ -0,0 +1,37 @@
RSpec.describe(Jekyll::Configuration) do
subject { described_class.from({}) }
describe "#safe_load_file" do
it "throws an InvalidFileFormat on a bad extension" do
filename = "my_config.json"
expect(-> { subject.safe_load_file(filename) }).to raise_error(
Jekyll::Errors::InvalidFileFormatError,
"No parser for '#{filename}' is available. Use a .toml or .y(a)ml file instead."
)
end
end
describe "#read_config_file" do
it "throws a FileNotFoundError if the file doesn't exist" do
filename = "_config.yml"
expect(-> { subject.read_config_file(filename) }).to raise_error(
Jekyll::Errors::FileNotFoundError,
"The configuration file '#{filename}' could not be found."
)
end
end
describe "#check_config_is_hash!" do
it "does not throw if the input is a hash" do
expect(subject.send(:check_config_is_hash!, {}, "_config.yml")).to eq(nil)
end
it "throws an InvalidConfigurationError if the input is not a hash" do
filename = "_config.yml"
expect(-> { subject.send(:check_config_is_hash!, false, filename) }).to raise_error(
Jekyll::Errors::InvalidConfigurationError,
"The configuration file '#{filename}' is invalid: it is not a Hash."
)
end
end
end

View File

@@ -0,0 +1,7 @@
require 'spec_helper'
RSpec.describe(Jekyll::Errors) do
it "defines the base exception, FatalException" do
expect(described_class).to be_const_defined(:FatalException)
end
end

66
spec/spec_helper.rb Normal file
View File

@@ -0,0 +1,66 @@
ROOT = Pathname.new(File.expand_path("../", __dir__))
require ROOT.join("lib", "jekyll.rb")
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_than(2).and_smaller_than(4).description
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = true
end
# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options. We recommend
# you configure your source control system to ignore this file.
# config.example_status_persistence_file_path = "spec/examples.txt"
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
config.disable_monkey_patching!
# This setting enables warnings. It's recommended, but in some cases may
# be too noisy due to issues in dependencies.
config.warnings = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
end

View File

@@ -1,10 +1,3 @@
$stdout.puts "# -------------------------------------------------------------"
$stdout.puts "# SPECS AND TESTS ARE RUNNING WITH WARNINGS OFF."
$stdout.puts "# SEE: https://github.com/Shopify/liquid/issues/730"
$stdout.puts "# SEE: https://github.com/jekyll/jekyll/issues/4719"
$stdout.puts "# -------------------------------------------------------------"
$VERBOSE = nil
def jruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
end

View File

@@ -174,13 +174,15 @@ class TestConfiguration < JekyllUnitTest
allow(SafeYAML).to receive(:load_file).with(@path).and_return(Array.new)
allow($stderr).to receive(:puts).and_return(("WARNING: ".rjust(20) + "Error reading configuration. Using defaults (and options).").yellow)
allow($stderr).to receive(:puts).and_return("Configuration file: (INVALID) #{@path}".yellow)
assert_equal @@defaults, Jekyll.configuration({})
assert_raises Jekyll::Errors::InvalidConfigurationError do
Jekyll.configuration({})
end
end
should "fire warning when user-specified config file isn't there" do
allow(SafeYAML).to receive(:load_file).with(@user_config) { raise SystemCallError, "No such file or directory - #{@user_config}" }
allow($stderr).to receive(:puts).with(("Fatal: ".rjust(20) + "The configuration file '#{@user_config}' could not be found.").red)
assert_raises LoadError do
assert_raises Jekyll::Errors::FileNotFoundError do
Jekyll.configuration({'config' => [@user_config]})
end
end

View File

@@ -37,7 +37,7 @@ class TestConvertible < JekyllUnitTest
out = capture_stderr do
@convertible.read_yaml(@base, 'exploit_front_matter.erb')
end
refute_match(/undefined class\/module DoesNotExist/, out)
refute_match /undefined class\/module DoesNotExist/, out
end
should "not parse if there is encoding error in file" do

View File

@@ -158,7 +158,7 @@ class TestFilters < JekyllUnitTest
end
should "format a time with xmlschema" do
assert_match(/2014-05-10T00:10:07/, @filter.date_to_xmlschema(@time_as_numeric))
assert_match /2014-05-10T00:10:07/, @filter.date_to_xmlschema(@time_as_numeric)
end
should "format a time according to RFC-822" do

View File

@@ -91,7 +91,7 @@ class TestNewCommand < JekyllUnitTest
should 'force created folder' do
capture_stdout { Jekyll::Commands::New.process(@args) }
output = capture_stdout { Jekyll::Commands::New.process(@args, '--force') }
assert_match(/New jekyll site installed in/, output)
assert_match /New jekyll site installed in/, output
end
end

View File

@@ -232,13 +232,13 @@ class TestSite < JekyllUnitTest
context 'error handling' do
should "raise if destination is included in source" do
assert_raises Jekyll::Errors::FatalException do
Site.new(site_configuration('destination' => source_dir))
site = Site.new(site_configuration('destination' => source_dir))
end
end
should "raise if destination is source" do
assert_raises Jekyll::Errors::FatalException do
Site.new(site_configuration('destination' => File.join(source_dir, "..")))
site = Site.new(site_configuration('destination' => File.join(source_dir, "..")))
end
end
end
@@ -520,6 +520,7 @@ class TestSite < JekyllUnitTest
contacts_html = @site.pages.find { |p| p.name == "contacts.html" }
@site.process
source = @site.in_source_dir(contacts_html.path)
dest = File.expand_path(contacts_html.destination(@site.dest))
mtime1 = File.stat(dest).mtime.to_i # first run must generate dest file

View File

@@ -149,7 +149,7 @@ CONTENT
end
should "not cause a markdown error" do
refute_match(/markdown\-html\-error/, @result)
refute_match /markdown\-html\-error/, @result
end
should "render markdown with pygments" do
@@ -442,7 +442,7 @@ CONTENT
end
should "not cause an error" do
refute_match(/markdown\-html\-error/, @result)
refute_match /markdown\-html\-error/, @result
end
should "have the url to the \"complex\" post from 2008-11-21" do
@@ -466,7 +466,7 @@ CONTENT
end
should "not cause an error" do
refute_match(/markdown\-html\-error/, @result)
refute_match /markdown\-html\-error/, @result
end
should "have the url to the \"complex\" post from 2008-11-21" do
@@ -600,8 +600,7 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
@result ||= ''
refute_match(/SYMLINK TEST/, @result)
refute_match /SYMLINK TEST/, @result
end
should "not expose the existence of symlinked files" do
@@ -616,7 +615,7 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
assert_match(/should exist and should not be a symlink/, ex.message)
assert_match /should exist and should not be a symlink/, ex.message
end
end
@@ -878,8 +877,7 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
@result ||= ''
refute_match(/SYMLINK TEST/, @result)
refute_match /SYMLINK TEST/, @result
end
should "not expose the existence of symlinked files" do
@@ -894,7 +892,7 @@ title: Include symlink
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
end
assert_match(/should exist and should not be a symlink/, ex.message)
assert_match /should exist and should not be a symlink/, ex.message
end
end
end

View File

@@ -63,12 +63,12 @@ class TestURL < JekyllUnitTest
},
})
site.read
matching_doc = site.collections["methods"].docs.find do |doc|
doc = site.collections["methods"].docs.find do |doc|
doc.relative_path == "_methods/escape-+ #%20[].md"
end
assert_equal '/methods/escape-+-20/escape-20.html', URL.new(
:template => '/methods/:title/:name:output_ext',
:placeholders => matching_doc.url_placeholders
:placeholders => doc.url_placeholders
).to_s
end