forked from github/opensource.guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "github-pages" | ||
gem "rake" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "rake/testtask" | ||
Rake::TestTask.new do |t| | ||
t.libs << "test" | ||
t.test_files = FileList["test/*_test.rb"] | ||
t.warning = false | ||
t.verbose = false | ||
end | ||
|
||
task :default => :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Each piece of content has YAML front matter with these properties: | ||
|
||
title: | ||
required: true | ||
|
||
next: | ||
type: String | ||
|
||
previous: | ||
type: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require "minitest/autorun" | ||
require "jekyll" | ||
|
||
module Helper | ||
class << self | ||
attr_accessor :config, :site | ||
end | ||
end | ||
|
||
def source | ||
File.expand_path('../', File.dirname(__FILE__)) | ||
end | ||
|
||
def config | ||
Helper.config ||= Jekyll.configuration("source" => source) | ||
end | ||
|
||
def content | ||
site.collections['content'].docs.map { |doc| doc.to_liquid } | ||
end | ||
|
||
def site | ||
Helper.site ||= begin | ||
site = Jekyll::Site.new(config) | ||
site.reset | ||
site.read | ||
site | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require_relative "./helper" | ||
|
||
describe "lint test" do | ||
|
||
content.each do |page| | ||
|
||
describe page["path"] do | ||
|
||
describe "frontmatter" do | ||
|
||
before do | ||
# Load raw metadata to skip defaults | ||
@data = SafeYAML.load_file(page["path"]) | ||
end | ||
|
||
it "contains supported fields" do | ||
extra_fields = @data.keys - site.data["fields"].keys | ||
assert extra_fields.empty?, "Unexpected metadata in #{page["path"]}: #{extra_fields.inspect}" | ||
end | ||
|
||
site.data["fields"].each do |name, attrs| | ||
it "#{name} is required" do | ||
assert @data.key?(name), "#{name} is required" | ||
end if attrs["required"] | ||
|
||
it "#{name} should be of type #{attrs["type"]}" do | ||
assert_kind_of Kernel.const_get(attrs["type"]), @data[name] if @data[name] | ||
end if attrs["type"] | ||
|
||
it "#{name} has valid attributes" do | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |