asciidoctor-doctest 2.0.0.beta.4 → 2.0.0.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.adoc +58 -0
  3. data/LICENSE +21 -0
  4. data/README.adoc +310 -0
  5. data/asciidoctor-doctest.gemspec +48 -0
  6. data/data/examples/asciidoc/embedded.adoc +15 -0
  7. data/data/examples/asciidoc/preamble.adoc +1 -2
  8. data/data/examples/asciidoc/section.adoc +9 -0
  9. data/data/examples/asciidoc/toc.adoc +21 -9
  10. data/lib/asciidoctor/doctest/html/converter.rb +1 -1
  11. data/lib/asciidoctor/doctest/io/asciidoc.rb +2 -3
  12. data/lib/asciidoctor/doctest/io/base.rb +1 -1
  13. data/lib/asciidoctor/doctest/io/xml.rb +1 -1
  14. data/lib/asciidoctor/doctest/test_reporter.rb +3 -3
  15. data/lib/asciidoctor/doctest/version.rb +1 -1
  16. metadata +20 -69
  17. data/doc/img/doctest-diag.odf +0 -0
  18. data/doc/img/doctest-diag.svg +0 -56
  19. data/doc/img/failing-test-term.gif +0 -0
  20. data/features/README +0 -1
  21. data/features/fixtures/html-slim/Rakefile +0 -9
  22. data/features/fixtures/html-slim/examples/asciidoc/document.adoc +0 -4
  23. data/features/fixtures/html-slim/examples/asciidoc/inline_quoted.adoc +0 -2
  24. data/features/fixtures/html-slim/examples/asciidoc/quote.adoc +0 -12
  25. data/features/fixtures/html-slim/examples/html/document.html +0 -7
  26. data/features/fixtures/html-slim/examples/html/quote.html +0 -26
  27. data/features/fixtures/html-slim/templates/document.html.slim +0 -13
  28. data/features/fixtures/html-slim/templates/embedded.html.slim +0 -3
  29. data/features/fixtures/html-slim/templates/inline_quoted.html.slim +0 -8
  30. data/features/fixtures/html-slim/templates/paragraph.html.slim +0 -1
  31. data/features/fixtures/html-slim/templates/quote.html.slim +0 -7
  32. data/features/generator_html.feature +0 -171
  33. data/features/step_definitions/doctest_steps.rb +0 -5
  34. data/features/support/env.rb +0 -24
  35. data/features/test_html.feature +0 -98
  36. data/spec/asciidoc_converter_spec.rb +0 -64
  37. data/spec/example_spec.rb +0 -180
  38. data/spec/factory_spec.rb +0 -46
  39. data/spec/html/converter_spec.rb +0 -137
  40. data/spec/html_normalizer_spec.rb +0 -70
  41. data/spec/io/asciidoc_spec.rb +0 -139
  42. data/spec/io/xml_spec.rb +0 -141
  43. data/spec/minitest_diffy_spec.rb +0 -59
  44. data/spec/no_fallback_template_converter_spec.rb +0 -38
  45. data/spec/shared_examples/base_examples.rb +0 -289
  46. data/spec/spec_helper.rb +0 -39
  47. data/spec/support/matchers.rb +0 -7
  48. data/spec/tester_spec.rb +0 -153
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bde064e105bfbe66ef6457b1f30318dca3a8376a
4
- data.tar.gz: f8fc3a4cf46648290eb70b462b210a91ae46331c
2
+ SHA256:
3
+ metadata.gz: cf074a0fcedbb0d74ae5c7cc8e9aeefa706fa6e03016fb93ca501c557b4d3a52
4
+ data.tar.gz: 9f2f7155e7612b8d2831db50e9500586b88eb4aacd24cb5550c09f97d2427714
5
5
  SHA512:
