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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/.ruby-gemset +1 -0
  4. data/.travis.yml +17 -23
  5. data/CONTRIBUTING.md +1 -2
  6. data/Gemfile +10 -5
  7. data/Gemfile.devtools +39 -27
  8. data/README.md +3 -6
  9. data/axiom-do-adapter.gemspec +5 -7
  10. data/config/devtools.yml +2 -0
  11. data/config/reek.yml +2 -7
  12. data/config/rubocop.yml +59 -0
  13. data/lib/axiom/adapter/data_objects/statement.rb +4 -7
  14. data/lib/axiom/adapter/data_objects/version.rb +1 -1
  15. data/lib/axiom/relation/gateway.rb +3 -3
  16. data/spec/shared/binary_relation_method_behaviour.rb +11 -11
  17. data/spec/shared/unary_relation_method_behaviour.rb +4 -4
  18. data/spec/spec_helper.rb +13 -18
  19. data/spec/support/config_alias.rb +2 -0
  20. data/spec/unit/axiom/adapter/data_objects/class_methods/new_spec.rb +1 -1
  21. data/spec/unit/axiom/adapter/data_objects/read_spec.rb +14 -18
  22. data/spec/unit/axiom/adapter/data_objects/statement/class_methods/new_spec.rb +3 -3
  23. data/spec/unit/axiom/adapter/data_objects/statement/each_spec.rb +23 -24
  24. data/spec/unit/axiom/adapter/data_objects/statement/to_s_spec.rb +9 -9
  25. data/spec/unit/axiom/relation/gateway/class_methods/new_spec.rb +2 -2
  26. data/spec/unit/axiom/relation/gateway/difference_spec.rb +3 -3
  27. data/spec/unit/axiom/relation/gateway/drop_spec.rb +6 -6
  28. data/spec/unit/axiom/relation/gateway/each_spec.rb +19 -23
  29. data/spec/unit/axiom/relation/gateway/extend_spec.rb +10 -12
  30. data/spec/unit/axiom/relation/gateway/intersect_spec.rb +3 -3
  31. data/spec/unit/axiom/relation/gateway/join_spec.rb +11 -11
  32. data/spec/unit/axiom/relation/gateway/materialize_spec.rb +9 -9
  33. data/spec/unit/axiom/relation/gateway/optimize_spec.rb +4 -4
  34. data/spec/unit/axiom/relation/gateway/product_spec.rb +3 -3
  35. data/spec/unit/axiom/relation/gateway/project_spec.rb +6 -6
  36. data/spec/unit/axiom/relation/gateway/remove_spec.rb +6 -6
  37. data/spec/unit/axiom/relation/gateway/rename_spec.rb +6 -6
  38. data/spec/unit/axiom/relation/gateway/respond_to_spec.rb +2 -2
  39. data/spec/unit/axiom/relation/gateway/restrict_spec.rb +10 -12
  40. data/spec/unit/axiom/relation/gateway/reverse_spec.rb +6 -6
  41. data/spec/unit/axiom/relation/gateway/sort_by_spec.rb +10 -12
  42. data/spec/unit/axiom/relation/gateway/summarize_spec.rb +48 -54
  43. data/spec/unit/axiom/relation/gateway/take_spec.rb +6 -6
  44. data/spec/unit/axiom/relation/gateway/union_spec.rb +3 -3
  45. metadata +23 -44
  46. data/.rvmrc +0 -1
  47. data/spec/support/example_group_methods.rb +0 -7
  48. 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) { mock('Adapter') }
10
- let(:relation) { mock('Relation', :extend => response) }
11
- let(:response) { mock('New Relation', :kind_of? => true) }
12
- let!(:object) { described_class.new(adapter, relation) }
13
- let(:args) { stub }
14
- let(:block) { lambda { |context| } }
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.should_receive(:extend).with(args)
19
+ expect(relation).to receive(:extend).with(args)
20
20
  subject
21
21
  end
22
22
 
