summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2013-10-23 16:53:18 -0600
committerDan Allen <dan.j.allen@gmail.com>2013-10-25 00:45:41 -0600
commita54baabc7f43d3cd4e4e3142b26d296438a08d5b (patch)
tree5b99a9cd805d6099f3c8e75c586c37c776ed1b86
parent9dd3d83c3e4a2e30aa62f7057876fd41a5225bbe (diff)
resolves #731 add initial Cucumber test infrastructure
- add cucumber and rspec-expectations dependencies - add cucumber Rake task definition - add sample cucumber tests and a step definition rough-in - set version ranges for library dependencies
-rw-r--r--Gemfile1
-rw-r--r--Rakefile7
-rw-r--r--asciidoctor.gemspec18
-rw-r--r--features/open_block.feature92
-rw-r--r--features/step_definitions.rb33
-rw-r--r--features/xref.feature37
6 files changed, 180 insertions, 8 deletions
diff --git a/Gemfile b/Gemfile
index efb0d3ce..2218a887 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,5 +1,6 @@
source 'https://rubygems.org'
+# Look in asciidoctor.gemspec for runtime and development dependencies
gemspec
# enable this group to use Guard for continuous testing
diff --git a/Rakefile b/Rakefile
index d68373f5..a3ad9626 100644
--- a/Rakefile
+++ b/Rakefile
@@ -38,6 +38,13 @@ end
=end
begin
+ require 'cucumber/rake/task'
+ Cucumber::Rake::Task.new(:features) do |t|
+ end
+rescue LoadError
+end
+
+begin
require 'rdoc/task'
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
diff --git a/asciidoctor.gemspec b/asciidoctor.gemspec
index 7df75001..ef54356b 100644
--- a/asciidoctor.gemspec
+++ b/asciidoctor.gemspec
@@ -18,7 +18,7 @@ EOS
s.files = `git ls-files -z -- */* {CHANGELOG,LICENSE,README,Rakefile}*`.split "\0"
s.executables = s.files.grep(/^bin\//) { |f| File.basename f }
- s.test_files = s.files.grep(/^test\/.*_test\.rb$/)
+ s.test_files = s.files.grep(/^(?:test\/.*_test\.rb|features\/.*\.(?:feature|rb))$/)
s.require_paths = %w[lib]
s.has_rdoc = true
@@ -29,12 +29,14 @@ EOS
# erubis is needed for testing use of alternative eRuby impls
# tilt, slim and haml are needed for testing custom templates
# coderay is needed for testing syntax highlighting
- s.add_development_dependency 'coderay'
- s.add_development_dependency 'erubis'
- s.add_development_dependency 'haml'
+ s.add_development_dependency 'coderay', '~> 1.1.0'
+ s.add_development_dependency 'cucumber', '~> 1.3.1'
+ s.add_development_dependency 'erubis', '~> 2.7.0'
+ s.add_development_dependency 'haml', '~> 4.0.0'
s.add_development_dependency 'nokogiri', '~> 1.5.10'
- s.add_development_dependency 'rake'
- s.add_development_dependency 'rdoc', '~> 3.12'
- s.add_development_dependency 'slim'
- s.add_development_dependency 'tilt'
+ s.add_development_dependency 'rake', '~> 10.0.0'
+ s.add_development_dependency 'rdoc', '~> 4.0.0'
+ s.add_development_dependency 'rspec-expectations', '~> 2.14.0'
+ s.add_development_dependency 'slim', '~> 2.0.0'
+ s.add_development_dependency 'tilt', '~> 1.4.1'
end
diff --git a/features/open_block.feature b/features/open_block.feature
new file mode 100644
index 00000000..000b29a7
--- /dev/null
+++ b/features/open_block.feature
@@ -0,0 +1,92 @@
+# language: en
+Feature: Open Blocks
+ In order to group content in a generic container
+ As a writer
+ I want to be able to wrap content in an open block
+
+
+ Scenario: Render an open block that contains a paragraph to HTML
+ Given the AsciiDoc source
+ """
+ --
+ A paragraph in an open block.
+ --
+ """
+ When it is rendered using the html backend
+ Then the output should match the HTML source
+ """
+ <div class="openblock">
+ <div class="content">
+ <div class="paragraph">
+ <p>A paragraph in an open block.</p>
+ </div>
+ </div>
+ </div>
+ """
+
+
+ Scenario: Render an open block that contains a paragraph to DocBook
+ Given the AsciiDoc source
+ """
+ --
+ A paragraph in an open block.
+ --
+ """
+ When it is rendered using the docbook backend
+ Then the output should match the XML source
+ """
+ <simpara>A paragraph in an open block.</simpara>
+ """
+
+
+ Scenario: Render an open block that contains a paragraph to HTML (alt)
+ Given the AsciiDoc source
+ """
+ --
+ A paragraph in an open block.
+ --
+ """
+ When it is rendered using the html backend
+ Then the output should match the HTML structure
+ """
+ .openblock
+ .content
+ .paragraph
+ p A paragraph in an open block.
+ """
+
+
+ Scenario: Render an open block that contains a paragraph to DocBook (alt)
+ Given the AsciiDoc source
+ """
+ --
+ A paragraph in an open block.
+ --
+ """
+ When it is rendered using the docbook backend
+ Then the output should match the XML structure
+ """
+ simpara A paragraph in an open block.
+ """
+
+
+ Scenario: Render an open block that contains a list to HTML
+ Given the AsciiDoc source
+ """
+ --
+ * one
+ * two
+ * three
+ --
+ """
+ When it is rendered using the html backend
+ Then the output should match the HTML structure
+ """
+ .openblock
+ .content
+ .ulist
+ ul
+ li: p one
+ li: p two
+ li: p three
+ """
diff --git a/features/step_definitions.rb b/features/step_definitions.rb
new file mode 100644
index 00000000..3dc66cc6
--- /dev/null
+++ b/features/step_definitions.rb
@@ -0,0 +1,33 @@
+require "#{File.dirname __FILE__}/../lib/asciidoctor"
+require 'rspec/expectations'
+require 'tilt'
+require 'slim'
+
+Given /the AsciiDoc source/ do |source|
+ #@document = Asciidoctor.load source
+ @source = source
+end
+
+When /it is rendered using the html backend/ do
+ @output = Asciidoctor.render @source
+end
+
+When /it is rendered using the docbook backend/ do
+ @output = Asciidoctor.render @source, :backend => :docbook
+end
+
+Then /the output should match the (HTML|XML) source/ do |format, expect|
+ @output.should == expect
+end
+
+Then /the output should match the (HTML|XML) structure/ do |format, expect|
+ case format
+ when 'HTML'
+ options = {:format => :html5}
+ when 'XML'
+ options = {:format => :xhtml}
+ else
+ options = {}
+ end
+ Slim::Template.new(options) { @output }.render.should == Slim::Template.new(options) { expect }.render
+end
diff --git a/features/xref.feature b/features/xref.feature
new file mode 100644
index 00000000..dcb66528
--- /dev/null
+++ b/features/xref.feature
@@ -0,0 +1,37 @@
+# language: en
+Feature: Cross References
+ In order to create links to other sections
+ As a writer
+ I want to be able to use a cross reference macro
+
+
+ Scenario: Create a cross reference from an AsciiDoc cell to a section
+ Given the AsciiDoc source
+ """
+ |===
+ a|See <<_install>>
+ |===
+
+ == Install
+
+ Instructions go here.
+ """
+ When it is rendered using the html backend
+ Then the output should match the HTML structure
+ """
+ table.tableblock.frame-all.grid-all style='width:100%; '
+ colgroup
+ col style='width:100%;'
+ '
+ tbody
+ tr
+ td.tableblock.halign-left.valign-top
+ div
+ .paragraph: p
+ 'See
+ a href='#_install' Install
+ .sect1
+ h2#_install Install
+ .sectionbody
+ .paragraph: p Instructions go here.
+ """