rom 0.5.0 → 0.6.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +19 -15
  3. data/.rubocop_todo.yml +28 -0
  4. data/.travis.yml +8 -1
  5. data/CHANGELOG.md +40 -0
  6. data/Gemfile +10 -2
  7. data/Guardfile +12 -10
  8. data/README.md +42 -43
  9. data/Rakefile +13 -23
  10. data/lib/rom.rb +19 -27
  11. data/lib/rom/command.rb +118 -0
  12. data/lib/rom/command_registry.rb +13 -27
  13. data/lib/rom/commands.rb +1 -59
  14. data/lib/rom/commands/abstract.rb +147 -0
  15. data/lib/rom/commands/composite.rb +47 -0
  16. data/lib/rom/commands/create.rb +2 -17
  17. data/lib/rom/commands/delete.rb +5 -25
  18. data/lib/rom/commands/result.rb +5 -5
  19. data/lib/rom/commands/update.rb +3 -27
  20. data/lib/rom/constants.rb +19 -0
  21. data/lib/rom/env.rb +85 -35
  22. data/lib/rom/global.rb +173 -42
  23. data/lib/rom/header.rb +5 -5
  24. data/lib/rom/header/attribute.rb +2 -2
  25. data/lib/rom/lint/enumerable_dataset.rb +52 -0
  26. data/lib/rom/lint/linter.rb +64 -0
  27. data/lib/rom/lint/repository.rb +78 -0
  28. data/lib/rom/lint/spec.rb +20 -0
  29. data/lib/rom/lint/test.rb +98 -0
  30. data/lib/rom/mapper.rb +32 -5
  31. data/lib/rom/mapper/attribute_dsl.rb +240 -0
  32. data/lib/rom/mapper/dsl.rb +100 -0
  33. data/lib/rom/mapper/model_dsl.rb +55 -0
  34. data/lib/rom/mapper_registry.rb +8 -1
  35. data/lib/rom/memory.rb +4 -0
  36. data/lib/rom/memory/commands.rb +46 -0
  37. data/lib/rom/memory/dataset.rb +72 -0
  38. data/lib/rom/memory/relation.rb +44 -0
  39. data/lib/rom/memory/repository.rb +62 -0
  40. data/lib/rom/memory/storage.rb +57 -0
  41. data/lib/rom/model_builder.rb +44 -5
  42. data/lib/rom/processor.rb +1 -1
  43. data/lib/rom/processor/transproc.rb +109 -16
  44. data/lib/rom/reader.rb +91 -39
  45. data/lib/rom/relation.rb +165 -26
  46. data/lib/rom/relation/composite.rb +132 -0
  47. data/lib/rom/relation/curried.rb +48 -0
  48. data/lib/rom/relation/lazy.rb +173 -0
  49. data/lib/rom/relation/loaded.rb +75 -0
  50. data/lib/rom/relation/registry_reader.rb +23 -0
  51. data/lib/rom/repository.rb +93 -34
  52. data/lib/rom/setup.rb +54 -98
  53. data/lib/rom/setup/finalize.rb +85 -76
  54. data/lib/rom/setup_dsl/command.rb +36 -0
  55. data/lib/rom/setup_dsl/command_dsl.rb +34 -0
  56. data/lib/rom/setup_dsl/mapper.rb +32 -0
  57. data/lib/rom/setup_dsl/mapper_dsl.rb +30 -0
  58. data/lib/rom/setup_dsl/relation.rb +21 -0
  59. data/lib/rom/setup_dsl/setup.rb +75 -0
  60. data/lib/rom/support/array_dataset.rb +38 -0
  61. data/lib/rom/support/class_builder.rb +44 -0
  62. data/lib/rom/support/class_macros.rb +56 -0
  63. data/lib/rom/support/data_proxy.rb +102 -0
  64. data/lib/rom/support/enumerable_dataset.rb +58 -0
  65. data/lib/rom/support/inflector.rb +73 -0
  66. data/lib/rom/support/options.rb +188 -0
  67. data/lib/rom/support/registry.rb +4 -8
  68. data/lib/rom/version.rb +1 -1
  69. data/rakelib/benchmark.rake +13 -0
  70. data/rakelib/mutant.rake +16 -0
  71. data/rakelib/rubocop.rake +18 -0
  72. data/rom.gemspec +4 -7
  73. data/spec/integration/commands/create_spec.rb +32 -24
  74. data/spec/integration/commands/delete_spec.rb +15 -7
  75. data/spec/integration/commands/update_spec.rb +13 -11
  76. data/spec/integration/mappers/deep_embedded_spec.rb +4 -11
  77. data/spec/integration/mappers/definition_dsl_spec.rb +31 -44
  78. data/spec/integration/mappers/embedded_spec.rb +9 -24
  79. data/spec/integration/mappers/group_spec.rb +22 -30
  80. data/spec/integration/mappers/prefixing_attributes_spec.rb +18 -23
  81. data/spec/integration/mappers/renaming_attributes_spec.rb +23 -38
  82. data/spec/integration/mappers/symbolizing_attributes_spec.rb +18 -24
  83. data/spec/integration/mappers/wrap_spec.rb +22 -30
  84. data/spec/integration/multi_repo_spec.rb +15 -37
  85. data/spec/integration/relations/reading_spec.rb +82 -14
  86. data/spec/integration/repositories/extending_relations_spec.rb +50 -0
  87. data/spec/integration/{adapters → repositories}/setting_logger_spec.rb +6 -5
  88. data/spec/integration/setup_spec.rb +59 -62
  89. data/spec/shared/enumerable_dataset.rb +49 -0
  90. data/spec/shared/one_behavior.rb +26 -0
  91. data/spec/shared/users_and_tasks.rb +11 -23
  92. data/spec/spec_helper.rb +16 -7
  93. data/spec/support/constant_leak_finder.rb +14 -0
  94. data/spec/test/memory_repository_lint_test.rb +27 -0
  95. data/spec/unit/rom/command_registry_spec.rb +44 -0
  96. data/spec/unit/rom/commands/result_spec.rb +14 -0
  97. data/spec/unit/rom/commands_spec.rb +174 -0
  98. data/spec/unit/rom/env_spec.rb +40 -7
  99. data/spec/unit/rom/global_spec.rb +14 -0
  100. data/spec/unit/rom/{mapper_builder_spec.rb → mapper/dsl_spec.rb} +52 -38
  101. data/spec/unit/rom/mapper_spec.rb +51 -10
  102. data/spec/unit/rom/{adapter/memory → memory}/dataset_spec.rb +6 -4
  103. data/spec/unit/rom/memory/repository_spec.rb +12 -0
  104. data/spec/unit/rom/memory/storage_spec.rb +45 -0
  105. data/spec/unit/rom/model_builder_spec.rb +4 -3
  106. data/spec/unit/rom/processor/transproc_spec.rb +1 -0
  107. data/spec/unit/rom/reader_spec.rb +97 -24
  108. data/spec/unit/rom/relation/composite_spec.rb +65 -0
  109. data/spec/unit/rom/relation/lazy_spec.rb +145 -0
  110. data/spec/unit/rom/relation/loaded_spec.rb +28 -0
  111. data/spec/unit/rom/relation_spec.rb +111 -6
  112. data/spec/unit/rom/repository_spec.rb +59 -9
  113. data/spec/unit/rom/setup_spec.rb +99 -11
  114. data/spec/unit/rom/support/array_dataset_spec.rb +59 -0
  115. data/spec/unit/rom/support/class_builder_spec.rb +42 -0
  116. data/spec/unit/rom/support/enumerable_dataset_spec.rb +17 -0
  117. data/spec/unit/rom/support/inflector_spec.rb +89 -0
  118. data/spec/unit/rom/support/options_spec.rb +119 -0
  119. metadata +74 -112
  120. data/lib/rom/adapter.rb +0 -191
  121. data/lib/rom/adapter/memory.rb +0 -32
  122. data/lib/rom/adapter/memory/commands.rb +0 -31
  123. data/lib/rom/adapter/memory/dataset.rb +0 -67
  124. data/lib/rom/adapter/memory/storage.rb +0 -26
  125. data/lib/rom/commands/with_options.rb +0 -18
  126. data/lib/rom/config.rb +0 -70
  127. data/lib/rom/mapper_builder.rb +0 -52
  128. data/lib/rom/mapper_builder/mapper_dsl.rb +0 -114
  129. data/lib/rom/mapper_builder/model_dsl.rb +0 -29
  130. data/lib/rom/reader_builder.rb +0 -48
  131. data/lib/rom/relation_builder.rb +0 -62
  132. data/lib/rom/setup/base_relation_dsl.rb +0 -46
  133. data/lib/rom/setup/command_dsl.rb +0 -46
  134. data/lib/rom/setup/mapper_dsl.rb +0 -19
  135. data/lib/rom/setup/relation_dsl.rb +0 -20
  136. data/lib/rom/setup/schema_dsl.rb +0 -33
  137. data/spec/integration/adapters/extending_relations_spec.rb +0 -41
  138. data/spec/integration/commands/try_spec.rb +0 -27
  139. data/spec/integration/schema_spec.rb +0 -77
  140. data/spec/unit/config_spec.rb +0 -60
  141. data/spec/unit/rom/adapter_spec.rb +0 -79
  142. data/spec/unit/rom_spec.rb +0 -14
@@ -0,0 +1,174 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Commands' do
4
+ include_context 'users and tasks'
5
+
6
+ let(:users) { rom.relations.users }
7
+
8
+ before do
9
+ setup.relation(:users) do
10
+ def by_id(id)
11
+ restrict(id: id)
12
+ end
13
+ end
14
+ end
15
+
16
+ describe '.build_class' do
17
+ it 'creates a command class constant' do
18
+ klass = ROM::Command.build_class(:create, :users, adapter: :memory) do
19
+ def super?
20
+ true
21
+ end
22
+ end
23
+
24
+ expect(klass.name).to eql('ROM::Memory::Commands::Create[Users]')
25
+ expect(klass.register_as).to eql(:create)
26
+
27
+ command = klass.build(rom.relations.users)
28
+
29
+ expect(command).to be_a(ROM::Memory::Commands::Create)
30
+ expect(command).to be_super
31
+ end
32
+ end
33
+
34
+ describe '.build' do
35
+ it 'returns create command when type is set to :create' do
36
+ klass = Class.new(ROM::Commands::Create[:memory]) do
37
+ relation :users
38
+ end
39
+
40
+ command = klass.build(users)
41
+
42
+ expect(command).to be_kind_of(ROM::Memory::Commands::Create)
43
+ end
44
+
45
+ it 'returns update command when type is set to :update' do
46
+ klass = Class.new(ROM::Commands::Update[:memory]) do
47
+ relation :users
48
+ end
49
+
50
+ command = klass.build(users)
51
+
52
+ expect(command).to be_kind_of(ROM::Memory::Commands::Update)
53
+ end
54
+
55
+ it 'returns delete command when type is set to :delete' do
56
+ klass = Class.new(ROM::Commands::Delete[:memory]) do
57
+ relation :users
58
+ end
59
+
60
+ command = klass.build(users)
61
+
62
+ expect(command).to be_kind_of(ROM::Memory::Commands::Delete)
63
+ end
64
+
65
+ describe 'extending command with a db-specific behavior' do
66
+ before do
67
+ setup.repositories[:default].instance_exec do
68
+ def extend_command_class(klass, _)
69
+ klass.class_eval do
70
+ def super_command?
71
+ true
72
+ end
73
+ end
74
+ klass
75
+ end
76
+ end
77
+ end
78
+
79
+ it 'applies to defined classes' do
80
+ klass = Class.new(ROM::Commands::Create[:memory]) { relation :users }
81
+ command = klass.build(users)
82
+ expect(command).to be_super_command
83
+ end
84
+
85
+ it 'applies to generated classes' do
86
+ klass = ROM::Command.build_class(:create, :users, adapter: :memory)
87
+ command = klass.build(users)
88
+ expect(command).to be_super_command
89
+ end
90
+ end
91
+ end
92
+
93
+ describe '.registry' do
94
+ it 'builds a hash with commands grouped by relations' do
95
+ commands = {}
96
+
97
+ [:Create, :Update, :Delete].each do |command_type|
98
+ klass = Class.new(ROM::Commands.const_get(command_type)) do
99
+ relation :users
100
+ end
101
+ klass.class_eval "def self.name; 'Test::#{command_type}'; end"
102
+ commands[command_type] = klass
103
+ end
104
+
105
+ registry = ROM::Command.registry(
106
+ rom.relations, setup.repositories, commands.values
107
+ )
108
+
109
+ expect(registry).to eql(
110
+ users: {
111
+ create: commands[:Create].build(users),
112
+ update: commands[:Update].build(users),
113
+ delete: commands[:Delete].build(users)
114
+ }
115
+ )
116
+ end
117
+ end
118
+
119
+ describe '#>>' do
120
+ let(:users) { double('users') }
121
+ let(:tasks) { double('tasks') }
122
+ let(:logs) { [] }
123
+
124
+ it 'composes two commands' do
125
+ user_input = { name: 'Jane' }
126
+ user_tuple = { user_id: 1, name: 'Jane' }
127
+
128
+ task_input = { title: 'Task One' }
129
+ task_tuple = { user_id: 1, title: 'Task One' }
130
+
131
+ create_user = Class.new(ROM::Commands::Create) {
132
+ def execute(user_input)
133
+ relation.insert(user_input)
134
+ end
135
+ }.build(users)
136
+
137
+ create_task = Class.new(ROM::Commands::Create) {
138
+ def execute(user_tuple, task_input)
139
+ relation.insert(task_input.merge(user_id: user_tuple[:user_id]))
140
+ end
141
+ }.build(tasks)
142
+
143
+ create_log = Class.new(ROM::Commands::Create) {
144
+ result :one
145
+
146
+ def execute(task_tuple)
147
+ relation << task_tuple
148
+ end
149
+ }.build(logs)
150
+
151
+ command = create_user.curry(user_input)
152
+ command >>= create_task.curry(task_input)
153
+ command >>= create_log
154
+
155
+ expect(users).to receive(:insert).with(user_input).and_return(user_tuple)
156
+ expect(tasks).to receive(:insert).with(task_tuple).and_return(task_tuple)
157
+
158
+ result = command.call
159
+
160
+ expect(result).to eql(task_tuple)
161
+ expect(logs).to include(task_tuple)
162
+ end
163
+ end
164
+
165
+ describe 'access to exposed relations' do
166
+ it 'exposes relation' do
167
+ command = ROM::Commands::Update[:memory].build(users)
168
+
169
+ users.insert(id: 1, name: 'Jane')
170
+
171
+ expect(command.by_id(1).relation).to eql(users.by_id(1))
172
+ end
173
+ end
174
+ end
@@ -3,17 +3,50 @@ require 'spec_helper'
3
3
  describe ROM::Env do
