/
cypher_spec.rb
54 lines (47 loc) · 2.07 KB
/
cypher_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'spec_helper'
describe Morpheus::API::Cypher do
let(:uri) { "http://localhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query" }
let(:body) do
<<-JSON
{
"data" : [ [ {
"outgoing_relationships" : "http://localhost:7474/db/data/node/1234/relationships/out",
"data" : {
"name" : "Mr 4-1"
},
"traverse" : "http://localhost:7474/db/data/node/1234/traverse/{returnType}",
"all_typed_relationships" : "http://localhost:7474/db/data/node/1234/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/1234/properties/{key}",
"self" : "http://localhost:7474/db/data/node/1234",
"properties" : "http://localhost:7474/db/data/node/1234/properties",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/1234/relationships/out/{-list|&|types}",
"incoming_relationships" : "http://localhost:7474/db/data/node/1234/relationships/in",
"extensions" : {
},
"create_relationship" : "http://localhost:7474/db/data/node/1234/relationships",
"paged_traverse" : "http://localhost:7474/db/data/node/1234/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships" : "http://localhost:7474/db/data/node/1234/relationships/all",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/1234/relationships/in/{-list|&|types}"
} ] ],
"columns" : [ "s" ]
}
JSON
end
subject { Morpheus::API::Cypher.new }
before { subject.stub(:query_url).and_return uri }
describe "results" do
before { FakeWeb.register_uri(:post, uri, :body => body) }
let(:user_class) do
Class.new(Morpheus::Node) do
end
end
it "should return nodes" do
results = subject.execute(user_class, "start s=node(1234) return s")
results.first.should be_a user_class
results.first.name.should == "Mr 4-1"
end
it "should raise if no resulting cass provided" do
lambda{ subject.execute(nil, "start s=node(1234) return s") }.should raise_error
end
end
end