From 7fddfc91617b48df6d8bc7798674aff3ebf6f626 Mon Sep 17 00:00:00 2001 From: nickflux Date: Mon, 26 Mar 2012 16:32:06 +0100 Subject: [PATCH] Added clean_database to Rest module to use test-delete-db-extension plugin --- README.rdoc | 20 ++++++++++++++++++++ lib/neography/rest.rb | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.rdoc b/README.rdoc index c647d16..d3012e4 100644 --- a/README.rdoc +++ b/README.rdoc @@ -341,6 +341,26 @@ Phase 2 way of doing these: * {Facebook}[https://github.com/maxdemarzi/neography/blob/master/examples/facebook_v2.rb] * {Linked In}[https://github.com/maxdemarzi/neography/blob/master/examples/linkedin_v2.rb] +=== Testing + +To run testing locally you will need to have two instances of the server running. There is some +good advice on how to set up the a second instance on the +{neo4j site}[http://docs.neo4j.org/chunked/stable/server-installation.html#_multiple_server_instances_on_one_machine]. +Connect to the second instance in your testing environment, for example: + + if Rails.env.development? + @neo = Neography::Rest.new({:port => 7474}) + elsif Rails.env.test? + @neo = Neography::Rest.new({:port => 7475}) + end + +Install the test-delete-db-extension plugin, as mentioned in the neo4j.org docs, if you want to use +the Rest clean_database method to empty your database between tests. In Rspec, for example, +put this in your spec_helper.rb: + + config.before(:each) do + @neo.clean_database("yes_i_really_want_to_clean_the_database") + end === To Do diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 9c9a3f7..d08baba 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -383,8 +383,8 @@ def batch(*args) post("/batch", options) end - ### - # FOR TESTING + # For testing (use a separate neo4j instance) + # call this before each test or spec def clean_database(sanity_check = "not_really") if sanity_check == "yes_i_really_want_to_clean_the_database" delete("/cleandb/secret-key")