forked from minad/olelo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Mendler
committed
Feb 9, 2009
1 parent
58ebe60
commit dadfd04
Showing
5 changed files
with
112 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'test/unit' | ||
require 'wiki' | ||
|
||
module GitSupport | ||
def setup | ||
@repo_path = File.expand_path(File.join(File.dirname(__FILE__), '.test')) | ||
@repo = Git.init(@repo_path) | ||
page = Wiki::Page.new(@repo, 'init.txt') | ||
page.write('This file is used to initialize the repository. It can be deleted.', 'Initialize Repository') | ||
end | ||
|
||
def teardown | ||
FileUtils.rm_rf(@repo_path) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
require 'git_support' | ||
|
||
class TC_Object < Test::Unit::TestCase | ||
include GitSupport | ||
|
||
def test_find | ||
assert_instance_of Wiki::Tree, Wiki::Object.find(@repo, '') | ||
assert_instance_of Wiki::Tree, Wiki::Tree.find(@repo, '') | ||
assert_nil Wiki::Page.find(@repo, '') | ||
|
||
assert_instance_of Wiki::Tree, Wiki::Object.find(@repo, '/') | ||
assert_instance_of Wiki::Tree, Wiki::Tree.find(@repo, '/') | ||
assert_nil Wiki::Page.find(@repo, '/') | ||
|
||
assert_instance_of Wiki::Page, Wiki::Object.find(@repo, 'init.txt') | ||
assert_nil Wiki::Tree.find(@repo, 'init.txt') | ||
assert_instance_of Wiki::Page, Wiki::Page.find(@repo, 'init.txt') | ||
|
||
assert_instance_of Wiki::Tree, Wiki::Object.find(@repo, '/') | ||
assert_instance_of Wiki::Tree, Wiki::Tree.find(@repo, '/') | ||
assert_nil Wiki::Page.find(@repo, '/') | ||
|
||
assert_instance_of Wiki::Tree, Wiki::Object.find(@repo, '/root') | ||
assert_instance_of Wiki::Tree, Wiki::Tree.find(@repo, '/root') | ||
assert_nil Wiki::Page.find(@repo, '/root') | ||
end | ||
|
||
def test_find! | ||
assert_instance_of Wiki::Tree, Wiki::Object.find!(@repo, '/root') | ||
assert_instance_of Wiki::Tree, Wiki::Tree.find!(@repo, '/root') | ||
assert_raise Wiki::Object::NotFound do | ||
Wiki::Page.find!(@repo, '/root') | ||
end | ||
|
||
assert_instance_of Wiki::Page, Wiki::Object.find!(@repo, '/init.txt') | ||
assert_instance_of Wiki::Page, Wiki::Page.find!(@repo, '/init.txt') | ||
assert_raise Wiki::Object::NotFound do | ||
Wiki::Tree.find!(@repo, '/init.txt') | ||
end | ||
|
||
assert_raise Wiki::Object::NotFound do | ||
Wiki::Object.find!(@repo, '/foo') | ||
end | ||
assert_raise Wiki::Object::NotFound do | ||
Wiki::Page.find!(@repo, '/foo') | ||
end | ||
assert_raise Wiki::Object::NotFound do | ||
Wiki::Tree.find!(@repo, '/foo') | ||
end | ||
end | ||
|
||
def test_new? | ||
assert !Wiki::Page.find(@repo, 'init.txt').new? | ||
assert !Wiki::Tree.find(@repo, '').new? | ||
assert Wiki::Page.new(@repo, 'new').new? | ||
assert Wiki::Tree.new(@repo, 'new').new? | ||
end | ||
|
||
def test_type | ||
assert Wiki::Page.find(@repo, 'init.txt').page? | ||
assert Wiki::Tree.find(@repo, '').tree? | ||
end | ||
|
||
def test_name | ||
assert_equal 'name.ext', Wiki::Object.new(@repo, '/path/name.ext').name | ||
end | ||
|
||
def test_pretty_name | ||
assert_equal 'name', Wiki::Object.new(@repo, '/path/name.ext').pretty_name | ||
end | ||
|
||
def test_path | ||
assert_equal 'path/name.ext', Wiki::Object.new(@repo, '/path/name.ext').path | ||
end | ||
|
||
def test_safe_name | ||
assert_equal '._____-_0123456789abc', Wiki::Object.new(@repo, '.#+*?=-_0123456789abc').safe_name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'git_support' | ||
|
||
class TC_Object < Test::Unit::TestCase | ||
include GitSupport | ||
|
||
def test_extension | ||
assert_equal 'path/name.ext', Wiki::Page.new(@repo, '/path/name.ext').path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters