Skip to content

Commit

Permalink
Started setup for doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
James Carlson committed Dec 10, 2014
1 parent 2c243b7 commit 7876810
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source 'https://rubygems.org'

ruby '2.1.2'

gem 'asciidoctor', '~> 1.5.0', '>= 1.5.0'

gem 'rake', '~> 10.0'

# gem 'aruba'

gem 'asciidoctor-doctest', '~> 1.5'
25 changes: 25 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ require File.expand_path('lib/asciidoctor-latex/version', File.dirname(__FILE__)

require 'rake/clean'

require 'asciidoctor/doctest'
require 'rake/testtask'
require 'thread_safe'
# require 'tilt'

default_tasks = []

begin
Expand Down Expand Up @@ -78,3 +83,23 @@ end
# =end

task :default => default_tasks unless default_tasks.empty?

################################################################

Rake::TestTask.new(:test) do |task|
task.description = 'Run tests for templates'
task.pattern = 'test/templates_test.rb'
task.libs << 'test'
end

DocTest::GeneratorTask.new(:generate) do |task|
task.output_suite = DocTest::HTML::ExamplesSuite.new(examples_path: 'test/examples/html')
task.renderer_opts[:template_dirs] = 'data/templates'

This comment has been minimized.

Copy link
@jirutka

jirutka Dec 10, 2014

template_dirs is for templates-based backends only (Slim, Haml, ERB, …), that’s not the case of the latex backend. Use task.renderer_opts[:backend_name] = :latex instead.

#
# add extra input examples (optional)
task.examples_path.unshift 'test/examples/adoc'
end

# When no task specified, run test.
task :default => :test

2 changes: 1 addition & 1 deletion asciidoctor-latex.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ An extension for Asciidoctor that converts AsciiDoc documents to LaTeX.

s.add_runtime_dependency 'asciidoctor', '~> 1.5.0', '>= 1.5.0'

spec.add_development_dependency("aruba")
# spec.add_development_dependency("aruba")
end
6 changes: 6 additions & 0 deletions test/templates_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'test_helper'

class TestTemplates < DocTest::Test
renderer_opts template_dirs: 'data/templates'

This comment has been minimized.

Copy link
@jirutka

jirutka Dec 10, 2014

template_dirs is for templates-based backends only (Slim, Haml, ERB, …), that’s not the case of the latex backend. Use renderer_opts backend_name: :latex instead.

This comment has been minimized.

Copy link
@jxxcarlson

jxxcarlson via email Dec 10, 2014

Owner
generate_tests! DocTest::HTML::ExamplesSuite

This comment has been minimized.

Copy link
@jirutka

jirutka Dec 10, 2014

Since this backend isn’t producing HTML, but LaTeX, it doesn’t make sense to use DocTest::HTML::ExamplesSuite here.

I’ve prepared some basic support for LaTeX backends in branch latex, but there are some issues we must discuss.

end
17 changes: 17 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'asciidoctor/doctest'
require 'minitest/autorun'

# used to colorize output
require 'minitest/rg'

# needed if you're testing templates-based backend
# require 'tilt'

# extra input examples (optional)
DocTest.examples_path.unshift 'test/examples/adoc'

# output examples
DocTest.examples_path.unshift 'test/examples/html'

# output examples
DocTest.examples_path.unshift 'test/examples/tex'

0 comments on commit 7876810

Please sign in to comment.