pacer 0.9.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +8 -0
- data/.document +5 -0
- data/.gitignore +26 -0
- data/.rspec +1 -0
- data/.rvmrc +0 -0
- data/CONTRIBUTORS +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +24 -0
- data/README.md +187 -0
- data/Rakefile +49 -0
- data/autotest/discover.rb +1 -0
- data/bin/autospec +16 -0
- data/bin/autotest +16 -0
- data/bin/rake +16 -0
- data/bin/rcov +16 -0
- data/bin/rspec +16 -0
- data/bin/yard +16 -0
- data/bin/yardoc +16 -0
- data/lib/pacer/blueprints/extensions.rb +77 -0
- data/lib/pacer/blueprints/multi_graph.rb +121 -0
- data/lib/pacer/blueprints/ruby_graph.rb +199 -0
- data/lib/pacer/blueprints/tg.rb +100 -0
- data/lib/pacer/blueprints.rb +4 -0
- data/lib/pacer/core/graph/edges_route.rb +92 -0
- data/lib/pacer/core/graph/element_route.rb +171 -0
- data/lib/pacer/core/graph/graph_index_route.rb +48 -0
- data/lib/pacer/core/graph/graph_route.rb +55 -0
- data/lib/pacer/core/graph/mixed_route.rb +96 -0
- data/lib/pacer/core/graph/vertices_route.rb +220 -0
- data/lib/pacer/core/graph.rb +13 -0
- data/lib/pacer/core/route.rb +502 -0
- data/lib/pacer/core/side_effect.rb +11 -0
- data/lib/pacer/core.rb +8 -0
- data/lib/pacer/exceptions.rb +11 -0
- data/lib/pacer/extensions/block_filter_element.rb +22 -0
- data/lib/pacer/extensions.rb +6 -0
- data/lib/pacer/filter/block_filter.rb +31 -0
- data/lib/pacer/filter/collection_filter.rb +109 -0
- data/lib/pacer/filter/empty_filter.rb +70 -0
- data/lib/pacer/filter/future_filter.rb +68 -0
- data/lib/pacer/filter/index_filter.rb +30 -0
- data/lib/pacer/filter/loop_filter.rb +95 -0
- data/lib/pacer/filter/object_filter.rb +55 -0
- data/lib/pacer/filter/property_filter/edge_filters.rb +93 -0
- data/lib/pacer/filter/property_filter/filters.rb +269 -0
- data/lib/pacer/filter/property_filter.rb +111 -0
- data/lib/pacer/filter/random_filter.rb +13 -0
- data/lib/pacer/filter/range_filter.rb +104 -0
- data/lib/pacer/filter/uniq_filter.rb +12 -0
- data/lib/pacer/filter/where_filter/node_visitor.rb +280 -0
- data/lib/pacer/filter/where_filter.rb +47 -0
- data/lib/pacer/filter.rb +17 -0
- data/lib/pacer/function_resolver.rb +43 -0
- data/lib/pacer/graph/edge_mixin.rb +127 -0
- data/lib/pacer/graph/element_mixin.rb +202 -0
- data/lib/pacer/graph/graph_indices_mixin.rb +93 -0
- data/lib/pacer/graph/graph_mixin.rb +361 -0
- data/lib/pacer/graph/graph_transactions_mixin.rb +207 -0
- data/lib/pacer/graph/index_mixin.rb +30 -0
- data/lib/pacer/graph/vertex_mixin.rb +119 -0
- data/lib/pacer/graph.rb +14 -0
- data/lib/pacer/pipe/blackbox_pipeline.rb +48 -0
- data/lib/pacer/pipe/block_filter_pipe.rb +38 -0
- data/lib/pacer/pipe/collection_filter_pipe.rb +10 -0
- data/lib/pacer/pipe/cross_product_transform_pipe.rb +48 -0
- data/lib/pacer/pipe/enumerable_pipe.rb +30 -0
- data/lib/pacer/pipe/expandable_pipe.rb +63 -0
- data/lib/pacer/pipe/id_collection_filter_pipe.rb +33 -0
- data/lib/pacer/pipe/is_empty_pipe.rb +30 -0
- data/lib/pacer/pipe/is_unique_pipe.rb +61 -0
- data/lib/pacer/pipe/label_collection_filter_pipe.rb +21 -0
- data/lib/pacer/pipe/label_prefix_pipe.rb +21 -0
- data/lib/pacer/pipe/loop_pipe.rb +86 -0
- data/lib/pacer/pipe/map_pipe.rb +36 -0
- data/lib/pacer/pipe/never_pipe.rb +9 -0
- data/lib/pacer/pipe/process_pipe.rb +37 -0
- data/lib/pacer/pipe/property_comparison_pipe.rb +40 -0
- data/lib/pacer/pipe/ruby_pipe.rb +25 -0
- data/lib/pacer/pipe/simple_visitor_pipe.rb +43 -0
- data/lib/pacer/pipe/stream_sort_pipe.rb +84 -0
- data/lib/pacer/pipe/stream_uniq_pipe.rb +33 -0
- data/lib/pacer/pipe/type_filter_pipe.rb +22 -0
- data/lib/pacer/pipe/unary_transform_pipe.rb +59 -0
- data/lib/pacer/pipe/variable_store_iterator_wrapper.rb +26 -0
- data/lib/pacer/pipe/visitor_pipe.rb +67 -0
- data/lib/pacer/pipes.rb +61 -0
- data/lib/pacer/route/mixin/bulk_operations.rb +52 -0
- data/lib/pacer/route/mixin/route_operations.rb +107 -0
- data/lib/pacer/route/mixin/variable_route_module.rb +26 -0
- data/lib/pacer/route/mixins.rb +3 -0
- data/lib/pacer/route.rb +228 -0
- data/lib/pacer/routes.rb +6 -0
- data/lib/pacer/side_effect/aggregate.rb +31 -0
- data/lib/pacer/side_effect/counted.rb +30 -0
- data/lib/pacer/side_effect/group_count.rb +44 -0
- data/lib/pacer/side_effect/is_unique.rb +32 -0
- data/lib/pacer/side_effect/section.rb +25 -0
- data/lib/pacer/side_effect/visitor.rb +37 -0
- data/lib/pacer/side_effect.rb +11 -0
- data/lib/pacer/support/array_list.rb +28 -0
- data/lib/pacer/support/enumerable.rb +100 -0
- data/lib/pacer/support/hash.rb +9 -0
- data/lib/pacer/support/iterator_mixins.rb +110 -0
- data/lib/pacer/support/native_exception.rb +22 -0
- data/lib/pacer/support/proc.rb +16 -0
- data/lib/pacer/support.rb +10 -0
- data/lib/pacer/transform/cap.rb +50 -0
- data/lib/pacer/transform/gather.rb +9 -0
- data/lib/pacer/transform/has_count_cap.rb +41 -0
- data/lib/pacer/transform/join.rb +181 -0
- data/lib/pacer/transform/map.rb +23 -0
- data/lib/pacer/transform/path.rb +50 -0
- data/lib/pacer/transform/process.rb +23 -0
- data/lib/pacer/transform/scatter.rb +23 -0
- data/lib/pacer/transform/sort_section.rb +103 -0
- data/lib/pacer/transform/stream_sort.rb +21 -0
- data/lib/pacer/transform/stream_uniq.rb +21 -0
- data/lib/pacer/transform.rb +16 -0
- data/lib/pacer/utils/graph_analysis.rb +112 -0
- data/lib/pacer/utils/trie.rb +93 -0
- data/lib/pacer/utils/tsort.rb +65 -0
- data/lib/pacer/utils/y_files.rb +127 -0
- data/lib/pacer/utils.rb +10 -0
- data/lib/pacer/version.rb +13 -0
- data/lib/pacer/wrappers/edge_wrapper.rb +51 -0
- data/lib/pacer/wrappers/element_wrapper.rb +78 -0
- data/lib/pacer/wrappers/new_element.rb +106 -0
- data/lib/pacer/wrappers/vertex_wrapper.rb +51 -0
- data/lib/pacer/wrappers.rb +19 -0
- data/lib/pacer-0.9.1.1-standalone.jar +0 -0
- data/lib/pacer.rb +290 -0
- data/pacer.gemspec +30 -0
- data/pom/standalone.xml +22 -0
- data/pom.xml +124 -0
- data/samples/grateful-dead.xml +26380 -0
- data/samples/grateful_dead.rb +63 -0
- data/samples/profile.rb +15 -0
- data/spec/data/grateful-dead.xml +26380 -0
- data/spec/data/pacer.graphml +319 -0
- data/spec/pacer/blueprints/dex_spec.rb +172 -0
- data/spec/pacer/blueprints/neo4j_spec.rb +177 -0
- data/spec/pacer/blueprints/tg_spec.rb +128 -0
- data/spec/pacer/core/graph/edges_route_spec.rb +52 -0
- data/spec/pacer/core/graph/element_route_spec.rb +46 -0
- data/spec/pacer/core/graph/graph_route_spec.rb +94 -0
- data/spec/pacer/core/graph/vertices_route_spec.rb +169 -0
- data/spec/pacer/core/route_spec.rb +197 -0
- data/spec/pacer/filter/collection_filter_spec.rb +19 -0
- data/spec/pacer/filter/empty_filter_spec.rb +29 -0
- data/spec/pacer/filter/future_filter_spec.rb +97 -0
- data/spec/pacer/filter/loop_filter_spec.rb +31 -0
- data/spec/pacer/filter/property_filter_spec.rb +111 -0
- data/spec/pacer/filter/random_filter_spec.rb +17 -0
- data/spec/pacer/filter/uniq_filter_spec.rb +18 -0
- data/spec/pacer/filter/where_filter_spec.rb +93 -0
- data/spec/pacer/graph/edge_mixin_spec.rb +116 -0
- data/spec/pacer/graph/element_mixin_spec.rb +297 -0
- data/spec/pacer/graph/graph_mixin_spec.rb +538 -0
- data/spec/pacer/graph/index_mixin_spec.rb +0 -0
- data/spec/pacer/graph/vertex_mixin_spec.rb +192 -0
- data/spec/pacer/pipe/block_filter_pipe_spec.rb +0 -0
- data/spec/pacer/pipe/labels_filter_pipe_spec.rb +0 -0
- data/spec/pacer/pipe/ruby_pipe_spec.rb +0 -0
- data/spec/pacer/pipe/type_filter_pipe_spec.rb +0 -0
- data/spec/pacer/route/mixin/base_spec.rb +419 -0
- data/spec/pacer/route/mixin/bulk_operations_spec.rb +30 -0
- data/spec/pacer/route/mixin/route_operations_spec.rb +127 -0
- data/spec/pacer/support/array_list_spec.rb +0 -0
- data/spec/pacer/support/enumerable_spec.rb +115 -0
- data/spec/pacer/transform/join_spec.rb +138 -0
- data/spec/pacer/transform/path_spec.rb +54 -0
- data/spec/pacer/utils/tsort_spec.rb +89 -0
- data/spec/pacer/wrapper/edge_wrapper_spec.rb +33 -0
- data/spec/pacer/wrapper/element_wrapper_spec.rb +169 -0
- data/spec/pacer/wrapper/vertex_wrapper_spec.rb +33 -0
- data/spec/pacer_spec.rb +0 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/support/contexts.rb +14 -0
- data/spec/support/graph_runner.rb +142 -0
- data/spec/support/matchers.rb +19 -0
- data/spec/support/use_transactions.rb +31 -0
- data/spec/tackle/simple_mixin.rb +21 -0
- data/spec/tackle/tinkerpop_graph_mixins.rb +60 -0
- metadata +364 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for Pacer::EdgeMixin do
|
4
|
+
use_simple_graph_data
|
5
|
+
|
6
|
+
describe '#e' do
|
7
|
+
subject { e0.e }
|
8
|
+
it { should be_an_edges_route }
|
9
|
+
it { should_not be_a(graph.element_type(:edge)) }
|
10
|
+
it { should_not be_an_instance_of(graph.element_type(:edge)) }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#add_extensions' do
|
14
|
+
context 'no extensions' do
|
15
|
+
subject { e0.add_extensions([]) }
|
16
|
+
its('extensions.to_a') { should == [] }
|
17
|
+
it { should_not be_a(Pacer::Wrappers::ElementWrapper) }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with extensions' do
|
21
|
+
subject { e0.add_extensions([Tackle::SimpleMixin]) }
|
22
|
+
its('extensions.to_a') { should == [Tackle::SimpleMixin] }
|
23
|
+
it { should be_a(Pacer::Wrappers::ElementWrapper) }
|
24
|
+
it { should be_a(Pacer::Wrappers::EdgeWrapper) }
|
25
|
+
it { should_not be_a(Pacer::Wrappers::VertexWrapper) }
|
26
|
+
|
27
|
+
describe '#e' do
|
28
|
+
subject { e0.add_extensions([Tackle::SimpleMixin]).e }
|
29
|
+
its('extensions.to_a') { should == [Tackle::SimpleMixin] }
|
30
|
+
it { should be_an_edges_route }
|
31
|
+
it { should be_a(Tackle::SimpleMixin::Route) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#delete!' do
|
37
|
+
before do
|
38
|
+
@edge_id = e0.element_id
|
39
|
+
e0.delete!
|
40
|
+
graph.checkpoint # deleted edges in neo may be looked up during the transaction
|
41
|
+
end
|
42
|
+
it 'should be removed' do
|
43
|
+
graph.edge(@edge_id).should be_nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
contexts(
|
48
|
+
'into new tg' => proc {
|
49
|
+
let(:dest) { Pacer.tg }
|
50
|
+
},
|
51
|
+
'into graph2' => proc {
|
52
|
+
let(:dest) { graph2 }
|
53
|
+
}) do
|
54
|
+
describe '#clone_into', :transactions => false do
|
55
|
+
before { pending 'support temporary hash indices for clone/copy' unless graph.supports_manual_indices? }
|
56
|
+
context 'including vertices' do
|
57
|
+
subject { e0.clone_into(dest, :create_vertices => true) }
|
58
|
+
|
59
|
+
its('element_id.to_s') { should == e0.element_id.to_s if graph.supports_custom_element_ids? }
|
60
|
+
its(:label) { should == 'links' }
|
61
|
+
its(:graph) { should equal(dest) }
|
62
|
+
its('in_vertex.properties') { should == { 'name' => 'eliza' } }
|
63
|
+
its('out_vertex.properties') { should == { 'name' => 'darrick' } }
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'without vertices' do
|
67
|
+
subject { e0.clone_into(dest) rescue nil }
|
68
|
+
it { should be_nil }
|
69
|
+
|
70
|
+
context 'but already existing' do
|
71
|
+
before do
|
72
|
+
v0.clone_into(dest)
|
73
|
+
v1.clone_into(dest)
|
74
|
+
end
|
75
|
+
its('element_id.to_s') { should == e0.element_id.to_s if graph.supports_custom_element_ids? }
|
76
|
+
its(:label) { should == 'links' }
|
77
|
+
its(:graph) { should equal(dest) }
|
78
|
+
its('in_vertex.properties') { should == { 'name' => 'eliza' } }
|
79
|
+
its('out_vertex.properties') { should == { 'name' => 'darrick' } }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#copy_into', :transactions => false do
|
85
|
+
before { pending unless graph.supports_manual_indices? }
|
86
|
+
subject { v0.clone_into(dest); v1.clone_into(dest); e0.copy_into(dest) }
|
87
|
+
its(:label) { should == 'links' }
|
88
|
+
its(:graph) { should equal(dest) }
|
89
|
+
its('in_vertex.properties') { should == { 'name' => 'eliza' } }
|
90
|
+
its('out_vertex.properties') { should == { 'name' => 'darrick' } }
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
subject { e0 }
|
96
|
+
its(:graph) { should equal(graph) }
|
97
|
+
its(:display_name) { should == "#{ v0.element_id }-links-#{ v1.element_id }" }
|
98
|
+
its(:inspect) { should == "#<E[#{ e0.element_id }]:#{ v0.element_id }-links-#{ v1.element_id }>" }
|
99
|
+
context 'with label proc' do
|
100
|
+
before do
|
101
|
+
graph.edge_name = proc { |e| "some name" }
|
102
|
+
end
|
103
|
+
its(:display_name) { should == "some name" }
|
104
|
+
its(:inspect) { should == "#<E[#{ e0.element_id }]:some name>" }
|
105
|
+
end
|
106
|
+
|
107
|
+
context '', :transactions => true do
|
108
|
+
it { should_not == e1 }
|
109
|
+
it { should == e0 }
|
110
|
+
it { should_not == v0 }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
Run.all do
|
115
|
+
it_uses Pacer::EdgeMixin
|
116
|
+
end
|
@@ -0,0 +1,297 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
unless defined? ElementMixinSpec
|
4
|
+
ElementMixinSpec = true
|
5
|
+
|
6
|
+
shared_examples_for Pacer::ElementMixin do
|
7
|
+
context 'vertex' do
|
8
|
+
subject { v0 }
|
9
|
+
it { should be_a(Pacer::Core::Graph::VerticesRoute) }
|
10
|
+
it { should be_a(Pacer::ElementMixin) }
|
11
|
+
it { should be_a(Pacer::VertexMixin) }
|
12
|
+
it { should_not be_a(Pacer::EdgeMixin) }
|
13
|
+
|
14
|
+
describe '#v' do
|
15
|
+
context '()' do
|
16
|
+
subject { v0.v }
|
17
|
+
its(:to_a) { should == [v0] }
|
18
|
+
it { should be_a_vertices_route }
|
19
|
+
end
|
20
|
+
|
21
|
+
context '(:name => "eliza")' do
|
22
|
+
subject { v0.v(:name => 'eliza') }
|
23
|
+
its(:to_a) { should == [v0] }
|
24
|
+
it { should be_a_vertices_route }
|
25
|
+
end
|
26
|
+
|
27
|
+
context '(:name => "other")' do
|
28
|
+
subject { v0.v(:name => 'other') }
|
29
|
+
its(:to_a) { should == [] }
|
30
|
+
it { should be_a_vertices_route }
|
31
|
+
end
|
32
|
+
|
33
|
+
context '(SimpleMixin)' do
|
34
|
+
subject { v0.v(Tackle::SimpleMixin) }
|
35
|
+
its(:to_a) { should == [v0] }
|
36
|
+
it { should be_a_vertices_route }
|
37
|
+
its(:extensions) { should == Set[Tackle::SimpleMixin] }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#e' do
|
42
|
+
it 'is unsupported' do
|
43
|
+
expect { v0.e }.to raise_error(Pacer::UnsupportedOperation)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#eql?' do
|
48
|
+
subject { Hash.new(0) }
|
49
|
+
before do
|
50
|
+
subject[v0] += 1
|
51
|
+
subject[graph.v.first] += 1
|
52
|
+
end
|
53
|
+
|
54
|
+
its(:keys) { should == [v0] }
|
55
|
+
its(:values) { should == [2] }
|
56
|
+
|
57
|
+
it 'should put wrapped vertices in the same key' do
|
58
|
+
subject[v0.v(Tackle::SimpleMixin).first] += 1
|
59
|
+
subject.values.should == [3]
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should put other vertices in a different key' do
|
63
|
+
subject[v1].should == 0
|
64
|
+
subject[v0].should == 2
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'edge' do
|
70
|
+
subject { e0 }
|
71
|
+
it { should be_a(Pacer::Core::Graph::EdgesRoute) }
|
72
|
+
it { should be_a(Pacer::ElementMixin) }
|
73
|
+
it { should be_a(Pacer::EdgeMixin) }
|
74
|
+
it { should_not be_a(Pacer::VertexMixin) }
|
75
|
+
|
76
|
+
describe '#e', :transactions => false do
|
77
|
+
context '()' do
|
78
|
+
subject { e0.e }
|
79
|
+
its(:to_a) { should == [e0] }
|
80
|
+
it(:a => :b) { should be_an_edges_route }
|
81
|
+
end
|
82
|
+
|
83
|
+
context '(:links)' do
|
84
|
+
subject { e0.e(:links) }
|
85
|
+
its(:to_a) { should == [e0] }
|
86
|
+
it { should be_an_edges_route }
|
87
|
+
end
|
88
|
+
|
89
|
+
context '(:other)' do
|
90
|
+
subject { e0.e(:other) }
|
91
|
+
its(:to_a) { should == [] }
|
92
|
+
it { should be_an_edges_route }
|
93
|
+
end
|
94
|
+
|
95
|
+
context '(SimpleMixin)' do
|
96
|
+
subject { e0.e(Tackle::SimpleMixin) }
|
97
|
+
its(:to_a) { should == [e0] }
|
98
|
+
it { should be_an_edges_route }
|
99
|
+
its(:extensions) { should == Set[Tackle::SimpleMixin] }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#v' do
|
104
|
+
it 'is unsupported' do
|
105
|
+
expect { e0.v }.to raise_error(Pacer::UnsupportedOperation)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#eql?', :transactions => false do
|
110
|
+
subject { Hash.new(0) }
|
111
|
+
before do
|
112
|
+
subject[e0] += 1
|
113
|
+
subject[graph.e.first] += 1
|
114
|
+
end
|
115
|
+
|
116
|
+
its(:keys) { should == [e0] }
|
117
|
+
its(:values) { should == [2] }
|
118
|
+
|
119
|
+
it 'should put wrapped edges in the same key' do
|
120
|
+
subject[e0.e(Tackle::SimpleMixin).first] += 1
|
121
|
+
subject.values.should == [3]
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should put other edges in a different key' do
|
125
|
+
subject[e1].should == 0
|
126
|
+
subject[e0].should == 2
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#graph' do
|
132
|
+
it { v0.graph.should == graph }
|
133
|
+
it { e0.graph.should == graph }
|
134
|
+
end
|
135
|
+
|
136
|
+
contexts(
|
137
|
+
'vertex' => proc{
|
138
|
+
let(:element) { v0 }
|
139
|
+
},
|
140
|
+
'edge' => proc{
|
141
|
+
let(:element) { e0 }
|
142
|
+
}) do
|
143
|
+
describe '#[]' do
|
144
|
+
context 'value types' do
|
145
|
+
it '(String)' do
|
146
|
+
element[:string] = 'words'
|
147
|
+
element[:string].should == 'words'
|
148
|
+
end
|
149
|
+
|
150
|
+
it '(Array)' do
|
151
|
+
a = [10, 'elements']
|
152
|
+
element[:array] = a
|
153
|
+
element[:array].should == a
|
154
|
+
end
|
155
|
+
|
156
|
+
it '(Hash)' do
|
157
|
+
h = { :elements => 10 }
|
158
|
+
element[:hash] = h
|
159
|
+
element[:hash].should == h
|
160
|
+
end
|
161
|
+
|
162
|
+
it '(Time)' do
|
163
|
+
time = Time.utc 2011, 1, 2, 3, 4, 5
|
164
|
+
element[:time] = time
|
165
|
+
element[:time].should == time
|
166
|
+
end
|
167
|
+
|
168
|
+
it '(Fixnum)' do
|
169
|
+
element[:number] = 123
|
170
|
+
element[:number].should == 123
|
171
|
+
end
|
172
|
+
|
173
|
+
it '(Float)' do
|
174
|
+
element[:float] = 12.345
|
175
|
+
element[:float].should == 12.345
|
176
|
+
end
|
177
|
+
|
178
|
+
it '(Bignum)' do
|
179
|
+
element[:big] = 123321123321123321123321123321123321
|
180
|
+
element[:big].should == 123321123321123321123321123321123321
|
181
|
+
end
|
182
|
+
|
183
|
+
it "('')" do
|
184
|
+
element[:name] = ''
|
185
|
+
element[:name].should be_nil
|
186
|
+
element.property_keys.should_not include('name')
|
187
|
+
end
|
188
|
+
|
189
|
+
it '(nil)' do
|
190
|
+
element[:name] = nil
|
191
|
+
element[:name].should be_nil
|
192
|
+
element.property_keys.should_not include('name')
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'key types' do
|
197
|
+
it 'String' do
|
198
|
+
element['name'].should == element[:name]
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'Fixnum' do
|
202
|
+
element[123] = 'value'
|
203
|
+
element[123].should == 'value'
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
describe '#result', :transactions => false do
|
209
|
+
subject { element.result }
|
210
|
+
it { should equal(element) }
|
211
|
+
end
|
212
|
+
|
213
|
+
describe '#from_graph?' do
|
214
|
+
context 'same graph' do
|
215
|
+
subject { element.from_graph? graph }
|
216
|
+
it { should be_true }
|
217
|
+
end
|
218
|
+
context 'different graph' do
|
219
|
+
subject { element.from_graph? graph2 }
|
220
|
+
it { should be_false }
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe '#properties' do
|
225
|
+
before do
|
226
|
+
element.properties = { :a => 'valuea', :b => 'valueb' }
|
227
|
+
end
|
228
|
+
subject { element.properties }
|
229
|
+
it { should be_a(Hash) }
|
230
|
+
its(:count) { should == 2 }
|
231
|
+
it 'should have the correct vales' do
|
232
|
+
element.properties['a'].should == 'valuea'
|
233
|
+
element.properties['b'].should == 'valueb'
|
234
|
+
element[:a].should == 'valuea'
|
235
|
+
element[:b].should == 'valueb'
|
236
|
+
end
|
237
|
+
it 'should not affect the element if returned values are changed' do
|
238
|
+
element.properties['a'].gsub!(/value/, 'oops')
|
239
|
+
element.properties['a'].should == 'valuea'
|
240
|
+
element[:a].should == 'valuea'
|
241
|
+
end
|
242
|
+
it 'should not affect the element if returned keys are changed' do
|
243
|
+
element.properties.delete('a')
|
244
|
+
element.properties['a'].should == 'valuea'
|
245
|
+
element[:a].should == 'valuea'
|
246
|
+
end
|
247
|
+
it 'should not affect the element if something is added' do
|
248
|
+
element.properties['c'] = 'something'
|
249
|
+
element[:c].should be_nil
|
250
|
+
end
|
251
|
+
context 'existing properties' do
|
252
|
+
before do
|
253
|
+
element.properties = { :a => 'new value', :c => 'value c' }
|
254
|
+
end
|
255
|
+
its(:count) { should == 2 }
|
256
|
+
it 'should have the correct values' do
|
257
|
+
element[:a].should == 'new value'
|
258
|
+
element[:b].should be_nil
|
259
|
+
element[:c].should == 'value c'
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
subject { element }
|
265
|
+
its(:element_id) { should_not be_nil }
|
266
|
+
context '', :transactions => false do
|
267
|
+
# FIXME: Neo4j edges are flaky sometimes when inside a
|
268
|
+
# transaction. If you look them up by id, they are not found.
|
269
|
+
its(:to_a) { should == [element] }
|
270
|
+
its(:element) { should == element }
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
Run.all do
|
277
|
+
it_uses Pacer::ElementMixin do
|
278
|
+
let(:v0) { graph.create_vertex :name => 'eliza' }
|
279
|
+
let(:v1) { graph.create_vertex :name => 'darrick' }
|
280
|
+
let(:e0) { graph.create_edge nil, v0, v1, :links }
|
281
|
+
let(:e1) { graph.create_edge nil, v0, v1, :relinks }
|
282
|
+
end
|
283
|
+
|
284
|
+
context 'vertex' do
|
285
|
+
let(:v0) { graph.create_vertex :name => 'eliza' }
|
286
|
+
subject { v0 }
|
287
|
+
it { should_not be_a(Pacer::Wrappers::ElementWrapper) }
|
288
|
+
end
|
289
|
+
|
290
|
+
context 'edge' do
|
291
|
+
let(:v0) { graph.create_vertex :name => 'eliza' }
|
292
|
+
let(:v1) { graph.create_vertex :name => 'darrick' }
|
293
|
+
let(:e0) { graph.create_edge nil, v0, v1, :links }
|
294
|
+
subject { e0 }
|
295
|
+
it { should_not be_a(Pacer::Wrappers::ElementWrapper) }
|
296
|
+
end
|
297
|
+
end
|