Permalink
Browse files

tests

  • Loading branch information...
1 parent 0f0c035 commit 0690843f20ecfd3410851847141176c5a3a95c59 David Ricciardi committed Sep 22, 2010
Showing with 39 additions and 13 deletions.
  1. +18 −9 Rakefile
  2. +2 −0 test/test_helper.rb
  3. +19 −4 test/wiki_cloth_test.rb
View
@@ -4,17 +4,8 @@ require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'init'
-desc 'Default: run unit tests.'
task :default => :test
-desc 'Test the wikicloth plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
desc 'Generate documentation for the wikicloth plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
@@ -47,3 +38,21 @@ end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_tar = true
end
+
+find_file = lambda do |name|
+ file_name = lambda {|path| File.join(path, "#{name}.rb")}
+ root = $:.detect do |path|
+ File.exist?(file_name[path])
+ end
+ file_name[root] if root
+end
+
+TEST_LOADER = find_file['rake/rake_test_loader']
+multiruby = lambda do |glob|
+ system 'multiruby', TEST_LOADER, *Dir.glob(glob)
+end
+
+Rake::TestTask.new(:test) do |test|
+ test.pattern = 'test/**/*_test.rb'
+ test.verbose = true
+end
View
@@ -1,3 +1,5 @@
require 'rubygems'
require 'active_support'
require 'active_support/test_case'
+require 'test/unit'
+require File.join(File.dirname(__FILE__),'../init')
View
@@ -1,8 +1,23 @@
-require 'test_helper'
+require File.join(File.dirname(__FILE__),'test_helper')
+
+class WikiParser < WikiCloth::Parser
+ template do |template|
+ case template
+ when "noinclude"
+ "<noinclude>hello world</noinclude><includeonly>testing</includeonly>"
+ end
+ end
+end
class WikiClothTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
+
+ test "noinclude and includeonly tags" do
+ wiki = WikiParser.new(:data => "<noinclude>main page</noinclude><includeonly>never seen</includeonly>{{noinclude}}\n")
+ data = wiki.to_html
+ assert data =~ /testing/
+ assert data =~ /main page/
+ assert !(data =~ /never seen/)
+ assert !(data =~ /hello world/)
end
+
end

0 comments on commit 0690843

Please sign in to comment.