4
4
  include_context 'users and tasks'
5
5
 
6
- before { setup.relation(:users) }
6
+ before do
7
+ setup.relation(:users) do
8
+ def by_name(name)
9
+ restrict(name: name).project(:name)
10
+ end
11
+ end
7
12
 
8
- it 'exposes repositories on method-missing' do
9
- expect(rom.memory).to be(rom.repositories[:memory])
13
+ setup.relation(:tasks)
14
+
15
+ setup.mappers do
16
+ define(:users) do
17
+ attribute :name
18
+ attribute :email
19
+ end
20
+
21
+ define(:name_list, parent: :users) do
22
+ attribute :name
23
+ exclude :email
24
+ end
25
+ end
10
26
  end
11
27
 
12
- it 'responds to methods corresponding to repository names' do
13
- expect(rom).to respond_to(:memory)
28
+ describe '#relation' do
29
+ it 'yields selected relation to the block and returns a loaded relation' do
30
+ result = rom.relation(:users) { |r| r.by_name('Jane') }.as(:name_list)
31
+
32
+ expect(result.call).to match_array([{ name: 'Jane' }])
33
+ end
34
+
35
+ it 'returns lazy-mapped relation' do
36
+ by_name = rom.relation(:users).as(:name_list).by_name
37
+
38
+ expect(by_name['Jane']).to match_array([{ name: 'Jane' }])
39
+ end
40
+
41
+ it 'returns lazy relation without mappers when mappers are not defined' do
42
+ expect(rom.relation(:tasks)).to be_instance_of(ROM::Relation::Lazy)
43
+ expect(rom.relation(:tasks).relation).to be(rom.relations.tasks)
44
+ end
14
45
  end
