|
76 | 76 | end |
77 | 77 | end |
78 | 78 |
|
79 | | - describe 'returning a hash from cypher' do |
80 | | - before { Neo4j::Node.create({name: 'Foo'}, :person) } |
| 79 | + describe 'complex structures' do |
| 80 | + let!(:node) { Neo4j::Node.create({name: 'Foo'}, :Person) } |
| 81 | + |
| 82 | + describe 'returning a collection' do |
| 83 | + it 'does not raise an error' do |
| 84 | + begin |
| 85 | + tx = Neo4j::Transaction.new |
| 86 | + expect { Neo4j::Session.current.query.match(p: :Person).pluck('collect(p)') }.not_to raise_error |
| 87 | + ensure |
| 88 | + tx.close |
| 89 | + end |
| 90 | + end |
81 | 91 |
|
82 | | - it 'is not mistaken for a malformed object' do |
83 | | - begin |
84 | | - tx = Neo4j::Transaction.new |
85 | | - Neo4j::Session.current.query.match(person: 'person').pluck('person limit 1') |
86 | | - response = Neo4j::Session.current.query.match(person: 'person').where(person: {name: 'Foo'}) |
87 | | - .pluck('person, { name: person.name, labels: LABELS(person)[0]} as ph').first |
88 | | - expect(response[1]).to be_a(Hash) |
89 | | - # Behavior differs slightly in JRuby/Embedded. |
90 | | - key = response[1].key?('name') ? 'name' : :name |
91 | | - expect(response[1][key]).to eq 'Foo' |
92 | | - ensure |
93 | | - tx.close if Neo4j::Transaction.current |
| 92 | + it 'returns a node within an array' do |
| 93 | + begin |
| 94 | + tx = Neo4j::Transaction.new |
| 95 | + result = Neo4j::Session.current.query.match(p: :Person).pluck('collect(p)').first |
| 96 | + expect(result).to be_a(Array) |
| 97 | + expect(result.first).to respond_to(:neo_id) |
| 98 | + expect(result.first.labels).to include(:Person) |
| 99 | + ensure |
| 100 | + tx.close |
| 101 | + end |
| 102 | + end |
| 103 | + end |
| 104 | + |
| 105 | + describe 'returning a hash from cypher' do |
| 106 | + it 'is not mistaken for a malformed object' do |
| 107 | + begin |
| 108 | + tx = Neo4j::Transaction.new |
| 109 | + Neo4j::Session.current.query.match(person: 'Person').pluck('person limit 1') |
| 110 | + response = Neo4j::Session.current.query.match(person: 'Person').where(person: {name: 'Foo'}) |
| 111 | + .pluck('person, { name: person.name, labels: LABELS(person)[0]} as ph').first |
| 112 | + expect(response[1]).to be_a(Hash) |
| 113 | + # Behavior differs slightly in JRuby/Embedded. |
| 114 | + key = response[1].key?('name') ? 'name' : :name |
| 115 | + expect(response[1][key]).to eq 'Foo' |
| 116 | + ensure |
| 117 | + tx.close if Neo4j::Transaction.current |
| 118 | + end |
94 | 119 | end |
95 | 120 | end |
96 | 121 | end |
|
0 commit comments