Skip to content

Commit

Permalink
Removed dynamic accessor [#67]
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas committed Sep 16, 2009
1 parent 107cb5c commit d8b50e9
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions test/neo4j/transaction_spec.rb
Expand Up @@ -7,7 +7,6 @@

class BaseNode
include Neo4j::NodeMixin
include Neo4j::DynamicAccessorMixin
end


Expand Down Expand Up @@ -40,33 +39,33 @@ class BaseNode
end

it "should not change properties" do
node = Neo4j::Transaction.run { b = BaseNode.new; b.foo = 'foo'; b }
node = Neo4j::Transaction.run { b = BaseNode.new; b[:foo] = 'foo'; b }

# when doing a rollback
Neo4j::Transaction.run { |t|
node.foo = "changed"
node.foo.should == "changed"
node[:foo] = "changed"
node[:foo].should == "changed"
t.failure
}

# then
Neo4j::Transaction.run { node.foo.should == 'foo' }
Neo4j::Transaction.run { node[:foo].should == 'foo' }
end

it "should rollback a transaction when an exception is thrown" do
node = Neo4j::Transaction.run { b = BaseNode.new; b.foo = 'foo'; b }
node = Neo4j::Transaction.run { b = BaseNode.new; b[:foo] = 'foo'; b }

# when doing a rollback
lambda do
Neo4j::Transaction.run { |t|
node.foo = "changed"
node.foo.should == "changed"
node[:foo] = "changed"
node[:foo].should == "changed"
raise "BOOOM"
}
end.should raise_error

# then
Neo4j::Transaction.run { node.foo.should == 'foo' }
Neo4j::Transaction.run { node[:foo].should == 'foo' }

end

Expand All @@ -90,15 +89,15 @@ class BaseNode
node = nil
Neo4j::Transaction.run {
node = BaseNode.new
node.baaz = "hello"
node[:baaz] = "hello"
}

Neo4j.stop
Neo4j.start

Neo4j::Transaction.run {
node2 = Neo4j.instance.find_node(node.neo_node_id)
node2.baaz.should == "hello"
node2[:baaz].should == "hello"
}
end
end
Expand Down

0 comments on commit d8b50e9

Please sign in to comment.