6
- metadata.gz: c1c26f53f43f7de304d9921bc737b0978fe13e84b552f3aacb94331623cb13e7ab5a1f48cd69879ee3f23f0a97c86aa13152e35591b480c6c0c92ee66a239d4b
7
- data.tar.gz: b81e1405c6b9c2ae6969f22419954f6200f36763aac8fff373d374c41c5a042ada975b9956b224f9ef98bef57545d7ef09697dc09b7c0ff8aec95d6f6c9ea9be
6
+ metadata.gz: 9a9f1542f352bc4d9b50ef4c88b5e0296284c1b699447b9491b93a7b7cb76ff7025152dbbfe5e5f4760282c56a6f7e48a15f0a4fa9f501c90cd5a97ca47e5d31
7
+ data.tar.gz: 07ae456cf30b74706fe3b76d31f7f722804cb15addb5a86944de1be07b8e5d04d76e1b02b4fbdec111dd25c3c44372ca759a5e0dedcdd71bd52e107200e14bb1
data/CHANGELOG.adoc ADDED
@@ -0,0 +1,58 @@
1
+ = Asciidoctor::DocTest Changelog
2
+ :repo-uri: https://github.com/asciidoctor/asciidoctor-doctest
3
+ :commit-uri: {repo-uri}/commit
4
+ :issue-uri: {repo-uri}/issues
5
+
6
+ This document provides a high-level view of the changes introduced in DocTest by release.
7
+ For a detailed view of what has changed, refer to the {repo-uri}/commits/master[commit history] on GitHub.
8
+
9
+
10
+ == 1.5.2.0 (2015-04-04)
11
+
12
+ Improvements::
13
+ * Update https://github.com/threedaymonk/htmlbeautifier[htmlbeautifier] to 1.0.0 and remove workaround in `html/html_beautifier` [{commit-uri}/6caafb0[6caafb0]].
14
+ * Extract formatting (serialization) of example’s options into `BaseExamplesSuite#format_options` to be reusable [{commit-uri}/c4d779c[c4d779c]].
15
+ * Implement serialization of examples suite into AsciiDoc [{commit-uri}/900aab8[900aab8]].
16
+ * Replace custom core extensions, ActiveSupport and Colorize with https://github.com/jirutka/corefines[Corefines]. This also means that refinements will be used instead of global monkey-patching, when running on Ruby that supports refinements (currently MRI ≥2.1.0). [{commit-uri}/50e05c1[50e05c1], {commit-uri}/2f4a42e[2f4a42e]]
17
+
18
+ Bug fixes::
19
+ * Fix implementation of `eql?` and `hash` in BaseExample [{commit-uri}/c27615b[c27615b]].
20
+
21
+
22
+ == 1.5.1.2 (2015-01-03)
23
+
24
+ Improvements::
25
+ * Support for MRI 2.0.0 and JRuby 9000-dev [{commit-uri}/8908c5d[8908c5d], {commit-uri}/748d54a[748d54a]].
26
+
27
+
28
+ == 1.5.1.1 (2014-12-30)
29
+
30
+ Bug fixes::
31
+ * Avoid setting `backend_name` to an empty string.
32
+ When there’s an empty string and code highlighter is set to Pygments or CodeRay, then Asciidoctor doesn’t highlight listings at all. [{commit-uri}/bf5f077[bf5f077]]
33
+ * Update https://github.com/threedaymonk/htmlbeautifier[htmlbeautifier] to 0.0.11 that doesn’t modify content of `pre` element and adds newlines around block elements. {issue-uri}/3[#3] [{commit-uri}/4aaa137[4aaa137]]
34
+
35
+
36
+ == 1.5.1 (2014-12-29)
37
+
38
+ Improvements::
39
+ * Rename parameter `renderer_opts` to `converter_opts` and method `render` to `convert` to be consistent with Asciidoctor (old names are aliased for now). {issue-uri}/2[#2] [{commit-uri}/97c06af[97c06af]]
40
+ * Rename `to_s` to `content_pretty` in BaseExample and make alias. [{commit-uri}/3b610e2[3b610e2]]
41
+
42
+ Bug fixes::
43
+ * Allow to modify default `examples_path` in GeneratorTask (was frozen). [{commit-uri}/7251e6c[7251e6c]]
44
+ * Fix `template_dirs` validation and default `backend_name` in AsciidocRenderer. [{commit-uri}/2a4413d[2a4413d]]
45
+ * Beautify generated HTML examples. [{commit-uri}/e9d42be[e9d42be]]
46
+ * Fix Generator to not lose description of the updated example. [{commit-uri}/0d2f4ee[0d2f4ee]]
47
+
48
+ Tests::
49
+ * Add end-to-end integration tests using Cucumber.
50
+ * Increase (unit) test coverage from 84.2% to 88.5%.
51
+
52
+ Known issues::
53
+ * HTML beautifier doesn’t work as expected. {issue-uri}/3[#3]
54
+
55
+
56
+ == 1.5.0 (2014-12-09)
57
+
58
+ The first stable release.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright 2014-2018 Jakub Jirutka <jakub@jirutka.cz> and the Asciidoctor Project.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,310 @@
1
+ = Asciidoctor::DocTest
2
+ Jakub Jirutka <https://github.com/jirutka[@jirutka]>
3
+ :source-language: ruby
4
+ // custom
5
+ :gem-name: asciidoctor-doctest
6
+ :gh-name: asciidoctor/{gem-name}
7
+ :gh-branch: master
8
+ :badge-style: flat
9
+ :doctor-man-uri: http://asciidoctor.org/docs/user-manual
10
+ :rawgit-base: https://cdn.rawgit.com/{gh-name}/master
11
+ :src-base: lib/asciidoctor/doctest
12
+
13
+ image:https://img.shields.io/travis/{gh-name}/{gh-branch}.svg?style={badge-style}[Build Status, link="https://travis-ci.org/{gh-name}"]
14
+ image:https://img.shields.io/codeclimate/coverage/github/{gh-name}.svg?style={badge-style}[Test Coverage, link="https://codeclimate.com/github/{gh-name}"]
15
+ image:https://img.shields.io/codeclimate/github/{gh-name}.svg?style={badge-style}[Code Climate, link="https://codeclimate.com/github/{gh-name}"]
16
+ image:https://inch-ci.org/github/{gh-name}.svg?branch={gh-branch}&style={badge-style}[Inline docs, link="http://inch-ci.org/github/{gh-name}"]
17
+ image:https://img.shields.io/gem/v/{gem-name}.svg?style={badge-style}[Gem Version, link="https://rubygems.org/gems/{gem-name}"]
18
+ image:https://img.shields.io/badge/yard-docs-blue.svg?style={badge-style}[Yard Docs, link="http://www.rubydoc.info/github/{gh-name}/frames"]
19
+
20
+ DocTest is a tool for end-to-end testing of Asciidoctor _backends_ based on comparing of textual output.
21
+
22
+ It provides a collection of categorized <<input-examples, input _examples_>> (documents in AsciiDoc syntax) to simplify and systematize writing tests for new backends.
23
+ You just write or <<generate-examples, generate>> the expected output, i.e. what the backend should produce for the given input.
24
+
25
+ image::{rawgit-base}/doc/img/doctest-diag.svg[diagram, align="center"]
26
+
27
+ Each example should be focused on one use case, so when writing a new backend, you can incrementally implement new features following the reference input examples.
28
+ However, they are not strictly isolated like unit tests.
29
+ For example, if you change a format of a paragraph, it may affect a variety of other examples.
30
+
31
+ When test fails, DocTest prints a nicely formatted diff of the expected and actual output (see <<run-tests>>), so you see exactly what went wrong.
32
+ Insignificant differences, such as attributes order in HTML, are ignored.
33
+
34
+ DocTest supports HTML-based backends and can be easily <<how-to-extend-it, extended>> to support any other backend with textual output.
35
+
36
+
37
+ == Setup DocTest
38
+
39
+ Let’s say that you’re developing a new shiny HTML template-based backend named “shiny” and assume that you have templates in the directory `data/templates`.
40
+
41
+ . Create a directory for your output examples:
42
+ +
43
+ [source, sh]
44
+ mkdir -p test/examples/shiny
45
+ +
46
+ and optionally a directory for your extra input examples:
47
+ +
48
+ [source, sh]
49
+ mkdir -p test/examples/asciidoc
50
+
51
+ . Add development dependency on `asciidoctor-doctest` to your gemspec:
52
+ +
53
+ [source, ruby]
54
+ s.add_development_dependency 'asciidoctor-doctest', '~> 2.0.0'
55
+ +
56
+ or Gemfile if you’re not distributing the backend as a gem:
57
+ +
58
+ [source, ruby]
59
+ gem 'asciidoctor-doctest', '~> 2.0.0'
60
+ +
61
+ and run `bundle install`.
62
+
63
+ . Create or edit `Rakefile` and configure DocTest tasks:
64
+ +
65
+ [source, ruby]
66
+ ----
67
+ require 'asciidoctor/doctest'
68
+ require 'thread_safe'
69
+ require 'tilt'
70
+
71
+ DocTest::RakeTasks.new(:doctest) do |t|
72
+ # Add extra input examples; if you don’t need that, you can omit this.
73
+ t.input_examples :asciidoc, path: [
74
+ *DocTest.examples_path,
75
+ 'test/examples/asciidoc'
76
+ ]
77
+ t.output_examples :html, path: 'test/examples/shiny'
78
+ t.converter = DocTest::HTML::Converter
79
+ t.converter_opts = {
80
+ template_dirs: 'data/templates'
81
+ }
82
+ end
83
+ ----
84
+
85
+ . Check if rake loads the DocTest tasks _doctest_, _doctest:test_ and _doctest:generate_.
86
+ +
87
+ [source, sh]
88
+ bundle exec rake -D
89
+
90
+
91
+ == Run tests
92
+
93
+ Assume that you have defined the Rake tasks in the default namespace _doctest_ (see above).
94
+ Then you can simply run:
95
+
96
+ [source, sh]
97
+ bundle exec rake doctest:test
98
+
99
+ To test only specific examples, use `PATTERN` with glob-like expression:
100
+
101
+ [source, sh]
102
+ bundle exec rake doctest:test PATTERN='inline_*:*'
103
+
104
+ For verbose output, use `VERBOSE=yes`:
105
+
106
+ [source, sh]
107
+ bundle exec rake doctest:test VERBOSE=yes
108
+
109
+ image::doc/img/failing-test-term.gif[Failing test in term, align="center"]
110
+
111
+
112
+ == Examples
113
+
114
+ Test _example_ is just a document fragment in AsciiDoc syntax (a reference input), or the backend’s target syntax (an expected output).
115
+ Example should consider one case of the generated output, i.e. it should reflect one code branch in a converter or template.
116
+ Examples are grouped in _example groups_.
117
+ Each group focuses on one block or inline element — more precisely Asciidoctor’s AST node (paragraph, table, anchor, footnote…).
118
+
119
+ Examples group is a text file named similar to Asciidoctor templates, i.e. the AST node name with an extension according to syntax, for example `table.adoc`, `table.html`. See below for a list of the AST nodes.
120
+ Individual examples in the group file are separated by a special header with the name of the example, an optional description and options.
121
+
122
+ Each example is identified by its name and the group name like this: `{group_name}:{example_name}` (e.g. `table:with-title`).
123
+ Input and output examples are paired — for every input example there should be an output example with the same identifier.
124
+ When you <<run-tests, run tests>>, the input example is converted using the tested backend (or templates) and its actual output is compared with the expected output example.
125
+
126
+ [horizontal]
127
+ .List of Asciidoctor’s AST nodes
128
+ document:: TODO
129
+ embedded:: TODO
130
+ section:: {doctor-man-uri}/#sections[document sections], i.e. headings
131
+ admonition:: {doctor-man-uri}/#admonition[an admonition block]
132
+ audio:: {doctor-man-uri}/#audio[an audio block]
133
+ colist:: {doctor-man-uri}/#callouts[a code callouts] list
134
+ dlist:: {doctor-man-uri}/#labeled-list[a labeled list] (aka definition list) and {doctor-man-uri}/#question-and-answer-style-list[a Q&A style list]
135
+ example:: {doctor-man-uri}/#example[an example block]
136
+ floating_title:: {doctor-man-uri}/#discrete-or-floating-section-titles[a discrete or floating section title]
137
+ image:: {doctor-man-uri}/#images[an image block]
138
+ listing:: {doctor-man-uri}/#listing-blocks[a listing and source code block]
139
+ literal:: {doctor-man-uri}/#literal-text-and-blocks[a literal block]
140
+ olist:: {doctor-man-uri}/#ordered-lists[an ordered list] (i.e. numbered list)
141
+ open:: {doctor-man-uri}/#open-blocks[open blocks], {doctor-man-uri}/#user-abstractabstract[abstract], …
142
+ outline:: an actual {doctor-man-uri}/#user-toc[TOC] content (i.e. list of links), usually recursively called
143
+ page_break:: {doctor-man-uri}/#page-break[page break]
144
+ paragraph:: {doctor-man-uri}/#paragraph[a paragraph]
145
+ pass:: {doctor-man-uri}/#pass-bl[a passthrough block]
146
+ preamble:: {doctor-man-uri}/#doc-preamble[a preamble], optionally with a TOC
147
+ quote:: {doctor-man-uri}/#quote[a quote block]
148
+ sidebar:: {doctor-man-uri}/#sidebar[a sidebar]
149
+ stem:: {doctor-man-uri}/#stem[a STEM block] (Science, Technology, Engineering and Math)
150
+ table:: {doctor-man-uri}/#tables[a table]
151
+ thematic_break:: {doctor-man-uri}/#horizontal-rules[a thematic break] (i.e. horizontal rule)
152
+ toc:: {doctor-man-uri}/#manual-placement[a TOC macro] (i.e. manually placed TOC); This block is used for `toc::[]` macro only and it’s responsible just for rendering of a the TOC “envelope,” not an actual TOC content.
153
+ ulist:: {doctor-man-uri}/#unordered-lists[an unordered list] (aka bullet list) and a {doctor-man-uri}/#checklist[checklist] (e.g. TODO list)
154
+ verse:: {doctor-man-uri}/#verse[a verse block]
155
+ video:: {doctor-man-uri}/#video[a video block]
156
+ inline_anchor:: {doctor-man-uri}/#url[anchors] (links, cross references and bibliography references)
157
+ inline_break:: {doctor-man-uri}/#line-breaks[line break]
158
+ inline_button:: {doctor-man-uri}/#ui-buttons[UI button]
159
+ inline_callout:: {doctor-man-uri}/#callouts[code callout] icon/mark inside a code block
160
+ inline_footnote:: {doctor-man-uri}/#user-footnotes[footnote]
161
+ inline_image:: {doctor-man-uri}/#images[inline image] and {doctor-man-uri}/#inline-icons[inline icon]
162
+ inline_kbd:: {doctor-man-uri}/#keyboard-shortcuts[keyboard shortcut]
163
+ inline_menu:: {doctor-man-uri}/#menu-selections[menu section]
164
+ inline_quoted:: {doctor-man-uri}/#quotes[text formatting]; emphasis, strong, monospaced, superscript, subscript, curved quotes and inline STEM
165
+
166
+
167
+ === Input examples
168
+
169
+ DocTest provides a collection of the reference input examples that should be suitable for most backends.
170
+ You can find them in link:data/examples/asciidoc[].footnote:[Since GitHub implicitly renders them as a plain AsciiDoc, you must view a Raw source if you want to see what’s going on there.]
171
+ There are a lot of test examples and some of them may not be relevant to your backend — that’s okay, when some output example is not found, it’s marked as skipped in test.
172
+
173
+ You can also write your own input examples and use them together with those provided (or replace them).
174
+ Just add another directory to your examples_path (e.g. `test/examples/asciidoc`) and create example group files with `.adoc` suffix here (e.g. `video.adoc`).
175
+ When DocTest is looking for examples to test, it indexes all examples found in files with `.adoc` suffix on the examples_path.
176
+ If there are two files with the same name, it simply merges their content, and if they contain two examples with the same name, then the first wins (i.e. that from the file that is ahead on the examples_path).
177
+
178
+ ==== Format
179
+
180
+ [source, asciidoc]
181
+ ----
182
+ // .first-example
183
+ // Each block must be preceded by a header (comment); the first line must
184
+ // contain the example’s name prefixed with a dot. This text is interpreted
185
+ // as a description.
186
+ The example’s content in *Asciidoc*.
187
+
188
+ NOTE: The trailing new line (below this) will be removed.
189
+
190
+ // .second-example
191
+ * List item level 1
192
+ ** List item level 2
193
+
194
+ ----
195
+
196
+ === HTML-based examples
197
+
198
+ HtmlTest assumes that paragraphs are enclosed in `<p></p>` tags and implicitly sets the _include_ option to `./p/node()` for `inline_*:*` examples (if _include_ is not already set).
199
+ If it’s not your case, then you must overwrite it:
200
+
201
+ [source, ruby]
202
+ ----
203
+ DocTest::RakeTasks.new(:doctest) do |t|
204
+ t.output_examples :html, path: 'test/examples/shiny'
205
+ t.converter = DocTest::HTML::Converter
206
+ t.converter_opts = {
207
+ template_dirs: 'data/templates',
208
+ paragraph_xpath: './div/p/node()' //<1>
209
+ }
210
+ end
211
+ ----
212
+
213
+ ==== Options
214
+
215
+ List of options that can be set in the header of HTML example.
216
+
217
+ include::
218
+ XPath expression that specifies a subsection of the document that should be
219
+ compared (asserted). Default is `./p/node()` for `inline_*:*` groups and
220
+ empty (i.e. `.`) for others.
221
+ exclude::
222
+ XPath expression that specifies parts of the document that should _not_ be
223
+ compared (asserted). Always start the expression with a dot (e.g. `.//h1`).
224
+ This option may be used multiple times per example.
225
+ header_footer::
226
+ Option for Asciidoctor to render a full document (instead of embedded).
227
+ This is default for `document:*` group.
228
+
229
+ ==== Format
230
+
231
+ [source, html]
232
+ ----
233
+ <!-- .first-example
234
+ Each example must be preceded by a header (comment); the first line must
235
+ contain the example’s name prefixed with a dot. This text is interpreted
236
+ as a description.
237
+ -->
238
+ <p>The example’s content in <strong>HTML</strong>.</p>
239
+
240
+ <div class="note">The trailing new line (below this) will be removed.</div>
241
+
242
+ <!-- .second-example
243
+ You may also specify options for comparing or Asciidoctor renderer. Option
244
+ line starts with a semicolon, then comes the option name ended by a
245
+ semicolon and after that the option’s value (may be omitted for boolean
246
+ options).
247
+ :option_1: value 1
248
+ :option_2: value 1
249
+ :option_2: value 2
250
+ :boolean_option:
251
+ -->
252
+ <div class="colist">
253
+ <ol>
254
+ <li>Method signature</li>
255
+ <li>Some stuff inside</li>
256
+ <li>Return statement</li>
257
+ </ol>
258
+ </div>
259
+
260
+ ----
261
+
262
+
263
+ === Generate examples
264
+
265
+ Writing examples of an expected output for all the input examples from scratch is quite a chore.
266
+ Therefore DocTest provides a generator.
267
+ When you have at least partially working Asciidoctor _backend_ (converter or a set of templates), you can pass the input examples through it and generate your output examples.
268
+ Then you should verify them and modify if needed.
269
+
270
+ Assume that you have defined the Rake tasks in the default namespace _doctest_ (see <<setup-doctest>>).
271
+
272
+ Now you can generate output examples from all the input examples (those with `.adoc` extension) found on the examples_path that doesn’t already exist (i.e. it doesn’t rewrite existing):
273
+
274
+ [source, sh]
275
+ bundle exec rake doctest:generate
276
+
277
+ Same as previous, but rewrite existing tested examples:
278
+
279
+ [source, sh]
280
+ bundle exec rake doctest:generate FORCE=yes
281
+
282
+ Generate just examples for `ulist` node (i.e. all examples in `ulist.adoc` file(s) found on the examples_path) that doesn’t exist yet:
283
+
284
+ [source, sh]
285
+ bundle exec rake doctest:generate PATTERN='ulist:*'
286
+
287
+ (Re)generate examples which name starts with `basic` for all _inline_ nodes (i.e. files that starts with `inline_`):
288
+
289
+ [source, sh]
290
+ bundle exec rake doctest:generate PATTERN='inline_*:basic*' FORCE=yes
291
+
292
+
293
+ == How to extend it
294
+
295
+ You can extend DocTest to support any textual format you want.
296
+ All what you need is to subclass link:{src-base}/io/base.rb[IO::Base] and link:{src-base}/asciidoc_converter.rb[AsciidocConverter] (see link:{src-base}/html/converter.rb[HTML::Converter] for example).
297
+ Please note that this code is still in beta – refactoring is not finished, so some parts of the doctest code-base are kinda strange now (i.e. AsciidocConverter and HTML::Converter).
298
+
299
+
300
+ == Contributing
301
+
302
+ . Fork it
303
+ . Create your feature branch (`git checkout -b my-new-feature`)
304
+ . Commit your changes (`git commit -am 'Add some feature'`)
305
+ . Push to the branch (`git push origin my-new-feature`)
306
+ . Create new Pull Request
307
+
308
+ == License
309
+
310
+ This project is licensed under http://opensource.org/licenses/MIT/[MIT License]. For the full text of the license, see the link:LICENSE[LICENSE] file.
@@ -0,0 +1,48 @@
1
+ # coding: utf-8
2
+ require File.expand_path('lib/asciidoctor/doctest/version', __dir__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'asciidoctor-doctest'
6
+ s.version = Asciidoctor::DocTest::VERSION
7
+ s.author = 'Jakub Jirutka'
8
+ s.email = 'jakub@jirutka.cz'
9
+ s.homepage = 'https://github.com/asciidoctor/asciidoctor-doctest'
10
+ s.license = 'MIT'
11
+
12
+ s.summary = 'Test suite for Asciidoctor backends'
13
+ s.description = <<-EOS
14
+ A tool for end-to-end testing of Asciidoctor backends based on comparing of textual output.
15
+ EOS
16
+
17
+ s.files = Dir['data/**/*', 'lib/**/*', '*.gemspec', 'CHANGELOG*', 'LICENSE*', 'README*']
18
+ s.require_paths = ['lib']
19
+ s.has_rdoc = 'yard'
20
+
21
+ s.required_ruby_version = '>= 2.0'
22
+
23
+ # runtime
24
+ s.add_runtime_dependency 'asciidoctor', '>= 1.5.0', '< 2.1'
25
+ s.add_runtime_dependency 'corefines', '~> 1.2'
26
+ s.add_runtime_dependency 'diffy', '~> 3.0'
27
+ s.add_runtime_dependency 'htmlbeautifier', '~> 1.0'
28
+ s.add_runtime_dependency 'minitest', '~> 5.4'
29
+ s.add_runtime_dependency 'nokogiri', '~> 1.8.0'
30
+
31
+ # development
32
+ s.add_development_dependency 'bundler', '~> 1.6'
33
+ s.add_development_dependency 'rake', '~> 12.0'
34
+ s.add_development_dependency 'thread_safe', '~> 0.3'
35
+ s.add_development_dependency 'yard', '~> 0.8'
36
+
37
+ # unit tests
38
+ s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
39
+ s.add_development_dependency 'fakefs', '~> 0.11.0'
40
+ s.add_development_dependency 'simplecov', '~> 0.9'
41
+ s.add_development_dependency 'rspec', '~> 3.1'
42
+ s.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
43
+
44
+ # integration tests
45
+ s.add_development_dependency 'aruba', '~> 0.6'
46
+ s.add_development_dependency 'cucumber', '~> 2.4'
47
+ s.add_development_dependency 'slim', '~> 2.1'
48
+ end