neography-down 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.project +12 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +4 -0
  6. data/CHANGELOG.md +939 -0
  7. data/CONTRIBUTORS +18 -0
  8. data/Gemfile +4 -0
  9. data/Guardfile +14 -0
  10. data/LICENSE +19 -0
  11. data/README.md +281 -0
  12. data/Rakefile +14 -0
  13. data/examples/facebook.rb +40 -0
  14. data/examples/facebook_v2.rb +25 -0
  15. data/examples/greatest.rb +43 -0
  16. data/examples/linkedin.rb +39 -0
  17. data/examples/linkedin_v2.rb +22 -0
  18. data/examples/traversal_example1.rb +65 -0
  19. data/examples/traversal_example2.rb +54 -0
  20. data/lib/neography.rb +45 -0
  21. data/lib/neography/config.rb +64 -0
  22. data/lib/neography/connection.rb +263 -0
  23. data/lib/neography/equal.rb +21 -0
  24. data/lib/neography/errors.rb +60 -0
  25. data/lib/neography/index.rb +52 -0
  26. data/lib/neography/multi_json_parser.rb +28 -0
  27. data/lib/neography/neography.rb +10 -0
  28. data/lib/neography/node.rb +63 -0
  29. data/lib/neography/node_path.rb +29 -0
  30. data/lib/neography/node_relationship.rb +37 -0
  31. data/lib/neography/node_traverser.rb +146 -0
  32. data/lib/neography/path_traverser.rb +100 -0
  33. data/lib/neography/property.rb +110 -0
  34. data/lib/neography/property_container.rb +28 -0
  35. data/lib/neography/railtie.rb +19 -0
  36. data/lib/neography/relationship.rb +78 -0
  37. data/lib/neography/relationship_traverser.rb +80 -0
  38. data/lib/neography/rest.rb +99 -0
  39. data/lib/neography/rest/batch.rb +414 -0
  40. data/lib/neography/rest/clean.rb +17 -0
  41. data/lib/neography/rest/constraints.rb +38 -0
  42. data/lib/neography/rest/cypher.rb +29 -0
  43. data/lib/neography/rest/extensions.rb +21 -0
  44. data/lib/neography/rest/gremlin.rb +20 -0
  45. data/lib/neography/rest/helpers.rb +96 -0
  46. data/lib/neography/rest/node_auto_indexes.rb +60 -0
  47. data/lib/neography/rest/node_indexes.rb +139 -0
  48. data/lib/neography/rest/node_labels.rb +49 -0
  49. data/lib/neography/rest/node_paths.rb +49 -0
  50. data/lib/neography/rest/node_properties.rb +52 -0
  51. data/lib/neography/rest/node_relationships.rb +33 -0
  52. data/lib/neography/rest/node_traversal.rb +25 -0
  53. data/lib/neography/rest/nodes.rb +94 -0
  54. data/lib/neography/rest/other_node_relationships.rb +38 -0
  55. data/lib/neography/rest/relationship_auto_indexes.rb +60 -0
  56. data/lib/neography/rest/relationship_indexes.rb +142 -0
  57. data/lib/neography/rest/relationship_properties.rb +52 -0
  58. data/lib/neography/rest/relationship_types.rb +11 -0
  59. data/lib/neography/rest/relationships.rb +16 -0
  60. data/lib/neography/rest/schema_indexes.rb +26 -0
  61. data/lib/neography/rest/spatial.rb +137 -0
  62. data/lib/neography/rest/transactions.rb +101 -0
  63. data/lib/neography/tasks.rb +207 -0
  64. data/lib/neography/version.rb +3 -0
  65. data/neography.gemspec +39 -0
  66. data/spec/integration/authorization_spec.rb +40 -0
  67. data/spec/integration/broken_spatial_spec.rb +28 -0
  68. data/spec/integration/index_spec.rb +71 -0
  69. data/spec/integration/neography_spec.rb +10 -0
  70. data/spec/integration/node_encoding_spec.rb +71 -0
  71. data/spec/integration/node_path_spec.rb +222 -0
  72. data/spec/integration/node_relationship_spec.rb +381 -0
  73. data/spec/integration/node_spec.rb +260 -0
  74. data/spec/integration/parsing_spec.rb +13 -0
  75. data/spec/integration/performance_spec.rb +17 -0
  76. data/spec/integration/relationship_spec.rb +37 -0
  77. data/spec/integration/rest_batch_no_streaming_spec.rb +41 -0
  78. data/spec/integration/rest_batch_spec.rb +604 -0
  79. data/spec/integration/rest_batch_streaming_spec.rb +51 -0
  80. data/spec/integration/rest_bulk_spec.rb +106 -0
  81. data/spec/integration/rest_constraints_spec.rb +72 -0
  82. data/spec/integration/rest_experimental_spec.rb +22 -0
  83. data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
  84. data/spec/integration/rest_header_spec.rb +15 -0
  85. data/spec/integration/rest_index_spec.rb +481 -0
  86. data/spec/integration/rest_labels_spec.rb +128 -0
  87. data/spec/integration/rest_node_spec.rb +274 -0
  88. data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
  89. data/spec/integration/rest_path_spec.rb +231 -0
  90. data/spec/integration/rest_plugin_spec.rb +177 -0
  91. data/spec/integration/rest_relationship_spec.rb +354 -0
  92. data/spec/integration/rest_relationship_types_spec.rb +18 -0
  93. data/spec/integration/rest_schema_index_spec.rb +32 -0
  94. data/spec/integration/rest_spatial_spec.rb +166 -0
  95. data/spec/integration/rest_transaction_spec.rb +166 -0
  96. data/spec/integration/rest_traverse_spec.rb +149 -0
  97. data/spec/integration/unmanaged_spec.rb +27 -0
  98. data/spec/matchers.rb +33 -0
  99. data/spec/neography_spec.rb +23 -0
  100. data/spec/spec_helper.rb +44 -0
  101. data/spec/unit/config_spec.rb +135 -0
  102. data/spec/unit/connection_spec.rb +284 -0
  103. data/spec/unit/node_spec.rb +100 -0
  104. data/spec/unit/properties_spec.rb +285 -0
  105. data/spec/unit/relationship_spec.rb +118 -0
  106. data/spec/unit/rest/batch_spec.rb +262 -0
  107. data/spec/unit/rest/clean_spec.rb +16 -0
  108. data/spec/unit/rest/constraints_spec.rb +45 -0
  109. data/spec/unit/rest/cypher_spec.rb +20 -0
  110. data/spec/unit/rest/extensions_spec.rb +28 -0
  111. data/spec/unit/rest/gremlin_spec.rb +25 -0
  112. data/spec/unit/rest/helpers_spec.rb +124 -0
  113. data/spec/unit/rest/labels_spec.rb +77 -0
  114. data/spec/unit/rest/node_auto_indexes_spec.rb +70 -0
  115. data/spec/unit/rest/node_indexes_spec.rb +140 -0
  116. data/spec/unit/rest/node_paths_spec.rb +77 -0
  117. data/spec/unit/rest/node_properties_spec.rb +79 -0
  118. data/spec/unit/rest/node_relationships_spec.rb +57 -0
  119. data/spec/unit/rest/node_traversal_spec.rb +35 -0
  120. data/spec/unit/rest/nodes_spec.rb +187 -0
  121. data/spec/unit/rest/relationship_auto_indexes_spec.rb +66 -0
  122. data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
  123. data/spec/unit/rest/relationship_properties_spec.rb +79 -0
  124. data/spec/unit/rest/relationship_types_spec.rb +15 -0
  125. data/spec/unit/rest/relationships_spec.rb +21 -0
  126. data/spec/unit/rest/schema_index_spec.rb +30 -0
  127. data/spec/unit/rest/transactions_spec.rb +43 -0
  128. metadata +372 -0
@@ -0,0 +1,3 @@
1
+ module Neography
2
+ VERSION = "1.6.4"
3
+ end
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,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Neography do
4
+ describe "ref_node", :reference => true do
5
+ it "can get the reference node" do
6
+ root_node = Neography.ref_node
7
+ expect(root_node).to have_key("self")
8
+ end
9
+ end
10
+ 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