spec/integration/tree_spec.rb in dm-is-tree-0.10.2 vs spec/integration/tree_spec.rb in dm-is-tree-1.0.0.rc1

- old
+ new

@@ -1,29 +1,32 @@ require 'spec_helper' -if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES +describe DataMapper::Is::Tree do - describe DataMapper::Is::Tree do + supported_by :sqlite, :mysql, :postgres do - class Category - include DataMapper::Resource + before(:each) do - property :id, Serial - property :parent_id, Integer - property :name, String - end + class ::Category + include DataMapper::Resource - before(:all) do - Category.auto_migrate! + property :id, Serial + property :name, String + is :tree + end + + DataMapper.auto_migrate! + @root_a = Category.create(:name => 'a root') @root_b = Category.create(:name => 'b root') - @child_a = Category.create(:name => 'a child', :parent_id => @root_a.id) - @child_b = Category.create(:name => 'b child', :parent_id => @root_a.id) + @child_a = Category.create(:name => 'a child', :parent => @root_a) + @child_b = Category.create(:name => 'b child', :parent => @root_a) - @grandchild_a = Category.create(:name => 'a grandchild', :parent_id => @child_a.id) - @grandchild_b = Category.create(:name => 'b grandchild', :parent_id => @child_a.id) + @grandchild_a = Category.create(:name => 'a grandchild', :parent => @child_a) + @grandchild_b = Category.create(:name => 'b grandchild', :parent => @child_a) + end describe "roots class method" do it "should return all instances where the child_key is nil" do