Skip to content

Commit

Permalink
I did this refactoring for orient but it will be useful for Dex as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrick Wiebe committed Mar 24, 2011
1 parent 1cb87e2 commit a20571e
Showing 1 changed file with 40 additions and 32 deletions.
72 changes: 40 additions & 32 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,30 +104,32 @@ def for_tg(usage_style = :read_write, indices = true, &block)
end


def for_neo4j(usage_style = :read_write, indices = true, &block)
return unless use_graph? 'neo4j'
describe 'neo4j' do
def for_transactional_graph(name, usage_style, indices, source_graph_1, source_graph_2, unindexed_graph, block)
return unless use_graph? name
describe name do
let(:supports_custom_id) { false }
let(:graph) do
if indices
$neo_graph
source_graph_1
else
$neo_graph_no_indices
unindexed_graph
end
end
let(:graph2) do
$neo_graph2
source_graph_2
end
if usage_style == :read_only
before(:all) do
$neo_graph.v.delete!
$neo_graph2.v.delete!
source_graph_1.v.delete!
source_graph_2.v.delete!
unindexed_graph.v.delete!
end
end
around do |spec|
if usage_style == :read_write
$neo_graph.v.delete!
$neo_graph2.v.delete!
source_graph_1.v.delete!
source_graph_2.v.delete!
unindexed_graph.v.delete!
end
if spec.use_transactions?
graph.manual_transactions do
Expand All @@ -150,6 +152,10 @@ def for_neo4j(usage_style = :read_write, indices = true, &block)
end
end

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

def use_simple_graph_data
let(:setup_data) { e0; e1 }
let(:v0) { graph.create_vertex :name => 'eliza' }
Expand Down Expand Up @@ -183,28 +189,6 @@ def use_pacer_graphml_data(usage_style = :read_write, version = '')
Pacer.verbose = false
c.mock_with :rr

c.before(:suite) do
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)

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

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
end


c.alias_it_should_behave_like_to :it_uses, '-'

# Not sure what this does: ...
Expand All @@ -220,3 +204,27 @@ def use_pacer_graphml_data(usage_style = :read_write, version = '')
# }
end

puts "Using JRuby #{ JRUBY_VERSION } in #{ RUBY_VERSION } mode."
if ENV['GRAPHS'].to_s == ''
puts "Testing all graphs."
else
puts "Testing graphs: #{ ENV['GRAPHS'] }."
end
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)

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

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

0 comments on commit a20571e

Please sign in to comment.