Skip to content

Commit

Permalink
Impl one RSpec on aggregate_each method [#72]
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas committed Oct 5, 2009
1 parent 3536a18 commit f2913ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Expand Up @@ -4,7 +4,7 @@ module AggregateEachNodeMixin
include Neo4j::NodeMixin
include Enumerable

has_list :groups
has_list :groups, :counter => true

def aggregate_size
groups.size
Expand Down
12 changes: 5 additions & 7 deletions test/extensions/aggregate_each_spec.rb
Expand Up @@ -19,7 +19,7 @@
end

it "should create a new group for each node" do
pending "work in progress"
#pending "work in progress"
nodes = []
4.times {nodes << Neo4j::Node.new}
nodes[0][:colour] = 'red'; nodes[0][:name] = "a"; nodes[0][:age] = 0
Expand All @@ -34,22 +34,20 @@
agg1.aggregate_each(nodes).group_by(:colour, :name).execute

# then

nodes[0].aggregate_groups.to_a.size.should == 1
g1 = nodes[0].aggregate_groups.to_a[0]
puts "G1 = #{g1.inspect}"
g1.should include('red', 'a')
g1.to_a.size.should == 2
g1[:age].should == 0 # group for @nodes[0]

agg1.should include(g1)
agg1.to_a.size.should == 4
agg1.aggregate_size.should == 4
agg1.each {|x| puts "VALUE #{x.props.inspect}"}
agg1.map{|group| group[:age]}.should include(0,1,2,3)
end

it "should delete group if the node is deleted" do
pending
pending "Need to fix lighthouse ticket 81 - Cascade delete on has_n, had_one and has_list first"

nodes = []
4.times {nodes << Neo4j::Node.new}
Expand All @@ -58,8 +56,8 @@
nodes[2][:colour] = 'red'; nodes[2][:name] = "c"; nodes[2][:age] = 2
nodes[3][:colour] = 'blue'; nodes[3][:name] = "d"; nodes[3][:age] = 3

agg1 = AggregateNode.new
agg1.aggregate_each(nodes).group_by(:colour, :name)
agg1 = AggregateEachNode.new
agg1.aggregate_each(nodes).group_by(:colour, :name).execute # TODO should not be needed to do execute
agg1.to_a.size.should == 4

# when
Expand Down

0 comments on commit f2913ea

Please sign in to comment.