15
46
 
16
- it 'raises exception when unknown repository is referenced' do
17
- expect { rom.not_here }.to raise_error(NoMethodError)
47
+ describe '#mappers' do
48
+ it 'returns mappers for all relations' do
49
+ expect(rom.mappers.users).to eql(rom.readers.users.mappers)
50
+ end
18
51
  end
19
52
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe ROM do
4
+ describe '.setup' do
5
+ it 'allows passing in repository instances' do
6
+ klass = Class.new(ROM::Repository)
7
+ repo = klass.new
8
+
9
+ setup = ROM.setup(test: repo)
10
+
11
+ expect(setup.repositories[:test]).to be(repo)
12
+ end
13
+ end
14
+ end
@@ -1,12 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ROM::MapperBuilder do
4
- subject(:builder) { ROM::MapperBuilder.new(:users, relation, options) }
3
+ describe ROM::Mapper do
4
+ subject(:mapper) do
5
+ klass = Class.new(parent)
6
+ options.each { |k, v| klass.send(k, v) }
7
+ klass
8
+ end
9
+
10
+ let(:parent) { Class.new(ROM::Mapper) }
5
11
 
6
12
  let(:options) { {} }
7
- let(:relation) { double('relation', header: []) }
8
13
  let(:header) { mapper.header }
