diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index ee4ba60..982a7eb 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -55,6 +55,7 @@ class Rest include NodePaths include Cypher include Gremlin + include Clean extend Forwardable attr_reader :connection @@ -66,7 +67,6 @@ def initialize(options = ENV['NEO4J_URL'] || {}) @extensions ||= Extensions.new(@connection) @batch ||= Batch.new(@connection) - @clean ||= Clean.new(@connection) @spatial ||= Spatial.new(@connection) end @@ -167,18 +167,5 @@ def add_node_to_spatial_index(index, id) @spatial.add_node_to_spatial_index(index, id) end - # clean database - - # 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" - @clean.execute - true - else - false - end - end - end end diff --git a/lib/neography/rest/clean.rb b/lib/neography/rest/clean.rb index 69a544d..0a8a39e 100644 --- a/lib/neography/rest/clean.rb +++ b/lib/neography/rest/clean.rb @@ -1,17 +1,15 @@ module Neography class Rest - class Clean - extend Neography::Rest::Paths + module Clean include Neography::Rest::Helpers - add_path :clean, "/cleandb/secret-key" - - def initialize(connection) - @connection ||= connection - end - - def execute - @connection.delete(clean_path) + def clean_database(sanity_check = "not_really") + if sanity_check == "yes_i_really_want_to_clean_the_database" + @connection.delete("/cleandb/secret-key") + true + else + false + end end end diff --git a/spec/unit/rest/clean_spec.rb b/spec/unit/rest/clean_spec.rb index 7393e22..f361793 100644 --- a/spec/unit/rest/clean_spec.rb +++ b/spec/unit/rest/clean_spec.rb @@ -4,12 +4,11 @@ module Neography class Rest describe Clean do - let(:connection) { double } - subject { Clean.new(connection) } + subject { Neography::Rest.new } it "cleans the database" do - connection.should_receive(:delete).with("/cleandb/secret-key") - subject.execute + subject.connection.should_receive(:delete).with("/cleandb/secret-key") + subject.clean_database("yes_i_really_want_to_clean_the_database") end end