File tree 3 files changed +79
-1
lines changed
3 files changed +79
-1
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,6 @@ require "rake/testtask"
133
133
Rake ::TestTask . new ( :"test-linter" ) do |t |
134
134
t . description = "Run tests for the Linter library"
135
135
t . libs = [ "test" , "lib" ]
136
- t . test_files = [ "test/test_linter.rb" ]
136
+ t . test_files = [ "test/test_linter.rb" ] + FileList [ 'test/test_linter_*.rb' ]
137
137
t . verbose = true
138
138
end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "minitest/autorun"
4
+ require "fileutils"
5
+ require "pathname"
6
+
7
+
8
+ TEST_DIR = File . expand_path ( __dir__ )
9
+ TEMP_DIR = File . join ( TEST_DIR , "tmp" )
10
+
11
+
12
+ def setup_tempdir
13
+ FileUtils . mkdir_p ( TEMP_DIR )
14
+
15
+ File . exist? ( TEMP_DIR ) ? TEMP_DIR : nil
16
+ end
17
+
18
+ def chdir_tempdir
19
+ setup_tempdir unless File . exist? ( TEMP_DIR )
20
+ Dir . chdir ( TEMP_DIR )
21
+ end
22
+
23
+ def teardown_tempdir
24
+ FileUtils . rm_rf ( TEMP_DIR ) if File . exist? ( TEMP_DIR )
25
+ end
26
+
27
+ def create_releases_file
28
+ FileUtils . mkdir_p ( "_data" )
29
+ FileUtils . touch ( "_data/releases.yml" )
30
+ end
31
+
32
+ def create_file ( path , content )
33
+ raise "path must be relative" unless Pathname . new ( path ) . relative?
34
+
35
+ dir = File . dirname ( path )
36
+ FileUtils . mkdir_p ( dir )
37
+ File . open ( path , "w" ) { |f | f . write content }
38
+ end
39
+
40
+ def linter_output
41
+ stdout , _stderr = capture_io { Linter . new ( exit_on_errors : false ) . run }
42
+
43
+ stdout
44
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "helper"
4
+ require "linter"
5
+
6
+
7
+ describe Linter do
8
+
9
+ before do
10
+ chdir_tempdir
11
+ create_releases_file
12
+
13
+ @ok = "Checking markdown files... ok\n "
14
+ end
15
+
16
+ after do
17
+ teardown_tempdir
18
+ end
19
+
20
+ it "checks ok a valid page" do
21
+ content = <<~PAGE
22
+ ---
23
+ layout: page
24
+ title: "Page"
25
+ lang: en
26
+ ---
27
+
28
+ Content
29
+ PAGE
30
+
31
+ create_file ( "en/page.md" , content )
32
+ _ ( linter_output ) . must_equal @ok
33
+ end
34
+ end
You can’t perform that action at this time.
0 commit comments