mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-02-22 12:19:01 +00:00
Add spec tests for GitHub raw content include processor
This commit is contained in:
parent
33faaeac88
commit
821d5eeb27
4
spec/fixtures/asciidoctor-v2.0.0-Rakefile
vendored
Normal file
4
spec/fixtures/asciidoctor-v2.0.0-Rakefile
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
Dir.glob('tasks/*.rake').each {|file| load file }
|
||||||
|
|
||||||
|
task default: %w(test:all)
|
20
spec/fixtures/nixpkgs-a46b89df91f56c8aca7de32d270422353d855483-COPYING
vendored
Normal file
20
spec/fixtures/nixpkgs-a46b89df91f56c8aca7de32d270422353d855483-COPYING
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Copyright (c) 2003-2019 Eelco Dolstra and the Nixpkgs/NixOS contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
44
spec/github_raw_content_include_processor_spec.rb
Normal file
44
spec/github_raw_content_include_processor_spec.rb
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
describe GitHubRawIncludeProcessor do
|
||||||
|
it 'should include the raw content of a GitHub file successfully' do
|
||||||
|
input = <<~INPUT
|
||||||
|
[literal]
|
||||||
|
....
|
||||||
|
include::github:asciidoctor/asciidoctor[path=Rakefile, rev=v2.0.0]
|
||||||
|
....
|
||||||
|
INPUT
|
||||||
|
|
||||||
|
expected = File.read(fixtures_file('asciidoctor-v2.0.0-Rakefile'))
|
||||||
|
|
||||||
|
actual = Asciidoctor.convert input.tr_s '\n', '\n'
|
||||||
|
(expect actual).to include expected.chomp
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should get the raw content of COPYING from nixpkgs at a specific commit' do
|
||||||
|
commit = 'a46b89df91f56c8aca7de32d270422353d855483'
|
||||||
|
input = <<~INPUT
|
||||||
|
[literal]
|
||||||
|
....
|
||||||
|
include::github:NixOS/nixpkgs[rev=#{commit}, path=COPYING]
|
||||||
|
....
|
||||||
|
INPUT
|
||||||
|
|
||||||
|
expected = File.read(fixtures_file("nixpkgs-#{commit}-COPYING"))
|
||||||
|
|
||||||
|
actual = (Asciidoctor.convert input).tr_s '\n', '\n'
|
||||||
|
(expect actual).to include expected.chomp
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not process since it points to the root directory of the repo' do
|
||||||
|
input = 'include::github:asciidoctor/asciidoctor[]'
|
||||||
|
|
||||||
|
expect { Asciidoctor.convert input }.to raise_error StandardError
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should fail to point to non-existent repo' do
|
||||||
|
input = 'include::github:nonexistentrepoyay/OKOKOKOKOKOKOK[path=README.adoc, rev=v2.0.0]'
|
||||||
|
|
||||||
|
expect { Asciidoctor.convert input }.to raise_error StandardError
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user