Skip to content

Commit

Permalink
Added clean_database to Rest module
Browse files Browse the repository at this point in the history
to use test-delete-db-extension plugin
  • Loading branch information
nickflux committed Mar 26, 2012
1 parent 7990f3c commit 7fddfc9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 7fddfc9

Please sign in to comment.