axiom-arango-adapter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rspec +5 -0
- data/.travis.yml +25 -0
- data/Gemfile +9 -0
- data/Gemfile.devtools +57 -0
- data/Guardfile +18 -0
- data/LICENSE +20 -0
- data/README.md +92 -0
- data/Rakefile +2 -0
- data/TODO +1 -0
- data/axiom-arango-adapter.gemspec +26 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/roodi.yml +18 -0
- data/config/site.reek +102 -0
- data/config/yardstick.yml +2 -0
- data/lib/axiom-arango-adapter.rb +2 -0
- data/lib/axiom/adapter/arango.rb +40 -0
- data/lib/axiom/adapter/arango/adapter.rb +68 -0
- data/lib/axiom/adapter/arango/gateway.rb +356 -0
- data/lib/axiom/adapter/arango/reader.rb +98 -0
- data/lib/axiom/adapter/arango/visitor.rb +100 -0
- data/lib/axiom/adapter/arango/visitor/aggregate.rb +132 -0
- data/lib/axiom/adapter/arango/visitor/attribute.rb +26 -0
- data/lib/axiom/adapter/arango/visitor/binary.rb +77 -0
- data/lib/axiom/adapter/arango/visitor/for.rb +75 -0
- data/lib/axiom/adapter/arango/visitor/for/base.rb +40 -0
- data/lib/axiom/adapter/arango/visitor/for/binary.rb +108 -0
- data/lib/axiom/adapter/arango/visitor/for/binary/join.rb +131 -0
- data/lib/axiom/adapter/arango/visitor/for/binary/product.rb +48 -0
- data/lib/axiom/adapter/arango/visitor/for/summarization.rb +113 -0
- data/lib/axiom/adapter/arango/visitor/for/unary.rb +29 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/extension.rb +72 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/limit.rb +31 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/offset.rb +34 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/order.rb +63 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/projection.rb +32 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/rename.rb +88 -0
- data/lib/axiom/adapter/arango/visitor/for/unary/restriction.rb +42 -0
- data/lib/axiom/adapter/arango/visitor/function.rb +33 -0
- data/lib/axiom/adapter/arango/visitor/header.rb +55 -0
- data/lib/axiom/adapter/arango/visitor/literal.rb +26 -0
- data/lib/axiom/adapter/arango/visitor/reverse.rb +27 -0
- data/spec/fuzzer.rb +53 -0
- data/spec/integration/arango/read_spec.rb +166 -0
- data/spec/setup/arangodb.sh +61 -0
- data/spec/setup/run.sh +23 -0
- data/spec/shared/aql_behavior.rb +7 -0
- data/spec/shared/binary_relation_method_behaviour.rb +53 -0
- data/spec/shared/unary_relation_method_behaviour.rb +21 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/support/ice_nine_config.rb +6 -0
- data/spec/unit/axiom/adapter/arango/adapter/class_methods/new_spec.rb +24 -0
- data/spec/unit/axiom/adapter/arango/adapter/gateway_spec.rb +11 -0
- data/spec/unit/axiom/adapter/arango/adapter/reader_spec.rb +12 -0
- data/spec/unit/axiom/adapter/arango/gateway/class_methods/new_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/gateway/difference_spec.rb +16 -0
- data/spec/unit/axiom/adapter/arango/gateway/drop_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/each_spec.rb +78 -0
- data/spec/unit/axiom/adapter/arango/gateway/extend_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/gateway/intersect_spec.rb +16 -0
- data/spec/unit/axiom/adapter/arango/gateway/join_spec.rb +43 -0
- data/spec/unit/axiom/adapter/arango/gateway/materialize_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/gateway/optimize_spec.rb +22 -0
- data/spec/unit/axiom/adapter/arango/gateway/product_spec.rb +16 -0
- data/spec/unit/axiom/adapter/arango/gateway/project_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/remove_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/rename_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/respond_to_predicate_spec.rb +28 -0
- data/spec/unit/axiom/adapter/arango/gateway/restrict_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/gateway/reverse_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/sort_by_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/gateway/summarize_spec.rb +150 -0
- data/spec/unit/axiom/adapter/arango/gateway/take_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/gateway/unhandled_message_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/gateway/union_spec.rb +16 -0
- data/spec/unit/axiom/adapter/arango/reader/each_spec.rb +43 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/count/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/count_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/maximum/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/maximum_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/minimum/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/minimum_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/sum/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/aggregate/sum_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/attribute/root_spec.rb +12 -0
- data/spec/unit/axiom/adapter/arango/visitor/binary/root_spec.rb +15 -0
- data/spec/unit/axiom/adapter/arango/visitor/class_methods/build_spec.rb +37 -0
- data/spec/unit/axiom/adapter/arango/visitor/class_methods/run_spec.rb +26 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/base/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/join/local_name_spec.rb +20 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/join/right/root_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/join/root_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/join_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/local_name_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/product/right/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/product/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/product_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/right/join_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/right/local_name_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/binary/right/product_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/local_name_spec.rb +21 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/root_spec.rb +29 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/summarization/root_spec.rb +53 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/extension/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/extension_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/limit/root_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/limit_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/offset/root_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/offset_spec.rb +17 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/order/root_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/order_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/projection/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/projection_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/rename/root_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/rename_spec.rb +13 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/restriction/root_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/for/unary/restriction_spec.rb +14 -0
- data/spec/unit/axiom/adapter/arango/visitor/header/root_spec.rb +12 -0
- data/spec/unit/axiom/adapter/arango/visitor/literal/root_spec.rb +10 -0
- data/spec/unit/axiom/adapter/arango/visitor/static/root_spec.rb +19 -0
- data/spec/unit/axiom/adapter/arango/visitor/visit_spec.rb +52 -0
- data/spec/unit/axiom/adapter/arango/visitor/visitor_spec.rb +39 -0
- metadata +379 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '.new' do
|
6
|
+
subject { object.new(adapter, relation) }
|
7
|
+
|
8
|
+
let(:adapter) { stub }
|
9
|
+
let(:relation) { stub }
|
10
|
+
let(:object) { described_class }
|
11
|
+
|
12
|
+
it { should be_instance_of(described_class) }
|
13
|
+
|
14
|
+
it { should be_frozen }
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#difference' do
|
6
|
+
subject { object.difference(other) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation') }
|
10
|
+
let(:object) { described_class.new(adapter, relation) }
|
11
|
+
let(:operation) { :difference }
|
12
|
+
let(:factory) { Axiom::Algebra::Difference }
|
13
|
+
let(:binary_relation) { mock(factory) }
|
14
|
+
|
15
|
+
it_should_behave_like 'a binary relation method'
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#drop' do
|
6
|
+
subject { object.drop(args) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation', :drop => response) }
|
10
|
+
let(:response) { mock('New Relation', :kind_of? => true) }
|
11
|
+
let!(:object) { described_class.new(adapter, relation) }
|
12
|
+
let(:args) { stub }
|
13
|
+
|
14
|
+
it_should_behave_like 'a unary relation method'
|
15
|
+
|
16
|
+
it 'forwards the arguments to relation#drop' do
|
17
|
+
relation.should_receive(:drop).with(args)
|
18
|
+
subject
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#each' do
|
6
|
+
subject { object.each { |tuple| yields << tuple } }
|
7
|
+
|
8
|
+
let(:header) { mock('Header') }
|
9
|
+
let(:reader) { mock('Reader') }
|
10
|
+
let(:tuple) { mock('Tuple') }
|
11
|
+
let(:adapter) { mock('Adapter') }
|
12
|
+
let(:relation) { mock('Relation') }
|
13
|
+
let!(:object) { described_class.new(adapter, relation) }
|
14
|
+
let(:reader) { [tuple] }
|
15
|
+
let(:yields) { [] }
|
16
|
+
|
17
|
+
before do
|
18
|
+
adapter.stub(:reader => reader)
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with an unmaterialized relation' do
|
22
|
+
let(:wrapper) { stub }
|
23
|
+
|
24
|
+
before do
|
25
|
+
relation.stub!(:header).and_return(header)
|
26
|
+
relation.stub!(:materialized?).and_return(false)
|
27
|
+
relation.stub!(:each).and_return(relation)
|
28
|
+
end
|
29
|
+
|
30
|
+
it_should_behave_like 'an #each method'
|
31
|
+
|
32
|
+
it 'yields each tuple' do
|
33
|
+
expect { subject }.to change { yields.dup }.
|
34
|
+
from([]).
|
35
|
+
to([ tuple ])
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'passes in the relation to the adapter reader' do
|
39
|
+
adapter.should_receive(:reader).with(relation).and_return(reader)
|
40
|
+
subject
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with a materialized relation' do
|
45
|
+
before do
|
46
|
+
relation.stub!(:materialized?).and_return(true)
|
47
|
+
|
48
|
+
# I do not know a better way to mock this behaviour out and
|
49
|
+
# I'm pretty sure that rspec does not provide Enumerator helpers
|
50
|
+
relation.stub(:each) do |&block|
|
51
|
+
unless block
|
52
|
+
relation.to_enum
|
53
|
+
else
|
54
|
+
block.call(tuple)
|
55
|
+
relation
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it_should_behave_like 'an #each method'
|
61
|
+
|
62
|
+
it 'yields each tuple' do
|
63
|
+
expect { subject }.to change { yields.dup }.
|
64
|
+
from([]).
|
65
|
+
to([ tuple ])
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'does not create a reader' do
|
69
|
+
adapter.should_not_receive(:read)
|
70
|
+
subject
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'does not create a wrapper' do
|
74
|
+
Axiom::Relation.should_not_receive(:new)
|
75
|
+
subject
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#extend' do
|
6
|
+
subject { object.extend(args, &block) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation', :extend => response) }
|
10
|
+
let(:response) { mock('New Relation', :kind_of? => true) }
|
11
|
+
let!(:object) { described_class.new(adapter, relation) }
|
12
|
+
let(:args) { stub }
|
13
|
+
let(:block) { lambda { |context| } }
|
14
|
+
|
15
|
+
it_should_behave_like 'a unary relation method'
|
16
|
+
|
17
|
+
it 'forwards the arguments to relation#extend' do
|
18
|
+
relation.should_receive(:extend).with(args)
|
19
|
+
subject
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'forwards the block to relation#extend' do
|
23
|
+
relation.stub!(:extend) { |_args, &proc| proc.should equal(block) }
|
24
|
+
subject
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#intersect' do
|
6
|
+
subject { object.intersect(other) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation') }
|
10
|
+
let(:object) { described_class.new(adapter, relation) }
|
11
|
+
let(:operation) { :intersect }
|
12
|
+
let(:factory) { Axiom::Algebra::Intersection }
|
13
|
+
let(:binary_relation) { mock(factory) }
|
14
|
+
|
15
|
+
it_should_behave_like 'a binary relation method'
|
16
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#join' do
|
6
|
+
subject { object.join(other) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation') }
|
10
|
+
let(:object) { described_class.new(adapter, relation) }
|
11
|
+
let(:operation) { :join }
|
12
|
+
let(:factory) { Axiom::Algebra::Join }
|
13
|
+
let(:binary_relation) { mock(factory) }
|
14
|
+
|
15
|
+
it_should_behave_like 'a binary relation method'
|
16
|
+
|
17
|
+
context 'when passed a block' do
|
18
|
+
subject { object.join(other) { |context| yields << context } }
|
19
|
+
|
20
|
+
let(:other_relation) { mock('Other Relation') }
|
21
|
+
let(:other) { described_class.new(adapter, other_relation) }
|
22
|
+
let(:gateway) { mock('Other Gateway') }
|
23
|
+
let(:join) { mock('Join', :restrict => gateway) }
|
24
|
+
let(:yields) { [] }
|
25
|
+
|
26
|
+
before do
|
27
|
+
Axiom::Algebra::Join.stub!(:new).with(relation, other_relation).and_return(join)
|
28
|
+
end
|
29
|
+
|
30
|
+
it { should equal(gateway) }
|
31
|
+
|
32
|
+
it 'passes the relations to the join constructor' do
|
33
|
+
Axiom::Algebra::Join.should_receive(:new).with(relation, other_relation)
|
34
|
+
subject
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'passes the block to the join relation' do
|
38
|
+
context = mock('Context')
|
39
|
+
join.should_receive(:restrict).and_yield(context)
|
40
|
+
expect { subject }.to change { yields.dup }.from([]).to([ context ])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#materialize' do
|
6
|
+
subject { object.materialize }
|
7
|
+
|
8
|
+
let(:header) { mock('Header') }
|
9
|
+
let(:directions) { mock('Directions') }
|
10
|
+
let(:adapter) { stub.as_null_object }
|
11
|
+
let(:relation) { mock('Relation', :header => header, :directions => directions, :materialized? => false) }
|
12
|
+
let!(:object) { described_class.new(adapter, relation) }
|
13
|
+
let(:materialized) { mock('Materialized') }
|
14
|
+
|
15
|
+
before do
|
16
|
+
Axiom::Relation::Materialized.stub!(:new).and_return(materialized)
|
17
|
+
Axiom::Relation.stub!(:new).and_return(stub.as_null_object)
|
18
|
+
end
|
19
|
+
|
20
|
+
it { should equal(materialized) }
|
21
|
+
|
22
|
+
it 'initializes the materialized relation with the header, tuples and directions' do
|
23
|
+
Axiom::Relation::Materialized.should_receive(:new).with(header, [], directions)
|
24
|
+
subject
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:adapter) { stub }
|
9
|
+
let(:relation) { mock('Relation') }
|
10
|
+
let(:object) { described_class.new(adapter, relation) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
relation.stub!(:optimize).and_return(relation)
|
14
|
+
end
|
15
|
+
|
16
|
+
it_should_behave_like 'a command method'
|
17
|
+
|
18
|
+
it 'forwards the message to relation#optimize' do
|
19
|
+
relation.should_receive(:optimize).with(no_args)
|
20
|
+
subject
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#product' do
|
6
|
+
subject { object.product(other) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation') }
|
10
|
+
let(:object) { described_class.new(adapter, relation) }
|
11
|
+
let(:operation) { :product }
|
12
|
+
let(:factory) { Axiom::Algebra::Product }
|
13
|
+
let(:binary_relation) { mock(factory) }
|
14
|
+
|
15
|
+
it_should_behave_like 'a binary relation method'
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#project' do
|
6
|
+
subject { object.project(args) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation', :project => response) }
|
10
|
+
let(:response) { mock('New Relation', :kind_of? => true) }
|
11
|
+
let!(:object) { described_class.new(adapter, relation) }
|
12
|
+
let(:args) { stub }
|
13
|
+
|
14
|
+
it_should_behave_like 'a unary relation method'
|
15
|
+
|
16
|
+
it 'forwards the arguments to relation#project' do
|
17
|
+
relation.should_receive(:project).with(args)
|
18
|
+
subject
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#remove' do
|
6
|
+
subject { object.remove(args) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation', :remove => response) }
|
10
|
+
let(:response) { mock('New Relation', :kind_of? => true) }
|
11
|
+
let!(:object) { described_class.new(adapter, relation) }
|
12
|
+
let(:args) { stub }
|
13
|
+
|
14
|
+
it_should_behave_like 'a unary relation method'
|
15
|
+
|
16
|
+
it 'forwards the arguments to relation#remove' do
|
17
|
+
relation.should_receive(:remove).with(args)
|
18
|
+
subject
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#rename' do
|
6
|
+
subject { object.rename(args) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation', :rename => response) }
|
10
|
+
let(:response) { mock('New Relation', :kind_of? => true) }
|
11
|
+
let!(:object) { described_class.new(adapter, relation) }
|
12
|
+
let(:args) { stub }
|
13
|
+
|
14
|
+
it_should_behave_like 'a unary relation method'
|
15
|
+
|
16
|
+
it 'forwards the arguments to relation#rename' do
|
17
|
+
relation.should_receive(:rename).with(args)
|
18
|
+
subject
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#respond_to?' do
|
6
|
+
subject { object.respond_to?(method) }
|
7
|
+
|
8
|
+
let(:relation) { mock('Relation', :header => stub) }
|
9
|
+
let(:object) { described_class.new(stub, relation) }
|
10
|
+
|
11
|
+
context 'with an unknown method' do
|
12
|
+
let(:method) { :unknown }
|
13
|
+
|
14
|
+
it { should be(false) }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with a known method' do
|
18
|
+
let(:method) { :each }
|
19
|
+
|
20
|
+
it { should be(true) }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with a known method in the relation' do
|
24
|
+
let(:method) { :header }
|
25
|
+
|
26
|
+
it { should be(true) }
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#restrict' do
|
6
|
+
subject { object.restrict(args, &block) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation', :restrict => response) }
|
10
|
+
let(:response) { mock('New Relation', :kind_of? => true) }
|
11
|
+
let!(:object) { described_class.new(adapter, relation) }
|
12
|
+
let(:args) { stub }
|
13
|
+
let(:block) { lambda { |context| } }
|
14
|
+
|
15
|
+
it_should_behave_like 'a unary relation method'
|
16
|
+
|
17
|
+
it 'forwards the arguments to relation#restrict' do
|
18
|
+
relation.should_receive(:restrict).with(args)
|
19
|
+
subject
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'forwards the block to relation#restrict' do
|
23
|
+
relation.stub!(:restrict) { |_args, &proc| proc.should equal(block) }
|
24
|
+
subject
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#reverse' do
|
6
|
+
subject { object.reverse(args) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation', :reverse => response) }
|
10
|
+
let(:response) { mock('New Relation', :kind_of? => true) }
|
11
|
+
let!(:object) { described_class.new(adapter, relation) }
|
12
|
+
let(:args) { stub }
|
13
|
+
|
14
|
+
it_should_behave_like 'a unary relation method'
|
15
|
+
|
16
|
+
it 'forwards the arguments to relation#reverse' do
|
17
|
+
relation.should_receive(:reverse).with(args)
|
18
|
+
subject
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Axiom::Adapter::Arango::Gateway, '#sort_by' do
|
6
|
+
subject { object.sort_by(args, &block) }
|
7
|
+
|
8
|
+
let(:adapter) { mock('Adapter') }
|
9
|
+
let(:relation) { mock('Relation', :sort_by => response) }
|
10
|
+
let(:response) { mock('New Relation', :kind_of? => true) }
|
11
|
+
let!(:object) { described_class.new(adapter, relation) }
|
12
|
+
let(:args) { stub }
|
13
|
+
let(:block) { lambda { |context| } }
|
14
|
+
|
15
|
+
it_should_behave_like 'a unary relation method'
|
16
|
+
|
17
|
+
it 'forwards the arguments to relation#sort_by' do
|
18
|
+
relation.should_receive(:sort_by).with(args)
|
19
|
+
subject
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'forwards the block to relation#sort_by' do
|
23
|
+
relation.stub!(:sort_by) { |_args, &proc| proc.should equal(block) }
|
24
|
+
subject
|
25
|
+
end
|
26
|
+
end
|