9
- let(:mapper) { builder.call }
10
14
 
11
15
  let(:expected_header) { ROM::Header.coerce(attributes) }
12
16
 
@@ -15,7 +19,7 @@ describe ROM::MapperBuilder do
15
19
  let(:attributes) { [[:name]] }
16
20
 
17
21
  it 'adds an attribute for the header' do
18
- builder.attribute :name
22
+ mapper.attribute :name
19
23
 
20
24
  expect(header).to eql(expected_header)
21
25
  end
@@ -25,7 +29,7 @@ describe ROM::MapperBuilder do
25
29
  let(:attributes) { [[:name, from: :user_name]] }
26
30
 
27
31
  it 'adds an aliased attribute for the header' do
28
- builder.attribute :name, from: :user_name
32
+ mapper.attribute :name, from: :user_name
29
33
 
30
34
  expect(header).to eql(expected_header)
31
35
  end
@@ -36,7 +40,18 @@ describe ROM::MapperBuilder do
36
40
  let(:options) { { prefix: :user } }
37
41
 
38
42
  it 'adds an aliased attribute for the header using configured :prefix' do
39
- builder.attribute :name
43
+ mapper.attribute :name
44
+
45
+ expect(header).to eql(expected_header)
46
+ end
47
+ end
48
+
49
+ context 'prefixed attribute using custom separator' do
50
+ let(:attributes) { [[:name, from: :'u.name']] }
51
+ let(:options) { { prefix: :u, prefix_separator: '.' } }
52
+
53
+ it 'adds an aliased attribute for the header using configured :prefix' do
54
+ mapper.attribute :name
40
55
 
