Skip to content

Commit

Permalink
Fixed a RSpecs which had sideeffects (index_spec caused tx_tracker to…
Browse files Browse the repository at this point in the history
… fail if run in that order)
  • Loading branch information
andreas committed Jun 20, 2009
1 parent 8139a2a commit ad93796
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 0 additions & 4 deletions lib/neo4j/indexer.rb
Expand Up @@ -30,10 +30,6 @@ def self.remove_instance(clazz)
@instances.delete(clazz.root_class) unless @instances.nil?
end

# only for testing purpose, e.g we need to redefine an existing class
def self.clear_all_instances
@instances = nil
end

# (Re)index the given node
# :api: private
Expand Down
12 changes: 8 additions & 4 deletions test/neo4j/indexer_spec.rb
Expand Up @@ -24,12 +24,16 @@ class Company
has_n(:employees).from(Employee, :employed_by)
end

Indexer.clear_all_instances
# Indexer.clear_all_instances
@employee_indexer = Indexer.instance Employee
@company_indexer = Indexer.instance Company
@employee_indexer.add_index_in_relationship_on_property(Company, 'employees', 'employed_by', 'salary')
end

after(:all) do
Indexer.remove_instance Employee
Indexer.remove_instance Company
end

before(:each) do
Neo4j::Transaction.new
Expand Down Expand Up @@ -105,7 +109,8 @@ class Company
has_n(:employees).to(Employee)
end

Indexer.clear_all_instances
Indexer.remove_instance Employee
Indexer.remove_instance Company
@employee_indexer = Indexer.instance Employee
@company_indexer = Indexer.instance Company
@employee_indexer.add_index_in_relationship_on_property(Company, 'employees', 'employees', 'salary')
Expand Down Expand Up @@ -217,7 +222,7 @@ class Person
end

def create_indexer
Indexer.clear_all_instances
Indexer.remove_instance Person
indexer = Indexer.instance Person
indexer.add_index_in_relationship_on_property(Person, 'friends', 'friends', 'age')
indexer
Expand Down Expand Up @@ -325,7 +330,6 @@ def create_indexer
before(:each) do
@node_class = mock('nodeClass')
@node_class.should_receive(:root_class).any_number_of_times.and_return("Foo")
Indexer.clear_all_instances
@indexer = Indexer.instance @node_class
@indexer.add_index_on_property('foo')
end
Expand Down
7 changes: 3 additions & 4 deletions test/neo4j/tx_tracker_spec.rb
Expand Up @@ -20,13 +20,13 @@ def to_s
describe "TxTracker (TxNodeList)" do


before(:all) do
Neo4j.start
before(:each) do
start
Neo4j.load_tx_tracker
@tx_node_list = Neo4j::TxNodeList.instance
end

after(:all) do
after(:each) do
stop
end

Expand Down Expand Up @@ -163,7 +163,6 @@ def to_s


it "should undo a complete transaction" do
pending "Fails if the RSpecs are running in reverse order - fix it"
@tx_node_list = Neo4j::TxNodeList.instance

node1 = node2 = node3 = nil
Expand Down

0 comments on commit ad93796

Please sign in to comment.