Skip to content

Commit

Permalink
query methods are better than initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrick Wiebe committed Apr 8, 2011
1 parent 4ad4150 commit c2d320e
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions lib/pacer-neo4j/rspec.rb
@@ -1,34 +1,41 @@
class Rspec::GraphRunner
module Neo4j
def initialize(*graphs)
def all(usage_style = :read_write, indices = true, &block)
super
if use_graph?('neo4j')
path1 = File.expand_path('tmp/spec.neo4j')
dir = Pathname.new(path1)
dir.rmtree if dir.exist?
@neo_graph = Pacer.neo4j(path1)
neo4j(usage_style, indices, &block)
end

def neo4j(usage_style = :read_write, indices = true, &block)
for_graph('neo4j', usage_style, indices, true, neo_graph, neo_graph2, neo_graph_no_indices, block)
end

path2 = File.expand_path('tmp/spec.neo4j.2')
dir = Pathname.new(path2)
dir.rmtree if dir.exist?
@neo_graph2 = Pacer.neo4j(path2)
protected

path3 = File.expand_path('tmp/spec_no_indices.neo4j')
dir = Pathname.new(path3)
dir.rmtree if dir.exist?
@neo_graph_no_indices = Pacer.neo4j(path3)
@neo_graph_no_indices.drop_index :vertices
@neo_graph_no_indices.drop_index :edges
end
def neo_graph
return @neo_graph if @neo_graph
path1 = File.expand_path('tmp/spec.neo4j')
dir = Pathname.new(path1)
dir.rmtree if dir.exist?
@neo_graph = Pacer.neo4j(path1)
end

def all(usage_style = :read_write, indices = true, &block)
super
neo4j(usage_style, indices, &block)
def neo_graph2
return @neo_graph2 if @neo_graph2
path2 = File.expand_path('tmp/spec.neo4j.2')
dir = Pathname.new(path2)
dir.rmtree if dir.exist?
@neo_graph2 = Pacer.neo4j(path2)
end

def neo4j(usage_style = :read_write, indices = true, &block)
for_graph('neo4j', usage_style, indices, true, @neo_graph, @neo_graph2, @neo_graph_no_indices, block)
def neo_graph_no_indices
return @neo_graph_no_indices if @neo_graph_no_indices
path3 = File.expand_path('tmp/spec_no_indices.neo4j')
dir = Pathname.new(path3)
dir.rmtree if dir.exist?
@neo_graph_no_indices = Pacer.neo4j(path3)
@neo_graph_no_indices.drop_index :vertices
@neo_graph_no_indices.drop_index :edges
@neo_graph_no_indices
end
end

Expand Down

0 comments on commit c2d320e

Please sign in to comment.