-
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
Kenneth Schmidt
committed
Dec 3, 2009
1 parent
9b4f81d
commit eddfbb0
Showing
13 changed files
with
169 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
'a' => 'a', | ||
'c' => 'b', | ||
'd' => 'Foo', | ||
}; |
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 @@ | ||
{ | ||
'a' => 'a', | ||
'b' => { | ||
'a' => [ 'a', 'b', 'c' ], | ||
'b' => 'a', | ||
}, | ||
'c' => 'b', | ||
'd' => 'Bar', | ||
}; |
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,5 @@ | ||
{ | ||
'a' => 'a', | ||
'c' => 'b', | ||
'd' => 'Foo', | ||
}; |
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,8 @@ | ||
{ | ||
'a' => 'a', | ||
'b' => { | ||
'a' => [ 'a', 'b', 'c' ], | ||
'b' => 'a', | ||
}, | ||
'c' => 'b', | ||
}; |
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,34 @@ | ||
--- | ||
class: Collection | ||
type: map | ||
mapping: | ||
"a": | ||
type: str | ||
enum: | ||
- a | ||
- b | ||
default: "a" | ||
"b": | ||
type: map | ||
mapping: | ||
"a": | ||
type: seq | ||
required: no | ||
sequence: | ||
- { type: str, unique: yes } | ||
"b": | ||
type: any | ||
default: true | ||
"c": | ||
type: seq | ||
required: no | ||
sequence: | ||
- { type: str, unique: yes } | ||
"c": | ||
type: str | ||
pattern: /^(a|b|c)$/ | ||
required: no | ||
"d": | ||
type: str | ||
name: HookOne | ||
required: yes |
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,33 @@ | ||
--- | ||
class: Collection | ||
mapping: | ||
"a": | ||
type: str | ||
enum: | ||
- a | ||
- b | ||
default: "a" | ||
"b": | ||
type: map | ||
mapping: | ||
"a": | ||
type: seq | ||
required: no | ||
sequence: | ||
- { type: str, unique: yes } | ||
"b": | ||
type: any | ||
default: true | ||
"c": | ||
type: seq | ||
required: no | ||
sequence: | ||
- { type: str, unique: yes } | ||
"c": | ||
type: str | ||
pattern: /^(a|b|c)$/ | ||
required: no | ||
"d": | ||
type: str | ||
name: HookOne | ||
required: yes |
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,18 @@ | ||
# -*- mode: yaml; tab-width: 2; indent-tabs-mode: nil; -*- | ||
--- | ||
class: Config | ||
type: map | ||
mapping: | ||
"a": | ||
type: map | ||
mapping: | ||
"b": { type: int, required: yes } | ||
"c": { type: int, required: yes } | ||
"d": { type: int, required: yes } | ||
"e": { type: int, required: yes } | ||
"f": | ||
type: seq | ||
required: no | ||
sequence: | ||
- type: str | ||
unique: yes |
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,12 @@ | ||
{ | ||
'a' => { | ||
'b' => 8, | ||
'c' => 6, | ||
'd' => 4, | ||
'e' => 3, | ||
'f' => [ 'a', | ||
'b', | ||
'c', | ||
], | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,9 +1,18 @@ | ||
require 'rubygems' | ||
require 'test/unit' | ||
|
||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
TESTDIR = File.dirname(__FILE__) | ||
$LOAD_PATH.unshift(TESTDIR) | ||
$LOAD_PATH.unshift(File.join(TESTDIR, '..', 'lib')) | ||
|
||
require 'yamo' | ||
|
||
class Test::Unit::TestCase | ||
class CollectionTest < Yamo::Collection | ||
schema "#{TESTDIR}/data/schemas/collection.yaml" | ||
objectdir "#{TESTDIR}/data/collection" | ||
end | ||
|
||
class SingletonTest < Yamo::Singleton | ||
schema "#{TESTDIR}/data/schemas/singleton.yaml" | ||
object "#{TESTDIR}/data/singleton.conf" | ||
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,11 @@ | ||
require 'helper' | ||
|
||
class TestCollection < Test::Unit::TestCase | ||
def test_load | ||
assert_equal(2, CollectionTest.entries.count) | ||
assert_equal('obj1', CollectionTest.get("obj1").name) | ||
assert_equal(1, CollectionTest.find_all { |c| c.d == "Bar" }.count) | ||
obj = CollectionTest.entries.first | ||
assert_equal(true, obj.b.b) | ||
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,8 @@ | ||
require 'helper' | ||
|
||
class TestSingleton < Test::Unit::TestCase | ||
def test_load | ||
assert_equal(8, SingletonTest.instance.a.b) | ||
assert_equal(3, SingletonTest.instance.a.f.count) | ||
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,14 @@ | ||
require 'helper' | ||
|
||
class TestValidation < Test::Unit::TestCase | ||
def test_load | ||
CollectionTest.objectdir "#{TESTDIR}/data/collection_bogus" | ||
assert_raise Yamo::ValidateError do | ||
CollectionTest.entries | ||
end | ||
|
||
assert_raise Yamo::ValidateError do | ||
CollectionTest.schema "#{TESTDIR}/data/schemas/collection_bogus.yaml" | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.