From 0eff2277bfc2fd9bc1f12bcf2652f836be78f7ee Mon Sep 17 00:00:00 2001 From: maxdemarzi Date: Sun, 14 Nov 2010 23:10:37 -0800 Subject: [PATCH] adding fakeweb and starting to create fake http responses --- Gemfile.lock | 2 ++ neography.gemspec | 1 + .../{neography_spec.rb => integration/node_spec.rb} | 13 ++----------- spec/integration/root_spec.rb | 7 +++++++ spec/spec_helper.rb | 13 +++++++++++++ spec/support/fake_root_spec.rb | 5 +++++ 6 files changed, 30 insertions(+), 11 deletions(-) rename spec/{neography_spec.rb => integration/node_spec.rb} (94%) create mode 100644 spec/integration/root_spec.rb create mode 100644 spec/spec_helper.rb create mode 100644 spec/support/fake_root_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index bbe3d3f..ecb86b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,6 +10,7 @@ GEM specs: crack (0.1.8) diff-lcs (1.1.2) + fakeweb (1.3.0) httparty (0.6.1) crack (= 0.1.8) json (1.4.6-java) @@ -29,6 +30,7 @@ PLATFORMS java DEPENDENCIES + fakeweb (~> 1.3.0) httparty (~> 0.6.1) json neography! diff --git a/neography.gemspec b/neography.gemspec index ec90fbf..6b39abb 100644 --- a/neography.gemspec +++ b/neography.gemspec @@ -21,6 +21,7 @@ Gem::Specification.new do |s| s.add_development_dependency "rspec", "~> 2.0.0.beta.22" s.add_development_dependency "net-http-spy", "~> 0.2.1" + s.add_development_dependency "fakeweb", "~> 1.3.0" s.add_dependency "httparty", "~> 0.6.1" s.add_dependency "json" end diff --git a/spec/neography_spec.rb b/spec/integration/node_spec.rb similarity index 94% rename from spec/neography_spec.rb rename to spec/integration/node_spec.rb index 4bb1091..c232acb 100644 --- a/spec/neography_spec.rb +++ b/spec/integration/node_spec.rb @@ -1,10 +1,4 @@ -require 'neography' - -describe Neography::Neo do - it "has a root node" do - Neography::Neo.root_node.should include("reference_node") - end -end +require File.join(File.dirname(__FILE__), '..', 'spec_helper') describe Neography::Node do it "can create an empty node" do @@ -83,7 +77,4 @@ Neography::Node.del(node2[:neo_id]).should be_nil end - - - -end \ No newline at end of file +end diff --git a/spec/integration/root_spec.rb b/spec/integration/root_spec.rb new file mode 100644 index 0000000..347c88d --- /dev/null +++ b/spec/integration/root_spec.rb @@ -0,0 +1,7 @@ +require File.join(File.dirname(__FILE__), '..', 'spec_helper') + +describe Neography::Neo do + it "has a root node" do + Neography::Neo.root_node.should include("reference_node") + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..2539c70 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,13 @@ +require 'neography' +require 'fakeweb' + +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} + +FakeWeb.allow_net_connect = false + +#To test against a real database: +#1. Make sure empty database is running (./bin/neo4j-rest start) +#2. Uncomment the next two lines +#FakeWeb.clean_registry +#FakeWeb.allow_net_connect = true + diff --git a/spec/support/fake_root_spec.rb b/spec/support/fake_root_spec.rb new file mode 100644 index 0000000..0ce81da --- /dev/null +++ b/spec/support/fake_root_spec.rb @@ -0,0 +1,5 @@ +FakeWeb.register_uri(:get, "http://localhost:9999/", :body => '{ + "index" : "http://localhost:9999/index", + "node" : "http://localhost:9999/node", + "reference_node" : "http://localhost:9999/node/0" +}') \ No newline at end of file