neography-down 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.project +12 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +939 -0
- data/CONTRIBUTORS +18 -0
- data/Gemfile +4 -0
- data/Guardfile +14 -0
- data/LICENSE +19 -0
- data/README.md +281 -0
- data/Rakefile +14 -0
- data/examples/facebook.rb +40 -0
- data/examples/facebook_v2.rb +25 -0
- data/examples/greatest.rb +43 -0
- data/examples/linkedin.rb +39 -0
- data/examples/linkedin_v2.rb +22 -0
- data/examples/traversal_example1.rb +65 -0
- data/examples/traversal_example2.rb +54 -0
- data/lib/neography.rb +45 -0
- data/lib/neography/config.rb +64 -0
- data/lib/neography/connection.rb +263 -0
- data/lib/neography/equal.rb +21 -0
- data/lib/neography/errors.rb +60 -0
- data/lib/neography/index.rb +52 -0
- data/lib/neography/multi_json_parser.rb +28 -0
- data/lib/neography/neography.rb +10 -0
- data/lib/neography/node.rb +63 -0
- data/lib/neography/node_path.rb +29 -0
- data/lib/neography/node_relationship.rb +37 -0
- data/lib/neography/node_traverser.rb +146 -0
- data/lib/neography/path_traverser.rb +100 -0
- data/lib/neography/property.rb +110 -0
- data/lib/neography/property_container.rb +28 -0
- data/lib/neography/railtie.rb +19 -0
- data/lib/neography/relationship.rb +78 -0
- data/lib/neography/relationship_traverser.rb +80 -0
- data/lib/neography/rest.rb +99 -0
- data/lib/neography/rest/batch.rb +414 -0
- data/lib/neography/rest/clean.rb +17 -0
- data/lib/neography/rest/constraints.rb +38 -0
- data/lib/neography/rest/cypher.rb +29 -0
- data/lib/neography/rest/extensions.rb +21 -0
- data/lib/neography/rest/gremlin.rb +20 -0
- data/lib/neography/rest/helpers.rb +96 -0
- data/lib/neography/rest/node_auto_indexes.rb +60 -0
- data/lib/neography/rest/node_indexes.rb +139 -0
- data/lib/neography/rest/node_labels.rb +49 -0
- data/lib/neography/rest/node_paths.rb +49 -0
- data/lib/neography/rest/node_properties.rb +52 -0
- data/lib/neography/rest/node_relationships.rb +33 -0
- data/lib/neography/rest/node_traversal.rb +25 -0
- data/lib/neography/rest/nodes.rb +94 -0
- data/lib/neography/rest/other_node_relationships.rb +38 -0
- data/lib/neography/rest/relationship_auto_indexes.rb +60 -0
- data/lib/neography/rest/relationship_indexes.rb +142 -0
- data/lib/neography/rest/relationship_properties.rb +52 -0
- data/lib/neography/rest/relationship_types.rb +11 -0
- data/lib/neography/rest/relationships.rb +16 -0
- data/lib/neography/rest/schema_indexes.rb +26 -0
- data/lib/neography/rest/spatial.rb +137 -0
- data/lib/neography/rest/transactions.rb +101 -0
- data/lib/neography/tasks.rb +207 -0
- data/lib/neography/version.rb +3 -0
- data/neography.gemspec +39 -0
- data/spec/integration/authorization_spec.rb +40 -0
- data/spec/integration/broken_spatial_spec.rb +28 -0
- data/spec/integration/index_spec.rb +71 -0
- data/spec/integration/neography_spec.rb +10 -0
- data/spec/integration/node_encoding_spec.rb +71 -0
- data/spec/integration/node_path_spec.rb +222 -0
- data/spec/integration/node_relationship_spec.rb +381 -0
- data/spec/integration/node_spec.rb +260 -0
- data/spec/integration/parsing_spec.rb +13 -0
- data/spec/integration/performance_spec.rb +17 -0
- data/spec/integration/relationship_spec.rb +37 -0
- data/spec/integration/rest_batch_no_streaming_spec.rb +41 -0
- data/spec/integration/rest_batch_spec.rb +604 -0
- data/spec/integration/rest_batch_streaming_spec.rb +51 -0
- data/spec/integration/rest_bulk_spec.rb +106 -0
- data/spec/integration/rest_constraints_spec.rb +72 -0
- data/spec/integration/rest_experimental_spec.rb +22 -0
- data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
- data/spec/integration/rest_header_spec.rb +15 -0
- data/spec/integration/rest_index_spec.rb +481 -0
- data/spec/integration/rest_labels_spec.rb +128 -0
- data/spec/integration/rest_node_spec.rb +274 -0
- data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
- data/spec/integration/rest_path_spec.rb +231 -0
- data/spec/integration/rest_plugin_spec.rb +177 -0
- data/spec/integration/rest_relationship_spec.rb +354 -0
- data/spec/integration/rest_relationship_types_spec.rb +18 -0
- data/spec/integration/rest_schema_index_spec.rb +32 -0
- data/spec/integration/rest_spatial_spec.rb +166 -0
- data/spec/integration/rest_transaction_spec.rb +166 -0
- data/spec/integration/rest_traverse_spec.rb +149 -0
- data/spec/integration/unmanaged_spec.rb +27 -0
- data/spec/matchers.rb +33 -0
- data/spec/neography_spec.rb +23 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/unit/config_spec.rb +135 -0
- data/spec/unit/connection_spec.rb +284 -0
- data/spec/unit/node_spec.rb +100 -0
- data/spec/unit/properties_spec.rb +285 -0
- data/spec/unit/relationship_spec.rb +118 -0
- data/spec/unit/rest/batch_spec.rb +262 -0
- data/spec/unit/rest/clean_spec.rb +16 -0
- data/spec/unit/rest/constraints_spec.rb +45 -0
- data/spec/unit/rest/cypher_spec.rb +20 -0
- data/spec/unit/rest/extensions_spec.rb +28 -0
- data/spec/unit/rest/gremlin_spec.rb +25 -0
- data/spec/unit/rest/helpers_spec.rb +124 -0
- data/spec/unit/rest/labels_spec.rb +77 -0
- data/spec/unit/rest/node_auto_indexes_spec.rb +70 -0
- data/spec/unit/rest/node_indexes_spec.rb +140 -0
- data/spec/unit/rest/node_paths_spec.rb +77 -0
- data/spec/unit/rest/node_properties_spec.rb +79 -0
- data/spec/unit/rest/node_relationships_spec.rb +57 -0
- data/spec/unit/rest/node_traversal_spec.rb +35 -0
- data/spec/unit/rest/nodes_spec.rb +187 -0
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +66 -0
- data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
- data/spec/unit/rest/relationship_properties_spec.rb +79 -0
- data/spec/unit/rest/relationship_types_spec.rb +15 -0
- data/spec/unit/rest/relationships_spec.rb +21 -0
- data/spec/unit/rest/schema_index_spec.rb +30 -0
- data/spec/unit/rest/transactions_spec.rb +43 -0
- metadata +372 -0
data/neography.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "neography/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "neography-down"
|
7
|
+
s.version = Neography::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = "Max De Marzi"
|
10
|
+
s.email = "maxdemarzi@gmail.com"
|
11
|
+
s.homepage = "http://rubygems.org/gems/neography"
|
12
|
+
s.summary = "ruby wrapper to Neo4j Rest API"
|
13
|
+
s.description = "A Ruby wrapper to the Neo4j Rest API see http://docs.neo4j.org/chunked/stable/rest-api.html for more details."
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.rubyforge_project = "neography-down"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_development_dependency "rspec", ">= 2.11"
|
24
|
+
s.add_development_dependency "net-http-spy", "0.2.1"
|
25
|
+
s.add_development_dependency "coveralls"
|
26
|
+
s.add_development_dependency "debugger"
|
27
|
+
s.add_development_dependency "guard-rspec"
|
28
|
+
s.add_dependency "excon", ">= 0.33.0"
|
29
|
+
s.add_dependency "json", ">= 1.7.7"
|
30
|
+
s.add_dependency "os", ">= 0.9.6"
|
31
|
+
s.add_dependency "multi_json", ">= 1.3.2"
|
32
|
+
|
33
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
34
|
+
s.add_runtime_dependency 'rake', '>= 0.8.7'
|
35
|
+
else
|
36
|
+
s.add_development_dependency "rake", ">= 0.8.7"
|
37
|
+
s.add_dependency "rake", ">= 0.8.7"
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neography::Rest, :slow => true do
|
4
|
+
describe "basic authentication" do
|
5
|
+
describe "get_root", :reference => true do
|
6
|
+
it "can get the root node"do
|
7
|
+
@neo = Neography::Rest.new({:authentication => 'digest', :username => "username", :password => "password"})
|
8
|
+
root_node = @neo.get_root
|
9
|
+
expect(root_node).to have_key("reference_node")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "create_node" do
|
14
|
+
it "can create an empty node" do
|
15
|
+
@neo = Neography::Rest.new({:authentication => 'basic', :username => "username", :password => "password"})
|
16
|
+
new_node = @neo.create_node
|
17
|
+
expect(new_node).not_to be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "quick initializer" do
|
22
|
+
it "can create an empty node" do
|
23
|
+
@neo = Neography::Rest.new("http://username:password@localhost:7474")
|
24
|
+
new_node = @neo.create_node
|
25
|
+
expect(new_node).not_to be_nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "digest authentication" do
|
31
|
+
describe "create_node" do
|
32
|
+
it "can create an empty node" do
|
33
|
+
@neo = Neography::Rest.new({:authentication => 'digest', :username => "username", :password => "password"})
|
34
|
+
new_node = @neo.create_node
|
35
|
+
expect(new_node).not_to be_nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neography::Rest do
|
4
|
+
before(:each) do
|
5
|
+
@neo = Neography::Rest.new(:log_enabled => true)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "can spatial plugin" do
|
9
|
+
it "can do spatial in batch", :neo_is_broken => true do
|
10
|
+
properties = {:lat => 60.1, :lon => 15.2}
|
11
|
+
node = @neo.create_node(properties)
|
12
|
+
batch_result = @neo.batch [:add_point_layer, "restaurantsbatch"],
|
13
|
+
[:add_node_to_layer, "restaurantsbatch", node],
|
14
|
+
[:get_layer, "restaurantsbatch"],
|
15
|
+
[:find_geometries_within_distance, "restaurantsbatch", 60.0,15.0, 100.0],
|
16
|
+
[:find_geometries_in_bbox, "restaurantsbatch", 60.0, 60.2, 15.0, 15.3]
|
17
|
+
# getting "The transaction is marked for rollback only." errors
|
18
|
+
# possibly related to a Cypher Transaction Bug.
|
19
|
+
puts batch_result.inspect
|
20
|
+
expect(batch_result[0].first["data"]["layer"]).to eq("restaurantsbatch")
|
21
|
+
expect(batch_result[1].first["data"]["lat"]).to eq(properties[:lat])
|
22
|
+
expect(batch_result[1].first["data"]["lon"]).to eq(properties[:lon])
|
23
|
+
expect(batch_result[2].first["data"]["layer"]).to eq("restaurantsbatch")
|
24
|
+
expect(batch_result[3].first["data"]).not_to be_empty
|
25
|
+
expect(batch_result[4].first["data"]).not_to be_empty
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neography::Index do
|
4
|
+
|
5
|
+
it "can add a node to an index" do
|
6
|
+
new_node = Neography::Node.create
|
7
|
+
key = generate_text(6)
|
8
|
+
value = generate_text
|
9
|
+
new_node.add_to_index("node_test_index", key, value)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "can add a node to an index uniquely" do
|
13
|
+
new_node = Neography::Node.create
|
14
|
+
key = generate_text(6)
|
15
|
+
value = generate_text
|
16
|
+
new_node.add_to_index("node_test_index", key, value, true)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "can add a relationship to an index" do
|
20
|
+
node1 = Neography::Node.create
|
21
|
+
node2 = Neography::Node.create
|
22
|
+
r = Neography::Relationship.create(:friends, node1, node2)
|
23
|
+
key = generate_text(6)
|
24
|
+
value = generate_text
|
25
|
+
r.add_to_index("relationship_test_index", key, value)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "can find a node in an index" do
|
29
|
+
value = generate_text
|
30
|
+
new_node = Neography::Node.create("name" => value)
|
31
|
+
new_node.add_to_index("node_test_index", "name", value)
|
32
|
+
existing_node = Neography::Node.find("node_test_index", "name", value)
|
33
|
+
expect(existing_node.name).to eq(value)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "can find a node in an index with brackets" do
|
37
|
+
key = generate_text(6)
|
38
|
+
value = "Sen. Roy Blunt [R-MO]"
|
39
|
+
new_node = Neography::Node.create("name" => value)
|
40
|
+
new_node.add_to_index(key, "name", value)
|
41
|
+
existing_node = Neography::Node.find(key, "name", value)
|
42
|
+
expect(existing_node.name).to eq(value)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can find a relationship in an index" do
|
46
|
+
value = generate_text
|
47
|
+
node1 = Neography::Node.create
|
48
|
+
node2 = Neography::Node.create
|
49
|
+
r = Neography::Relationship.create(:friends, node1, node2, {"name" => value})
|
50
|
+
r.add_to_index("relationship_test_index", "name", value)
|
51
|
+
existing_r = Neography::Relationship.find("relationship_test_index", "name", value)
|
52
|
+
expect(existing_r.name).to eq(value)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "can find multiple nodes in an index" do
|
56
|
+
value1 = generate_text
|
57
|
+
value2 = generate_text
|
58
|
+
value3 = generate_text
|
59
|
+
node1 = Neography::Node.create("first_name" => value1, "last_name" => value2)
|
60
|
+
node1.add_to_index("node_test_index", "first_name", value1)
|
61
|
+
node2 = Neography::Node.create("first_name" => value1, "last_name" => value3)
|
62
|
+
node2.add_to_index("node_test_index", "first_name", value1)
|
63
|
+
|
64
|
+
existing_nodes = Neography::Node.find("node_test_index", "first_name", value1)
|
65
|
+
expect(existing_nodes.size).to eq(2)
|
66
|
+
expect(existing_nodes.first.last_name).to eq(value2)
|
67
|
+
expect(existing_nodes.last.last_name).to eq(value3)
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Neography::Node do
|
5
|
+
|
6
|
+
describe "create and new" do
|
7
|
+
|
8
|
+
it "can create a node with UTF-8 encoded properties" do
|
9
|
+
new_node = Neography::Node.create("name" => "美都池水")
|
10
|
+
expect(new_node.name).to eq("美都池水")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "can create a node with more than one UTF-8 encoded properties" do
|
14
|
+
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
|
15
|
+
expect(new_node.first_name).to eq("美都")
|
16
|
+
expect(new_node.last_name).to eq("池水")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "load" do
|
22
|
+
it "can get a node with UTF-8 encoded properties that exists" do
|
23
|
+
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
|
24
|
+
existing_node = Neography::Node.load(new_node)
|
25
|
+
expect(existing_node).not_to be_nil
|
26
|
+
expect(existing_node.neo_id).not_to be_nil
|
27
|
+
expect(existing_node.neo_id).to eq(new_node.neo_id)
|
28
|
+
expect(existing_node.first_name).to eq("美都")
|
29
|
+
expect(existing_node.last_name).to eq("池水")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "can get a node with UTF-8 encoded properties from an index" do
|
33
|
+
@neo = Neography::Rest.new
|
34
|
+
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
|
35
|
+
key = generate_text(6)
|
36
|
+
value = generate_text
|
37
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
38
|
+
node_from_index = @neo.get_node_index("test_node_index", key, value)
|
39
|
+
existing_node = Neography::Node.load(node_from_index)
|
40
|
+
expect(existing_node).not_to be_nil
|
41
|
+
expect(existing_node.neo_id).not_to be_nil
|
42
|
+
expect(existing_node.neo_id).to eq(new_node.neo_id)
|
43
|
+
expect(existing_node.first_name).to eq("美都")
|
44
|
+
expect(existing_node.last_name).to eq("池水")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "can get a node with UTF-8 encoded properties that exists via cypher" do
|
48
|
+
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
|
49
|
+
cypher = "START n = node({id}) return n"
|
50
|
+
@neo = Neography::Rest.new
|
51
|
+
results = @neo.execute_query(cypher, {:id => new_node.neo_id.to_i})
|
52
|
+
existing_node = Neography::Node.load(results)
|
53
|
+
expect(existing_node).not_to be_nil
|
54
|
+
expect(existing_node.neo_id).not_to be_nil
|
55
|
+
expect(existing_node.neo_id).to eq(new_node.neo_id)
|
56
|
+
expect(existing_node.first_name).to eq("美都")
|
57
|
+
expect(existing_node.last_name).to eq("池水")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "can get columns of data from a node with UTF-8 encoded properties that exists via cypher" do
|
61
|
+
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
|
62
|
+
cypher = "START me = node({id})
|
63
|
+
RETURN me.first_name, me.last_name"
|
64
|
+
@neo = Neography::Rest.new
|
65
|
+
results = @neo.execute_query(cypher, {:id => new_node.neo_id.to_i})
|
66
|
+
expect(results['data'][0]).to eq(["美都","池水"])
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neography::NodePath do
|
4
|
+
|
5
|
+
def create_nodes
|
6
|
+
johnathan = Neography::Node.create("name" =>'Johnathan')
|
7
|
+
mark = Neography::Node.create("name" =>'Mark')
|
8
|
+
phill = Neography::Node.create("name" =>'Phill')
|
9
|
+
mary = Neography::Node.create("name" =>'Mary')
|
10
|
+
|
11
|
+
johnathan.both(:friends) << mark
|
12
|
+
mark.both(:friends) << mary
|
13
|
+
mark.both(:friends) << phill
|
14
|
+
phill.both(:friends) << mary
|
15
|
+
|
16
|
+
[johnathan, mark, phill, mary]
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "all_paths" do
|
20
|
+
it "can return nodes" do
|
21
|
+
johnathan, mark, phill, mary = create_nodes
|
22
|
+
|
23
|
+
johnathan.all_paths_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
24
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be true}
|
25
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be false}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can return relationships" do
|
30
|
+
johnathan, mark, phill, mary = create_nodes
|
31
|
+
|
32
|
+
johnathan.all_paths_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
33
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be false}
|
34
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be true}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can return both" do
|
39
|
+
johnathan, mark, phill, mary = create_nodes
|
40
|
+
|
41
|
+
johnathan.all_paths_to(mary).incoming(:friends).depth(4).each do |path|
|
42
|
+
path.each_with_index do |n,i|
|
43
|
+
if i.even?
|
44
|
+
expect(n.is_a?(Neography::Node)).to be true
|
45
|
+
else
|
46
|
+
expect(n.is_a?(Neography::Relationship)).to be true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "all_simple_paths" do
|
54
|
+
it "can return nodes" do
|
55
|
+
johnathan, mark, phill, mary = create_nodes
|
56
|
+
|
57
|
+
johnathan.all_simple_paths_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
58
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be true}
|
59
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be false}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "can return relationships" do
|
64
|
+
johnathan, mark, phill, mary = create_nodes
|
65
|
+
|
66
|
+
johnathan.all_simple_paths_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
67
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be false}
|
68
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be true}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "can return both" do
|
73
|
+
johnathan, mark, phill, mary = create_nodes
|
74
|
+
|
75
|
+
johnathan.all_simple_paths_to(mary).incoming(:friends).depth(4).each do |path|
|
76
|
+
path.each_with_index do |n,i|
|
77
|
+
if i.even?
|
78
|
+
expect(n.is_a?(Neography::Node)).to be true
|
79
|
+
else
|
80
|
+
expect(n.is_a?(Neography::Relationship)).to be true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "all_shortest_paths_to" do
|
88
|
+
it "can return nodes" do
|
89
|
+
johnathan, mark, phill, mary = create_nodes
|
90
|
+
|
91
|
+
johnathan.all_shortest_paths_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
92
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be true}
|
93
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be false}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it "can return relationships" do
|
98
|
+
johnathan, mark, phill, mary = create_nodes
|
99
|
+
|
100
|
+
johnathan.all_shortest_paths_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
101
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be false}
|
102
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be true}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "can return both" do
|
107
|
+
johnathan, mark, phill, mary = create_nodes
|
108
|
+
|
109
|
+
johnathan.all_shortest_paths_to(mary).incoming(:friends).depth(4).each do |path|
|
110
|
+
path.each_with_index do |n,i|
|
111
|
+
if i.even?
|
112
|
+
expect(n.is_a?(Neography::Node)).to be true
|
113
|
+
else
|
114
|
+
expect(n.is_a?(Neography::Relationship)).to be true
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "path_to" do
|
122
|
+
it "can return nodes" do
|
123
|
+
johnathan, mark, phill, mary = create_nodes
|
124
|
+
|
125
|
+
johnathan.path_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
126
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be true}
|
127
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be false}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it "can return relationships" do
|
132
|
+
johnathan, mark, phill, mary = create_nodes
|
133
|
+
|
134
|
+
johnathan.path_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
135
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be false}
|
136
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be true}
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it "can return both" do
|
141
|
+
johnathan, mark, phill, mary = create_nodes
|
142
|
+
|
143
|
+
johnathan.path_to(mary).incoming(:friends).depth(4).each do |path|
|
144
|
+
path.each_with_index do |n,i|
|
145
|
+
if i.even?
|
146
|
+
expect(n.is_a?(Neography::Node)).to be true
|
147
|
+
else
|
148
|
+
expect(n.is_a?(Neography::Relationship)).to be true
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "simple_path_to" do
|
156
|
+
it "can return nodes" do
|
157
|
+
johnathan, mark, phill, mary = create_nodes
|
158
|
+
|
159
|
+
johnathan.simple_path_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
160
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be true}
|
161
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be false}
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
it "can return relationships" do
|
166
|
+
johnathan, mark, phill, mary = create_nodes
|
167
|
+
|
168
|
+
johnathan.simple_path_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
169
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be false}
|
170
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be true}
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
it "can return both" do
|
175
|
+
johnathan, mark, phill, mary = create_nodes
|
176
|
+
|
177
|
+
johnathan.simple_path_to(mary).incoming(:friends).depth(4).each do |path|
|
178
|
+
path.each_with_index do |n,i|
|
179
|
+
if i.even?
|
180
|
+
expect(n.is_a?(Neography::Node)).to be true
|
181
|
+
else
|
182
|
+
expect(n.is_a?(Neography::Relationship)).to be true
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "shortest_path_to" do
|
190
|
+
it "can return nodes" do
|
191
|
+
johnathan, mark, phill, mary = create_nodes
|
192
|
+
|
193
|
+
johnathan.shortest_path_to(mary).incoming(:friends).depth(4).nodes.each do |path|
|
194
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be true}
|
195
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be false}
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
it "can return relationships" do
|
200
|
+
johnathan, mark, phill, mary = create_nodes
|
201
|
+
|
202
|
+
johnathan.shortest_path_to(mary).incoming(:friends).depth(4).rels.each do |path|
|
203
|
+
path.map{|n| expect(n.is_a?(Neography::Node)).to be false}
|
204
|
+
path.map{|n| expect(n.is_a?(Neography::Relationship)).to be true}
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
it "can return both" do
|
209
|
+
johnathan, mark, phill, mary = create_nodes
|
210
|
+
|
211
|
+
johnathan.shortest_path_to(mary).incoming(:friends).depth(4).each do |path|
|
212
|
+
path.each_with_index do |n,i|
|
213
|
+
if i.even?
|
214
|
+
expect(n.is_a?(Neography::Node)).to be true
|
215
|
+
else
|
216
|
+
expect(n.is_a?(Neography::Relationship)).to be true
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|