axiom-do-adapter 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +17 -23
- data/CONTRIBUTING.md +1 -2
- data/Gemfile +10 -5
- data/Gemfile.devtools +39 -27
- data/README.md +3 -6
- data/axiom-do-adapter.gemspec +5 -7
- data/config/devtools.yml +2 -0
- data/config/reek.yml +2 -7
- data/config/rubocop.yml +59 -0
- data/lib/axiom/adapter/data_objects/statement.rb +4 -7
- data/lib/axiom/adapter/data_objects/version.rb +1 -1
- data/lib/axiom/relation/gateway.rb +3 -3
- data/spec/shared/binary_relation_method_behaviour.rb +11 -11
- data/spec/shared/unary_relation_method_behaviour.rb +4 -4
- data/spec/spec_helper.rb +13 -18
- data/spec/support/config_alias.rb +2 -0
- data/spec/unit/axiom/adapter/data_objects/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/adapter/data_objects/read_spec.rb +14 -18
- data/spec/unit/axiom/adapter/data_objects/statement/class_methods/new_spec.rb +3 -3
- data/spec/unit/axiom/adapter/data_objects/statement/each_spec.rb +23 -24
- data/spec/unit/axiom/adapter/data_objects/statement/to_s_spec.rb +9 -9
- data/spec/unit/axiom/relation/gateway/class_methods/new_spec.rb +2 -2
- data/spec/unit/axiom/relation/gateway/difference_spec.rb +3 -3
- data/spec/unit/axiom/relation/gateway/drop_spec.rb +6 -6
- data/spec/unit/axiom/relation/gateway/each_spec.rb +19 -23
- data/spec/unit/axiom/relation/gateway/extend_spec.rb +10 -12
- data/spec/unit/axiom/relation/gateway/intersect_spec.rb +3 -3
- data/spec/unit/axiom/relation/gateway/join_spec.rb +11 -11
- data/spec/unit/axiom/relation/gateway/materialize_spec.rb +9 -9
- data/spec/unit/axiom/relation/gateway/optimize_spec.rb +4 -4
- data/spec/unit/axiom/relation/gateway/product_spec.rb +3 -3
- data/spec/unit/axiom/relation/gateway/project_spec.rb +6 -6
- data/spec/unit/axiom/relation/gateway/remove_spec.rb +6 -6
- data/spec/unit/axiom/relation/gateway/rename_spec.rb +6 -6
- data/spec/unit/axiom/relation/gateway/respond_to_spec.rb +2 -2
- data/spec/unit/axiom/relation/gateway/restrict_spec.rb +10 -12
- data/spec/unit/axiom/relation/gateway/reverse_spec.rb +6 -6
- data/spec/unit/axiom/relation/gateway/sort_by_spec.rb +10 -12
- data/spec/unit/axiom/relation/gateway/summarize_spec.rb +48 -54
- data/spec/unit/axiom/relation/gateway/take_spec.rb +6 -6
- data/spec/unit/axiom/relation/gateway/union_spec.rb +3 -3
- metadata +23 -44
- data/.rvmrc +0 -1
- data/spec/support/example_group_methods.rb +0 -7
- data/spec/support/ice_nine_config.rb +0 -6
@@ -6,24 +6,22 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#extend' do
|
7
7
|
subject { object.extend(args, &block) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
11
|
-
let(:response) {
|
12
|
-
let!(:object) { described_class.new(adapter, relation)
|
13
|
-
let(:args) {
|
14
|
-
let(:block) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation', extend: response) }
|
11
|
+
let(:response) { double('New Relation', :kind_of? => true) }
|
12
|
+
let!(:object) { described_class.new(adapter, relation) }
|
13
|
+
let(:args) { double }
|
14
|
+
let(:block) { ->(context) {} }
|
15
15
|
|
16
16
|
it_should_behave_like 'a unary relation method'
|
17
17
|
|
18
18
|
it 'forwards the arguments to relation#extend' do
|
19
|
-
relation.
|
19
|
+
expect(relation).to receive(:extend).with(args)
|
20
20
|
subject
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
subject
|
27
|
-
end
|
23
|
+
it 'forwards the block to relation#extend' do
|
24
|
+
expect(relation).to receive(:extend) { |&proc| expect(proc).to equal(block) }
|
25
|
+
subject
|
28
26
|
end
|
29
27
|
end
|
@@ -6,12 +6,12 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#intersect' do
|
7
7
|
subject { object.intersect(other) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation') }
|
11
11
|
let(:object) { described_class.new(adapter, relation) }
|
12
12
|
let(:operation) { :intersect }
|
13
13
|
let(:factory) { Algebra::Intersection }
|
14
|
-
let(:binary_relation) {
|
14
|
+
let(:binary_relation) { double(factory) }
|
15
15
|
|
16
16
|
it_should_behave_like 'a binary relation method'
|
17
17
|
end
|
@@ -6,39 +6,39 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#join' do
|
7
7
|
subject { object.join(other) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation') }
|
11
11
|
let(:object) { described_class.new(adapter, relation) }
|
12
12
|
let(:operation) { :join }
|
13
13
|
let(:factory) { Algebra::Join }
|
14
|
-
let(:binary_relation) {
|
14
|
+
let(:binary_relation) { double(factory) }
|
15
15
|
|
16
16
|
it_should_behave_like 'a binary relation method'
|
17
17
|
|
18
18
|
context 'when passed a block' do
|
19
19
|
subject { object.join(other) { |context| yields << context } }
|
20
20
|
|
21
|
-
let(:other_relation) {
|
21
|
+
let(:other_relation) { double('Other Relation') }
|
22
22
|
let(:other) { described_class.new(adapter, other_relation) }
|
23
|
-
let(:gateway) {
|
24
|
-
let(:join) {
|
23
|
+
let(:gateway) { double('Other Gateway') }
|
24
|
+
let(:join) { double('Join', restrict: gateway) }
|
25
25
|
let(:yields) { [] }
|
26
26
|
|
27
27
|
before do
|
28
|
-
Algebra::Join.
|
28
|
+
allow(Algebra::Join).to receive(:new).with(relation, other_relation).and_return(join)
|
29
29
|
end
|
30
30
|
|
31
31
|
it { should equal(gateway) }
|
32
32
|
|
33
33
|
it 'passes the relations to the join constructor' do
|
34
|
-
Algebra::Join.
|
34
|
+
expect(Algebra::Join).to receive(:new).with(relation, other_relation)
|
35
35
|
subject
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'passes the block to the join relation' do
|
39
|
-
context =
|
40
|
-
join.
|
41
|
-
expect { subject }.to change { yields.dup }.from([]).to([
|
39
|
+
context = double('Context')
|
40
|
+
expect(join).to receive(:restrict).and_yield(context)
|
41
|
+
expect { subject }.to change { yields.dup }.from([]).to([context])
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -6,22 +6,22 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#materialize' do
|
7
7
|
subject { object.materialize }
|
8
8
|
|
9
|
-
let(:header) {
|
10
|
-
let(:directions) {
|
11
|
-
let(:adapter) {
|
12
|
-
let(:relation) {
|
13
|
-
let!(:object) { described_class.new(adapter, relation)
|
14
|
-
let(:materialized) {
|
9
|
+
let(:header) { double('Header') }
|
10
|
+
let(:directions) { double('Directions') }
|
11
|
+
let(:adapter) { double.as_null_object }
|
12
|
+
let(:relation) { double('Relation', :header => header, :directions => directions, :materialized? => false) }
|
13
|
+
let!(:object) { described_class.new(adapter, relation) }
|
14
|
+
let(:materialized) { double('Materialized') }
|
15
15
|
|
16
16
|
before do
|
17
|
-
Relation::Materialized.
|
18
|
-
Relation.
|
17
|
+
allow(Relation::Materialized).to receive(:new).and_return(materialized)
|
18
|
+
allow(Relation).to receive(:new).and_return(double.as_null_object)
|
19
19
|
end
|
20
20
|
|
21
21
|
it { should equal(materialized) }
|
22
22
|
|
23
23
|
it 'initializes the materialized relation with the header, tuples and directions' do
|
24
|
-
Relation::Materialized.
|
24
|
+
expect(Relation::Materialized).to receive(:new).with(header, [], directions)
|
25
25
|
subject
|
26
26
|
end
|
27
27
|
end
|
@@ -6,18 +6,18 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#optimize' do
|
7
7
|
subject { object.optimize }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
9
|
+
let(:adapter) { double }
|
10
|
+
let(:relation) { double('Relation') }
|
11
11
|
let(:object) { described_class.new(adapter, relation) }
|
12
12
|
|
13
13
|
before do
|
14
|
-
relation.
|
14
|
+
allow(relation).to receive(:optimize).and_return(relation)
|
15
15
|
end
|
16
16
|
|
17
17
|
it_should_behave_like 'a command method'
|
18
18
|
|
19
19
|
it 'forwards the message to relation#optimize' do
|
20
|
-
relation.
|
20
|
+
expect(relation).to receive(:optimize).with(no_args)
|
21
21
|
subject
|
22
22
|
end
|
23
23
|
end
|
@@ -6,12 +6,12 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#product' do
|
7
7
|
subject { object.product(other) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation') }
|
11
11
|
let(:object) { described_class.new(adapter, relation) }
|
12
12
|
let(:operation) { :product }
|
13
13
|
let(:factory) { Algebra::Product }
|
14
|
-
let(:binary_relation) {
|
14
|
+
let(:binary_relation) { double(factory) }
|
15
15
|
|
16
16
|
it_should_behave_like 'a binary relation method'
|
17
17
|
end
|
@@ -6,16 +6,16 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#project' do
|
7
7
|
subject { object.project(args) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
11
|
-
let(:response) {
|
12
|
-
let!(:object) { described_class.new(adapter, relation)
|
13
|
-
let(:args) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation', project: response) }
|
11
|
+
let(:response) { double('New Relation', :kind_of? => true) }
|
12
|
+
let!(:object) { described_class.new(adapter, relation) }
|
13
|
+
let(:args) { double }
|
14
14
|
|
15
15
|
it_should_behave_like 'a unary relation method'
|
16
16
|
|
17
17
|
it 'forwards the arguments to relation#project' do
|
18
|
-
relation.
|
18
|
+
expect(relation).to receive(:project).with(args)
|
19
19
|
subject
|
20
20
|
end
|
21
21
|
end
|
@@ -6,16 +6,16 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#remove' do
|
7
7
|
subject { object.remove(args) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
11
|
-
let(:response) {
|
12
|
-
let!(:object) { described_class.new(adapter, relation)
|
13
|
-
let(:args) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation', remove: response) }
|
11
|
+
let(:response) { double('New Relation', :kind_of? => true) }
|
12
|
+
let!(:object) { described_class.new(adapter, relation) }
|
13
|
+
let(:args) { double }
|
14
14
|
|
15
15
|
it_should_behave_like 'a unary relation method'
|
16
16
|
|
17
17
|
it 'forwards the arguments to relation#remove' do
|
18
|
-
relation.
|
18
|
+
expect(relation).to receive(:remove).with(args)
|
19
19
|
subject
|
20
20
|
end
|
21
21
|
end
|
@@ -6,16 +6,16 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#rename' do
|
7
7
|
subject { object.rename(args) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
11
|
-
let(:response) {
|
12
|
-
let!(:object) { described_class.new(adapter, relation)
|
13
|
-
let(:args) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation', rename: response) }
|
11
|
+
let(:response) { double('New Relation', :kind_of? => true) }
|
12
|
+
let!(:object) { described_class.new(adapter, relation) }
|
13
|
+
let(:args) { double }
|
14
14
|
|
15
15
|
it_should_behave_like 'a unary relation method'
|
16
16
|
|
17
17
|
it 'forwards the arguments to relation#rename' do
|
18
|
-
relation.
|
18
|
+
expect(relation).to receive(:rename).with(args)
|
19
19
|
subject
|
20
20
|
end
|
21
21
|
end
|
@@ -6,8 +6,8 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#respond_to?' do
|
7
7
|
subject { object.respond_to?(method) }
|
8
8
|
|
9
|
-
let(:relation) {
|
10
|
-
let(:object) { described_class.new(
|
9
|
+
let(:relation) { double('Relation', header: double) }
|
10
|
+
let(:object) { described_class.new(double, relation) }
|
11
11
|
|
12
12
|
context 'with an unknown method' do
|
13
13
|
let(:method) { :unknown }
|
@@ -6,24 +6,22 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#restrict' do
|
7
7
|
subject { object.restrict(args, &block) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
11
|
-
let(:response) {
|
12
|
-
let!(:object) { described_class.new(adapter, relation)
|
13
|
-
let(:args) {
|
14
|
-
let(:block) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation', restrict: response) }
|
11
|
+
let(:response) { double('New Relation', :kind_of? => true) }
|
12
|
+
let!(:object) { described_class.new(adapter, relation) }
|
13
|
+
let(:args) { double }
|
14
|
+
let(:block) { ->(context) {} }
|
15
15
|
|
16
16
|
it_should_behave_like 'a unary relation method'
|
17
17
|
|
18
18
|
it 'forwards the arguments to relation#restrict' do
|
19
|
-
relation.
|
19
|
+
expect(relation).to receive(:restrict).with(args)
|
20
20
|
subject
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
subject
|
27
|
-
end
|
23
|
+
it 'forwards the block to relation#restrict' do
|
24
|
+
expect(relation).to receive(:restrict) { |_args, &proc| expect(proc).to equal(block) }
|
25
|
+
subject
|
28
26
|
end
|
29
27
|
end
|
@@ -6,16 +6,16 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#reverse' do
|
7
7
|
subject { object.reverse(args) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
11
|
-
let(:response) {
|
12
|
-
let!(:object) { described_class.new(adapter, relation)
|
13
|
-
let(:args) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation', reverse: response) }
|
11
|
+
let(:response) { double('New Relation', :kind_of? => true) }
|
12
|
+
let!(:object) { described_class.new(adapter, relation) }
|
13
|
+
let(:args) { double }
|
14
14
|
|
15
15
|
it_should_behave_like 'a unary relation method'
|
16
16
|
|
17
17
|
it 'forwards the arguments to relation#reverse' do
|
18
|
-
relation.
|
18
|
+
expect(relation).to receive(:reverse).with(args)
|
19
19
|
subject
|
20
20
|
end
|
21
21
|
end
|
@@ -6,24 +6,22 @@ require 'axiom/relation/gateway'
|
|
6
6
|
describe Relation::Gateway, '#sort_by' do
|
7
7
|
subject { object.sort_by(args, &block) }
|
8
8
|
|
9
|
-
let(:adapter) {
|
10
|
-
let(:relation) {
|
11
|
-
let(:response) {
|
12
|
-
let!(:object) { described_class.new(adapter, relation)
|
13
|
-
let(:args) {
|
14
|
-
let(:block) {
|
9
|
+
let(:adapter) { double('Adapter') }
|
10
|
+
let(:relation) { double('Relation', sort_by: response) }
|
11
|
+
let(:response) { double('New Relation', :kind_of? => true) }
|
12
|
+
let!(:object) { described_class.new(adapter, relation) }
|
13
|
+
let(:args) { double }
|
14
|
+
let(:block) { ->(context) {} }
|
15
15
|
|
16
16
|
it_should_behave_like 'a unary relation method'
|
17
17
|
|
18
18
|
it 'forwards the arguments to relation#sort_by' do
|
19
|
-
relation.
|
19
|
+
expect(relation).to receive(:sort_by).with(args)
|
20
20
|
subject
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
subject
|
27
|
-
end
|
23
|
+
it 'forwards the block to relation#sort_by' do
|
24
|
+
expect(relation).to receive(:sort_by) { |&proc| expect(proc).to equal(block) }
|
25
|
+
subject
|
28
26
|
end
|
29
27
|
end
|
@@ -4,41 +4,39 @@ require 'spec_helper'
|
|
4
4
|
require 'axiom/relation/gateway'
|
5
5
|
|
6
6
|
describe Relation::Gateway, '#summarize' do
|
7
|
-
let(:summarization) {
|
8
|
-
let(:adapter) {
|
9
|
-
let(:relation) {
|
10
|
-
let!(:object) { described_class.new(adapter, relation)
|
11
|
-
let(:block) {
|
7
|
+
let(:summarization) { double('Summarization', :kind_of? => true) }
|
8
|
+
let(:adapter) { double('Adapter') }
|
9
|
+
let(:relation) { double('Relation', summarize: summarization) }
|
10
|
+
let!(:object) { described_class.new(adapter, relation) }
|
11
|
+
let(:block) { ->(context) {} }
|
12
12
|
|
13
13
|
context 'with no arguments' do
|
14
14
|
subject { object.summarize(&block) }
|
15
15
|
|
16
|
-
let(:gateway) {
|
16
|
+
let(:gateway) { double('New Gateway') }
|
17
17
|
|
18
18
|
before do
|
19
|
-
described_class.
|
19
|
+
allow(described_class).to receive(:new).and_return(gateway)
|
20
20
|
end
|
21
21
|
|
22
22
|
it { should equal(gateway) }
|
23
23
|
|
24
24
|
it 'forwards the default summarize_with relation to relation#summarize' do
|
25
|
-
relation.
|
26
|
-
other.
|
25
|
+
expect(relation).to receive(:summarize) do |other|
|
26
|
+
expect(other).to equal(TABLE_DEE)
|
27
27
|
end
|
28
28
|
subject
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
proc.should equal(block)
|
35
|
-
end
|
36
|
-
subject
|
31
|
+
it 'forwards the block to relation#summarize' do
|
32
|
+
expect(relation).to receive(:summarize) do |_summarize_with, &proc|
|
33
|
+
expect(proc).to equal(block)
|
37
34
|
end
|
35
|
+
subject
|
38
36
|
end
|
39
37
|
|
40
38
|
it 'initializes the gateway with the adapter and summarization' do
|
41
|
-
described_class.
|
39
|
+
expect(described_class).to receive(:new).with(adapter, summarization)
|
42
40
|
subject
|
43
41
|
end
|
44
42
|
end
|
@@ -46,33 +44,31 @@ describe Relation::Gateway, '#summarize' do
|
|
46
44
|
context 'with a header' do
|
47
45
|
subject { object.summarize(header, &block) }
|
48
46
|
|
49
|
-
let(:gateway) {
|
50
|
-
let(:header) {
|
47
|
+
let(:gateway) { double('New Gateway') }
|
48
|
+
let(:header) { double('Header') }
|
51
49
|
|
52
50
|
before do
|
53
|
-
described_class.
|
51
|
+
allow(described_class).to receive(:new).and_return(gateway)
|
54
52
|
end
|
55
53
|
|
56
54
|
it { should equal(gateway) }
|
57
55
|
|
58
56
|
it 'forwards the header to relation#summarize' do
|
59
|
-
relation.
|
60
|
-
other.
|
57
|
+
expect(relation).to receive(:summarize) do |other|
|
58
|
+
expect(other).to equal(header)
|
61
59
|
end
|
62
60
|
subject
|
63
61
|
end
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
proc.should equal(block)
|
69
|
-
end
|
70
|
-
subject
|
63
|
+
it 'forwards the block to relation#summarize' do
|
64
|
+
expect(relation).to receive(:summarize) do |_summarize_with, &proc|
|
65
|
+
expect(proc).to equal(block)
|
71
66
|
end
|
67
|
+
subject
|
72
68
|
end
|
73
69
|
|
74
70
|
it 'initializes the gateway with the adapter and summarization' do
|
75
|
-
described_class.
|
71
|
+
expect(described_class).to receive(:new).with(adapter, summarization)
|
76
72
|
subject
|
77
73
|
end
|
78
74
|
end
|
@@ -80,35 +76,33 @@ describe Relation::Gateway, '#summarize' do
|
|
80
76
|
context 'when summarize_with has the same adapter' do
|
81
77
|
subject { object.summarize(other, &block) }
|
82
78
|
|
83
|
-
let(:header) {
|
84
|
-
let(:other_relation) {
|
79
|
+
let(:header) { double('Header') }
|
80
|
+
let(:other_relation) { double('Other Relation', header: header) }
|
85
81
|
let!(:other) { described_class.new(adapter, other_relation) }
|
86
|
-
let(:gateway) {
|
82
|
+
let(:gateway) { double('New Gateway') }
|
87
83
|
|
88
84
|
before do
|
89
|
-
described_class.
|
85
|
+
allow(described_class).to receive(:new).and_return(gateway)
|
90
86
|
end
|
91
87
|
|
92
88
|
it { should equal(gateway) }
|
93
89
|
|
94
90
|
it 'forwards the other relation to relation#summarize' do
|
95
|
-
relation.
|
96
|
-
other.
|
91
|
+
expect(relation).to receive(:summarize) do |other|
|
92
|
+
expect(other).to equal(other_relation)
|
97
93
|
end
|
98
94
|
subject
|
99
95
|
end
|
100
96
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
proc.should equal(block)
|
105
|
-
end
|
106
|
-
subject
|
97
|
+
it 'forwards the block to relation#summarize' do
|
98
|
+
expect(relation).to receive(:summarize) do |&proc|
|
99
|
+
expect(proc).to equal(block)
|
107
100
|
end
|
101
|
+
subject
|
108
102
|
end
|
109
103
|
|
110
104
|
it 'initializes the gateway with the adapter and summarization' do
|
111
|
-
described_class.
|
105
|
+
expect(described_class).to receive(:new).with(adapter, summarization)
|
112
106
|
subject
|
113
107
|
end
|
114
108
|
end
|
@@ -116,38 +110,38 @@ describe Relation::Gateway, '#summarize' do
|
|
116
110
|
context 'with a relation' do
|
117
111
|
subject { object.summarize(summarize_with, &block) }
|
118
112
|
|
119
|
-
let(:context_header) {
|
120
|
-
let(:header) {
|
121
|
-
let(:summarize_header) {
|
122
|
-
let(:summarize_with) {
|
123
|
-
let(:functions) {
|
124
|
-
let(:context) {
|
113
|
+
let(:context_header) { double('Context Header') }
|
114
|
+
let(:header) { double('Header', :- => context_header) }
|
115
|
+
let(:summarize_header) { double('Summarize With Header') }
|
116
|
+
let(:summarize_with) { double('Other Relation', header: summarize_header) }
|
117
|
+
let(:functions) { double('Functions') }
|
118
|
+
let(:context) { double('Context', functions: functions) }
|
125
119
|
|
126
120
|
before do
|
127
|
-
relation.
|
128
|
-
Algebra::Summarization.
|
129
|
-
Evaluator::Context.
|
121
|
+
allow(relation).to receive(:header).and_return(header)
|
122
|
+
allow(Algebra::Summarization).to receive(:new).and_return(summarization)
|
123
|
+
allow(Evaluator::Context).to receive(:new).and_return(context)
|
130
124
|
end
|
131
125
|
|
132
126
|
it { should equal(summarization) }
|
133
127
|
|
134
128
|
it 'gets the context header' do
|
135
|
-
header.
|
129
|
+
expect(header).to receive(:-).with(summarize_header)
|
136
130
|
subject
|
137
131
|
end
|
138
132
|
|
139
133
|
it 'passes the context header into the context' do
|
140
|
-
Evaluator::Context.
|
134
|
+
expect(Evaluator::Context).to receive(:new).with(context_header)
|
141
135
|
subject
|
142
136
|
end
|
143
137
|
|
144
138
|
it 'forwards the block to the context' do
|
145
|
-
Evaluator::Context.
|
139
|
+
allow(Evaluator::Context).to receive(:new) { |&proc| expect(proc).to equal(block) }.and_return(context)
|
146
140
|
subject
|
147
141
|
end
|
148
142
|
|
149
143
|
it 'initializes the summarization with the gateway, the relation and the functions' do
|
150
|
-
Algebra::Summarization.
|
144
|
+
expect(Algebra::Summarization).to receive(:new).with(object, summarize_with, functions)
|
151
145
|
subject
|
152
146
|
end
|
153
147
|
end
|