41
56
  expect(header).to eql(expected_header)
42
57
  end
@@ -47,21 +62,21 @@ describe ROM::MapperBuilder do
47
62
  let(:options) { { symbolize_keys: true } }
48
63
 
49
64
  it 'adds an attribute with symbolized alias' do
50
- builder.attribute :name
65
+ mapper.attribute :name
51
66
 
52
67
  expect(header).to eql(expected_header)
53
68
  end
54
69
  end
55
70
  end
56
71
 
57
- describe 'overriding inherited attributes from the relation header' do
72
+ describe 'overriding inherited attributes' do
58
73
  context 'when name matches' do
59
74
  let(:attributes) { [[:name, type: :string]] }
60
75
 
61
76
  it 'excludes the inherited attribute' do
62
- allow(relation).to receive(:header).and_return([:name])
77
+ parent.attribute :name
63
78
 
64
- builder.attribute :name, type: :string
79
+ mapper.attribute :name, type: :string
65
80
 
66
81
  expect(header).to eql(expected_header)
67
82
  end
@@ -71,9 +86,9 @@ describe ROM::MapperBuilder do
71
86
  let(:attributes) { [[:name, from: 'name', type: :string]] }
72
87
 
73
88
  it 'excludes the inherited attribute' do
74
- allow(relation).to receive(:header).and_return(['name'])
89
+ parent.attribute 'name'
75
90
 
76
- builder.attribute :name, from: 'name', type: :string
91
+ mapper.attribute :name, from: 'name', type: :string
77
92
 
78
93
  expect(header).to eql(expected_header)
79
94
  end
@@ -87,9 +102,9 @@ describe ROM::MapperBuilder do
87
102
  end
88
103
 
89
104
  it 'excludes the inherited attribute' do
90
- allow(relation).to receive(:header).and_return([:city_name])
105
+ parent.attribute :city_name
91
106
 
92
- builder.wrap :city do
107
+ mapper.wrap :city do
93
108
  attribute :name, from: :city_name
94
109
  end
95
110
 
@@ -105,9 +120,9 @@ describe ROM::MapperBuilder do
105
120
  end
106
121
 
107
122
  it 'excludes the inherited attribute' do
108
- allow(relation).to receive(:header).and_return([:tag_name])
123
+ parent.attribute :tag_name
109
124
 
110
- builder.group :tags do
125
+ mapper.group :tags do
111
126
  attribute :name, from: :tag_name
112
127
  end
113
128
 
@@ -123,9 +138,9 @@ describe ROM::MapperBuilder do
123
138
  end
124
139
 
125
140
  it 'excludes the inherited attribute' do
126
- allow(relation).to receive(:header).and_return([:city])
141
+ parent.attribute :city
127
142
 
128
- builder.embedded :city, type: :hash do
143
+ mapper.embedded :city, type: :hash do
129
144
  attribute :name, from: :city_name
130
145
  end
131
146
 
@@ -141,9 +156,9 @@ describe ROM::MapperBuilder do
141
156
  end
142
157
 
143
158
  it 'excludes the inherited attribute' do
144
- allow(relation).to receive(:header).and_return([:tags])
159
+ parent.attribute :tags
145
160
 
146
- builder.embedded :tags, type: :array do
161
+ mapper.embedded :tags, type: :array do
147
162
  attribute :name, from: :tag_name
148
163
  end
149
164
 
@@ -156,8 +171,7 @@ describe ROM::MapperBuilder do
156
171
  let(:attributes) { [[:name, from: 'name']] }
157
172
 
158
173
  it 'removes an attribute from the inherited header' do
159
- allow(relation).to receive(:header).and_return(['name'])
160
- builder.attribute :name, from: 'name'
174
+ mapper.attribute :name, from: 'name'
161
175
  expect(header).to eql(expected_header)
162
176
  end
163
177
  end
