summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Moulliard <ch007m@gmail.com>2014-02-03 12:27:18 +0100
committerDan Allen <dan.j.allen@gmail.com>2014-02-05 17:03:09 -0700
commit47a17845318ca5cc0ce101dc7e8a5fd4d7a22c98 (patch)
treedac68ead7727eb46e175d01e8ab143b446fe13a6
parent5a3854c98dc4dd0b81f6fb15501c9e5ff4af760a (diff)
refactor unit tests so they work in RubyMine
- explicitly add the test and lib directory to the load path - switch to the project root before running tests - add UTF-8 encoding magic header to all test files - exclude .gem file at root of project (where RubyMine puts it) This commit was modified from the original pull request by @mojavelinux
-rw-r--r--.gitignore1
-rw-r--r--test/attributes_test.rb6
-rw-r--r--test/blocks_test.rb7
-rw-r--r--test/document_test.rb5
-rw-r--r--test/extensions_test.rb6
-rw-r--r--test/invoker_test.rb5
-rw-r--r--test/lexer_test.rb6
-rw-r--r--test/links_test.rb6
-rw-r--r--test/lists_test.rb6
-rw-r--r--test/options_test.rb6
-rw-r--r--test/paragraphs_test.rb6
-rw-r--r--test/paths_test.rb6
-rw-r--r--test/preamble_test.rb6
-rw-r--r--test/reader_test.rb5
-rw-r--r--test/renderer_test.rb6
-rw-r--r--test/sections_test.rb5
-rw-r--r--test/substitutions_test.rb6
-rw-r--r--test/tables_test.rb6
-rw-r--r--test/test_helper.rb8
-rw-r--r--test/text_test.rb5
20 files changed, 91 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
index b0cacf30..6c5ba089 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
pkg/
/Gemfile.lock
/.bundle
+/*.gem
/.idea/
/.yardoc/
/rdoc/
diff --git a/test/attributes_test.rb b/test/attributes_test.rb
index 636186cd..d39a8446 100644
--- a/test/attributes_test.rb
+++ b/test/attributes_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context 'Attributes' do
context 'Assignment' do
diff --git a/test/blocks_test.rb b/test/blocks_test.rb
index 28e3e543..7e6894f0 100644
--- a/test/blocks_test.rb
+++ b/test/blocks_test.rb
@@ -1,5 +1,8 @@
-require 'test_helper'
-require 'pathname'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context "Blocks" do
context 'Line Breaks' do
diff --git a/test/document_test.rb b/test/document_test.rb
index 0be172fe..4cd159e8 100644
--- a/test/document_test.rb
+++ b/test/document_test.rb
@@ -1,5 +1,8 @@
# encoding: UTF-8
-require 'test_helper'
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context 'Document' do
diff --git a/test/extensions_test.rb b/test/extensions_test.rb
index 359bcc43..e70b676b 100644
--- a/test/extensions_test.rb
+++ b/test/extensions_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
require 'asciidoctor/extensions'
class SamplePreprocessor < Asciidoctor::Extensions::Preprocessor
diff --git a/test/invoker_test.rb b/test/invoker_test.rb
index 0a4d0908..e7577ed0 100644
--- a/test/invoker_test.rb
+++ b/test/invoker_test.rb
@@ -1,5 +1,8 @@
# encoding: UTF-8
-require 'test_helper'
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
require 'asciidoctor/cli/options'
require 'asciidoctor/cli/invoker'
diff --git a/test/lexer_test.rb b/test/lexer_test.rb
index ddec7d6c..81a6975a 100644
--- a/test/lexer_test.rb
+++ b/test/lexer_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context "Lexer" do
diff --git a/test/links_test.rb b/test/links_test.rb
index 03be723a..3be081f6 100644
--- a/test/links_test.rb
+++ b/test/links_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context 'Links' do
diff --git a/test/lists_test.rb b/test/lists_test.rb
index 1c2de4ad..8991cec8 100644
--- a/test/lists_test.rb
+++ b/test/lists_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context "Bulleted lists (:ulist)" do
context "Simple lists" do
diff --git a/test/options_test.rb b/test/options_test.rb
index 76dd8cb5..099016df 100644
--- a/test/options_test.rb
+++ b/test/options_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
require 'asciidoctor/cli/options'
context 'Options' do
diff --git a/test/paragraphs_test.rb b/test/paragraphs_test.rb
index 2a4dbb9d..ac6b3fd6 100644
--- a/test/paragraphs_test.rb
+++ b/test/paragraphs_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context 'Paragraphs' do
context 'Normal' do
diff --git a/test/paths_test.rb b/test/paths_test.rb
index 235f391f..ea7b0a5b 100644
--- a/test/paths_test.rb
+++ b/test/paths_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context 'Path Resolver' do
context 'Web Paths' do
diff --git a/test/preamble_test.rb b/test/preamble_test.rb
index ad68605b..e3daa472 100644
--- a/test/preamble_test.rb
+++ b/test/preamble_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context 'Preamble' do
diff --git a/test/reader_test.rb b/test/reader_test.rb
index 077a1130..f6cc31e9 100644
--- a/test/reader_test.rb
+++ b/test/reader_test.rb
@@ -1,5 +1,8 @@
# encoding: UTF-8
-require 'test_helper'
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
class ReaderTest < Test::Unit::TestCase
DIRNAME = File.expand_path(File.dirname(__FILE__))
diff --git a/test/renderer_test.rb b/test/renderer_test.rb
index e177b99e..6af3a572 100644
--- a/test/renderer_test.rb
+++ b/test/renderer_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
require 'tilt'
context 'Renderer' do
diff --git a/test/sections_test.rb b/test/sections_test.rb
index 91187c30..66142923 100644
--- a/test/sections_test.rb
+++ b/test/sections_test.rb
@@ -1,5 +1,8 @@
# encoding: UTF-8
-require 'test_helper'
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context 'Sections' do
context 'Ids' do
diff --git a/test/substitutions_test.rb b/test/substitutions_test.rb
index 8b0e1a22..a6898c79 100644
--- a/test/substitutions_test.rb
+++ b/test/substitutions_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
# TODO
# - test negatives
diff --git a/test/tables_test.rb b/test/tables_test.rb
index 93da390e..14962dd3 100644
--- a/test/tables_test.rb
+++ b/test/tables_test.rb
@@ -1,4 +1,8 @@
-require 'test_helper'
+# encoding: UTF-8
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context 'Tables' do
diff --git a/test/test_helper.rb b/test/test_helper.rb
index e29908ab..e6b0274e 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,10 +1,12 @@
+ASCIIDOCTOR_PROJECT_DIR = File.dirname File.dirname(__FILE__)
+Dir.chdir ASCIIDOCTOR_PROJECT_DIR
+$:.unshift File.join(ASCIIDOCTOR_PROJECT_DIR, 'lib')
+
if RUBY_VERSION < '1.9'
require 'rubygems'
end
-require "#{File.dirname __FILE__}/../lib/asciidoctor"
-# or
-#require 'asciidoctor'
+require 'asciidoctor'
require 'test/unit'
require 'nokogiri'
diff --git a/test/text_test.rb b/test/text_test.rb
index 76ed4b3f..02d59339 100644
--- a/test/text_test.rb
+++ b/test/text_test.rb
@@ -1,5 +1,8 @@
# encoding: UTF-8
-require 'test_helper'
+unless defined? ASCIIDOCTOR_PROJECT_DIR
+ $: << File.dirname(__FILE__); $:.uniq!
+ require 'test_helper'
+end
context "Text" do
test "proper encoding to handle utf8 characters in document using html backend" do