File tree Expand file tree Collapse file tree 7 files changed +90
-1
lines changed
Expand file tree Collapse file tree 7 files changed +90
-1
lines changed Original file line number Diff line number Diff line change 11source "https://rubygems.org"
22
33gem "github-pages"
4+ gem "rake"
Original file line number Diff line number Diff line change 104104 sawyer (~> 0.7.0 , >= 0.5.3 )
105105 pkg-config (1.1.7 )
106106 public_suffix (1.5.3 )
107+ rake (11.2.2 )
107108 rb-fsevent (0.9.7 )
108109 rb-inotify (0.9.7 )
109110 ffi (>= 0.5.0 )
@@ -125,6 +126,7 @@ PLATFORMS
125126
126127DEPENDENCIES
127128 github-pages
129+ rake
128130
129131BUNDLED WITH
130132 1.12.5
Original file line number Diff line number Diff line change 1+ require "rake/testtask"
2+ Rake ::TestTask . new do |t |
3+ t . libs << "test"
4+ t . test_files = FileList [ "test/*_test.rb" ]
5+ t . warning = false
6+ t . verbose = false
7+ end
8+
9+ task :default => :test
Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ baseurl: "/open-source-handbook"
22
33exclude :
44 - docs
5+ - Gemfile*
6+ - Rakefile
57 - README.md
68 - script
7- - Gemfile*
9+ - test
810
911collections :
1012 content :
Original file line number Diff line number Diff line change 1+ # Each piece of content has YAML front matter with these properties:
2+
3+ title :
4+ required : true
5+
6+ next :
7+ type : String
8+
9+ previous :
10+ type : String
Original file line number Diff line number Diff line change 1+ require "minitest/autorun"
2+ require "jekyll"
3+
4+ module Helper
5+ class << self
6+ attr_accessor :config , :site
7+ end
8+ end
9+
10+ def source
11+ File . expand_path ( '../' , File . dirname ( __FILE__ ) )
12+ end
13+
14+ def config
15+ Helper . config ||= Jekyll . configuration ( "source" => source )
16+ end
17+
18+ def content
19+ site . collections [ 'content' ] . docs . map { |doc | doc . to_liquid }
20+ end
21+
22+ def site
23+ Helper . site ||= begin
24+ site = Jekyll ::Site . new ( config )
25+ site . reset
26+ site . read
27+ site
28+ end
29+ end
Original file line number Diff line number Diff line change 1+ require_relative "./helper"
2+
3+ describe "lint test" do
4+
5+ content . each do |page |
6+
7+ describe page [ "path" ] do
8+
9+ describe "frontmatter" do
10+
11+ before do
12+ # Load raw metadata to skip defaults
13+ @data = SafeYAML . load_file ( page [ "path" ] )
14+ end
15+
16+ it "contains supported fields" do
17+ extra_fields = @data . keys - site . data [ "fields" ] . keys
18+ assert extra_fields . empty? , "Unexpected metadata in #{ page [ "path" ] } : #{ extra_fields . inspect } "
19+ end
20+
21+ site . data [ "fields" ] . each do |name , attrs |
22+ it "#{ name } is required" do
23+ assert @data . key? ( name ) , "#{ name } is required"
24+ end if attrs [ "required" ]
25+
26+ it "#{ name } should be of type #{ attrs [ "type" ] } " do
27+ assert_kind_of Kernel . const_get ( attrs [ "type" ] ) , @data [ name ] if @data [ name ]
28+ end if attrs [ "type" ]
29+
30+ it "#{ name } has valid attributes" do
31+ end
32+ end
33+ end
34+ end
35+ end
36+ end
You can’t perform that action at this time.
0 commit comments