@@ -167,7 +181,7 @@ describe ROM::MapperBuilder do
167
181
  let(:attributes) { [[:city, type: :hash, header: [[:name]]]] }
168
182
 
169
183
  it 'adds an embedded hash attribute' do
170
- builder.embedded :city, type: :hash do
184
+ mapper.embedded :city, type: :hash do
171
185
  attribute :name
172
186
  end
173
187
 
@@ -179,7 +193,7 @@ describe ROM::MapperBuilder do
179
193
  let(:attributes) { [[:tags, type: :array, header: [[:name]]]] }
180
194
 
181
195
  it 'adds an embedded array attribute' do
182
- builder.embedded :tags, type: :array do
196
+ mapper.embedded :tags, type: :array do
183
197
  attribute :name
184
198
  end
185
199
 
@@ -192,7 +206,7 @@ describe ROM::MapperBuilder do
192
206
  let(:attributes) { [[:city, type: :hash, wrap: true, header: [[:name]]]] }
193
207
 
194
208
  it 'adds an wrapped hash attribute using a block to define attributes' do
195
- builder.wrap :city do
209
+ mapper.wrap :city do
196
210
  attribute :name
197
211
  end
198
212
 
@@ -200,7 +214,7 @@ describe ROM::MapperBuilder do
200
214
  end
201
215
 
202
216
  it 'adds an wrapped hash attribute using a options define attributes' do
203
- builder.wrap city: [:name]
217
+ mapper.wrap city: [:name]
204
218
 
205
219
  expect(header).to eql(expected_header)
206
220
  end
@@ -210,7 +224,7 @@ describe ROM::MapperBuilder do
210
224
  let(:attributes) { [[:tags, type: :array, group: true, header: [[:name]]]] }
211
225
 
212
226
  it 'adds a group attribute using a block to define attributes' do
213
- builder.group :tags do
227
+ mapper.group :tags do
214
228
  attribute :name
215
229
  end
216
230
 
@@ -218,7 +232,7 @@ describe ROM::MapperBuilder do
218
232
  end
219
233
 
220
234
  it 'adds a group attribute using a options define attributes' do
221
- builder.group tags: [:name]
235
+ mapper.group tags: [:name]
222
236
 
223
237
  expect(header).to eql(expected_header)
224
238
  end
@@ -246,17 +260,17 @@ describe ROM::MapperBuilder do
246
260
  end
247
261
 
248
262
  it 'sets aliased attributes using prefix automatically' do
249
- builder.attribute :name
263
+ mapper.attribute :name
250
264
 
251
- builder.embedded :address, type: :hash do
265
+ mapper.embedded :address, type: :hash do
252
266
  attribute :city
253
267
  end
254
268
 
255
- builder.wrap :contact do
269
+ mapper.wrap :contact do
256
270
  attribute :mobile
257
271
  end
258
272
 
259
- builder.group :tasks do
273
+ mapper.group :tasks do
260
274
  attribute :title
261
275
  end
262
276
 
@@ -284,23 +298,23 @@ describe ROM::MapperBuilder do
284
298
  end
285
299
 
286
300
  it 'excludes from aliasing the ones which override it' do
287
- builder.attribute :name
301
+ mapper.attribute :name
288
302
 
289
- builder.embedded :birthday, type: :hash, prefix: :bd do
303
+ mapper.embedded :birthday, type: :hash, prefix: :bd do
290
304
  attribute :year
291
305
  attribute :month
292
306
  attribute :day
293
307
  end
294
308
 
295
- builder.embedded :address, type: :hash, prefix: false do
309
+ mapper.embedded :address, type: :hash, prefix: false do
296
310
  attribute :city
297
311
  end
298
312
 
299
- builder.wrap :contact, prefix: :contact do
313
+ mapper.wrap :contact, prefix: :contact do
300
314
  attribute :mobile
301
315
  end
302
316
 
303
- builder.group :tasks, prefix: :task do
317
+ mapper.group :tasks, prefix: :task do
304
318
  attribute :title
305
319
  end
306
320