spec/woyo/world/dsl_spec.rb in woyo-world-0.0.1 vs spec/woyo/world/dsl_spec.rb in woyo-world-0.0.2
- old
+ new
@@ -3,11 +3,11 @@
describe Woyo::DSL do
before :all do
class DSLTest
include Woyo::DSL
- contains :dog, :cat
+ children :dog, :cat
end
class Dog ; def initialize id, context: nil ; end ; end
class Cat ; def initialize id, context: nil ; end ; end
end
@@ -26,54 +26,49 @@
end
end
it 'can list classes to contain' do
- DSLTest.contains.should eq [ :dog, :cat ]
+ DSLTest.children.should eq [ :dog, :cat ]
end
it 'can add classes to contain' do
- pending 'fix containment'
- class DSLTestMore < DSLTest
- contains :cow
- contains :duck
+ class DSLTest
+ children :cow
+ children :duck
end
# class Cow ; def initialize id, context: nil ; end ; end
# class Duck ; def initialize id, context: nil ; end ; end
- DSLTestMore.contains.should eq [ :dog, :cat, :cow, :duck ]
+ DSLTest.children.should eq [ :dog, :cat, :cow, :duck ]
end
- it 'can create contained objects' do
+ it 'can create child objects' do
dsl = DSLTest.new
dog = dsl.dog :brown
dog.should be_instance_of Dog
dsl.dog(:brown).should be dog
dsl.dogs[:brown].should be dog
end
- it 'can list each contained object by class' do
+ it 'has hashes of each class of child objects' do
dsl = DSLTest.new
dog_brown = dsl.dog :brown
dog_black = dsl.dog :black
cat_white = dsl.cat :white
cat_black = dsl.cat :black
dsl.dogs.should eq Hash[ brown: dog_brown, black: dog_black ]
dsl.cats.should eq Hash[ white: cat_white, black: cat_black ]
end
- it 'can list all contained objects' do
+ it 'hash a hash of all classes of child objects' do
dsl = DSLTest.new
dog_brown = dsl.dog :brown
dog_black = dsl.dog :black
cat_white = dsl.cat :white
cat_black = dsl.cat :black
- dsl.contains.keys.should eq [ :dog, :cat ]
+ dsl.children.keys.should eq [ :dog, :cat ]
cats = Hash[ white: cat_white, black: cat_black ]
dogs = Hash[ brown: dog_brown, black: dog_black ]
- dsl.contains.should eq Hash[ dog: dogs, cat: cats ]
+ dsl.children.should eq Hash[ dog: dogs, cat: cats ]
end
-
- it 'accepts string or symbol key for contained object retrieval'
-
- it 'accepts string of symbol key for contained object assignment'
end