23
- unless testing_block_passing_broken?
24
- it 'forwards the block to relation#extend' do
25
- relation.should_receive(:extend) { |&proc| proc.should equal(block) }
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) { mock('Adapter') }
10
- let(:relation) { mock('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) { mock(factory) }
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) { mock('Adapter') }
10
- let(:relation) { mock('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) { mock(factory) }
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) { mock('Other Relation') }
21
+ let(:other_relation) { double('Other Relation') }
22
22
  let(:other) { described_class.new(adapter, other_relation) }
23
- let(:gateway) { mock('Other Gateway') }
24
- let(:join) { mock('Join', :restrict => gateway) }
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.stub!(:new).with(relation, other_relation).and_return(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.should_receive(:new).with(relation, other_relation)
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 = mock('Context')
40
- join.should_receive(:restrict).and_yield(context)
41
- expect { subject }.to change { yields.dup }.from([]).to([ context ])
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) { mock('Header') }
10
- let(:directions) { mock('Directions') }
11
- let(:adapter) { stub.as_null_object }
12
- let(:relation) { mock('Relation', :header => header, :directions => directions, :materialized? => false) }
13
- let!(:object) { described_class.new(adapter, relation) }
14
- let(:materialized) { mock('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.stub!(:new).and_return(materialized)
18
- Relation.stub!(:new).and_return(stub.as_null_object)
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.should_receive(:new).with(header, [], directions)
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) { stub }
10
- let(:relation) { mock('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.stub!(:optimize).and_return(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.should_receive(:optimize).with(no_args)
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) { mock('Adapter') }
10
- let(:relation) { mock('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) { mock(factory) }
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) { mock('Adapter') }
10
- let(:relation) { mock('Relation', :project => response) }
11
- let(:response) { mock('New Relation', :kind_of? => true) }
12
- let!(:object) { described_class.new(adapter, relation) }
13
- let(:args) { stub }
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.should_receive(:project).with(args)
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) { mock('Adapter') }
10
- let(:relation) { mock('Relation', :remove => response) }
11
- let(:response) { mock('New Relation', :kind_of? => true) }
12
- let!(:object) { described_class.new(adapter, relation) }
13
- let(:args) { stub }
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.should_receive(:remove).with(args)
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) { mock('Adapter') }
10
- let(:relation) { mock('Relation', :rename => response) }
11
- let(:response) { mock('New Relation', :kind_of? => true) }
12
- let!(:object) { described_class.new(adapter, relation) }
13
- let(:args) { stub }
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.should_receive(:rename).with(args)
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) { mock('Relation', :header => stub) }
10
- let(:object) { described_class.new(stub, relation) }
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) { mock('Adapter') }
10
- let(:relation) { mock('Relation', :restrict => response) }
11
- let(:response) { mock('New Relation', :kind_of? => true) }
12
- let!(:object) { described_class.new(adapter, relation) }
13
- let(:args) { stub }
14
- let(:block) { lambda { |context| } }
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.should_receive(:restrict).with(args)
19
+ expect(relation).to receive(:restrict).with(args)
20
20
  subject
21
21
  end
22
22
 
23
- unless testing_block_passing_broken?
24
- it 'forwards the block to relation#restrict' do
25
- relation.should_receive(:restrict) { |_args, &proc| proc.should equal(block) }
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) { mock('Adapter') }
10
- let(:relation) { mock('Relation', :reverse => response) }
11
- let(:response) { mock('New Relation', :kind_of? => true) }
12
- let!(:object) { described_class.new(adapter, relation) }
13
- let(:args) { stub }
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.should_receive(:reverse).with(args)
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) { mock('Adapter') }
10
- let(:relation) { mock('Relation', :sort_by => response) }
11
- let(:response) { mock('New Relation', :kind_of? => true) }
12
- let!(:object) { described_class.new(adapter, relation) }
13
- let(:args) { stub }
14
- let(:block) { lambda { |context| } }
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.should_receive(:sort_by).with(args)
19
+ expect(relation).to receive(:sort_by).with(args)
20
20
  subject
21
21
  end
22
22
 
23
- unless testing_block_passing_broken?
24
- it 'forwards the block to relation#sort_by' do
25
- relation.should_receive(:sort_by) { |&proc| proc.should equal(block) }
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) { mock('Summarization', :kind_of? => true) }
8
- let(:adapter) { mock('Adapter') }
9
- let(:relation) { mock('Relation', :summarize => summarization) }
10
- let!(:object) { described_class.new(adapter, relation) }
11
- let(:block) { lambda { |context| } }
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) { mock('New Gateway') }
16
+ let(:gateway) { double('New Gateway') }
17
17
 
18
18
  before do
19
- described_class.stub!(:new).and_return(gateway)
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.should_receive(:summarize) do |other|
26
- other.should equal(TABLE_DEE)
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
- unless testing_block_passing_broken?
32
- it 'forwards the block to relation#summarize' do
33
- relation.should_receive(:summarize) do |_summarize_with, &proc|
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.should_receive(:new).with(adapter, summarization)
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) { mock('New Gateway') }
50
- let(:header) { mock('Header') }
47
+ let(:gateway) { double('New Gateway') }
48
+ let(:header) { double('Header') }
51
49
 
52
50
  before do
53
- described_class.stub!(:new).and_return(gateway)
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.should_receive(:summarize) do |other|
60
- other.should equal(header)
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
- unless testing_block_passing_broken?
66
- it 'forwards the block to relation#summarize' do
67
- relation.should_receive(:summarize) do |_summarize_with, &proc|
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.should_receive(:new).with(adapter, summarization)
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) { mock('Header') }
84
- let(:other_relation) { mock('Other Relation', :header => header) }
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) { mock('New Gateway') }
82
+ let(:gateway) { double('New Gateway') }
87
83
 
88
84
  before do
89
- described_class.stub!(:new).and_return(gateway)
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.should_receive(:summarize) do |other|
96
- other.should equal(other_relation)
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
- unless testing_block_passing_broken?
102
- it 'forwards the block to relation#summarize' do
103
- relation.should_receive(:summarize) do |_summarize_with, &proc|
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.should_receive(:new).with(adapter, summarization)
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) { mock('Context Header') }
120
- let(:header) { mock('Header', :- => context_header) }
121
- let(:summarize_header) { mock('Summarize With Header') }
122
- let(:summarize_with) { mock('Other Relation', :header => summarize_header) }
123
- let(:functions) { mock('Functions') }
124
- let(:context) { mock('Context', :functions => functions) }
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.stub!(:header).and_return(header)
128
- Algebra::Summarization.stub!(:new).and_return(summarization)
129
- Evaluator::Context.stub!(:new).and_return(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.should_receive(:-).with(summarize_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.should_receive(:new).with(context_header)
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.stub!(:new) { |_header, proc| proc.should equal(block) }.and_return(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.should_receive(:new).with(object, summarize_with, functions)
144
+ expect(Algebra::Summarization).to receive(:new).with(object, summarize_with, functions)
151
145
  subject
152
146
  end
153
147
  end