rom 0.9.1 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +30 -12
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +24 -0
  5. data/Gemfile +7 -3
  6. data/README.md +24 -11
  7. data/lib/rom.rb +9 -26
  8. data/lib/rom/command.rb +113 -75
  9. data/lib/rom/commands/class_interface.rb +115 -0
  10. data/lib/rom/commands/graph.rb +17 -23
  11. data/lib/rom/commands/graph/builder.rb +176 -0
  12. data/lib/rom/commands/graph/class_interface.rb +8 -2
  13. data/lib/rom/commands/graph/input_evaluator.rb +13 -9
  14. data/lib/rom/commands/lazy.rb +23 -17
  15. data/lib/rom/commands/lazy/create.rb +23 -0
  16. data/lib/rom/commands/lazy/delete.rb +27 -0
  17. data/lib/rom/commands/lazy/update.rb +34 -0
  18. data/lib/rom/commands/result.rb +14 -0
  19. data/lib/rom/commands/update.rb +0 -4
  20. data/lib/rom/configuration.rb +86 -0
  21. data/lib/rom/{setup_dsl/setup.rb → configuration_dsl.rb} +9 -7
  22. data/lib/rom/configuration_dsl/command.rb +43 -0
  23. data/lib/rom/{setup_dsl → configuration_dsl}/command_dsl.rb +5 -4
  24. data/lib/rom/configuration_dsl/mapper.rb +37 -0
  25. data/lib/rom/{setup_dsl → configuration_dsl}/mapper_dsl.rb +11 -5
  26. data/lib/rom/configuration_dsl/relation.rb +26 -0
  27. data/lib/rom/configuration_plugin.rb +17 -0
  28. data/lib/rom/constants.rb +5 -12
  29. data/lib/rom/container.rb +11 -8
  30. data/lib/rom/create_container.rb +61 -0
  31. data/lib/rom/environment.rb +27 -241
  32. data/lib/rom/gateway.rb +18 -2
  33. data/lib/rom/global.rb +24 -0
  34. data/lib/rom/global/plugin_dsl.rb +2 -0
  35. data/lib/rom/lint/spec.rb +0 -12
  36. data/lib/rom/lint/test.rb +0 -31
  37. data/lib/rom/memory/commands.rb +2 -2
  38. data/lib/rom/memory/gateway.rb +2 -0
  39. data/lib/rom/pipeline.rb +1 -1
  40. data/lib/rom/plugin_base.rb +1 -1
  41. data/lib/rom/plugin_registry.rb +12 -10
  42. data/lib/rom/plugins/configuration/configuration_dsl.rb +16 -0
  43. data/lib/rom/plugins/relation/key_inference.rb +31 -0
  44. data/lib/rom/plugins/relation/view.rb +90 -0
  45. data/lib/rom/plugins/relation/view/dsl.rb +32 -0
  46. data/lib/rom/relation.rb +1 -11
  47. data/lib/rom/relation/class_interface.rb +37 -50
  48. data/lib/rom/setup.rb +13 -104
  49. data/lib/rom/setup/auto_registration.rb +55 -0
  50. data/lib/rom/setup/finalize.rb +113 -127
  51. data/lib/rom/setup/finalize/commands.rb +67 -0
  52. data/lib/rom/setup/finalize/mappers.rb +36 -0
  53. data/lib/rom/setup/finalize/relations.rb +53 -0
  54. data/lib/rom/support/configurable.rb +21 -7
  55. data/lib/rom/version.rb +1 -1
  56. data/rakelib/mutant.rake +4 -1
  57. data/rom.gemspec +3 -4
  58. data/spec/fixtures/app/commands/create_user.rb +2 -0
  59. data/spec/fixtures/app/mappers/user_list.rb +2 -0
  60. data/spec/fixtures/app/relations/users.rb +2 -0
  61. data/spec/fixtures/lib/persistence/commands/create_user.rb +6 -0
  62. data/spec/fixtures/lib/persistence/mappers/user_list.rb +6 -0
  63. data/spec/fixtures/lib/persistence/relations/users.rb +6 -0
  64. data/spec/{unit/rom → integration}/command_registry_spec.rb +8 -9
  65. data/spec/integration/commands/create_spec.rb +17 -13
  66. data/spec/integration/commands/delete_spec.rb +12 -11
  67. data/spec/integration/commands/error_handling_spec.rb +5 -4
  68. data/spec/integration/commands/graph_builder_spec.rb +213 -0
  69. data/spec/integration/commands/graph_spec.rb +112 -49
  70. data/spec/integration/commands/update_spec.rb +14 -11
  71. data/spec/integration/commands_spec.rb +60 -0
  72. data/spec/integration/mappers/combine_spec.rb +7 -6
  73. data/spec/integration/mappers/deep_embedded_spec.rb +5 -6
  74. data/spec/integration/mappers/definition_dsl_spec.rb +19 -18
  75. data/spec/integration/mappers/embedded_spec.rb +11 -12
  76. data/spec/integration/mappers/exclude_spec.rb +5 -6
  77. data/spec/integration/mappers/fold_spec.rb +8 -7
  78. data/spec/integration/mappers/group_spec.rb +16 -15
  79. data/spec/integration/mappers/overwrite_attributes_value_spec.rb +5 -5
  80. data/spec/integration/mappers/prefix_separator_spec.rb +5 -7
  81. data/spec/integration/mappers/prefix_spec.rb +5 -7
  82. data/spec/integration/mappers/prefixing_attributes_spec.rb +7 -7
  83. data/spec/integration/mappers/registering_custom_mappers_spec.rb +4 -5
  84. data/spec/integration/mappers/renaming_attributes_spec.rb +18 -18
  85. data/spec/integration/mappers/step_spec.rb +11 -12
  86. data/spec/integration/mappers/symbolizing_attributes_spec.rb +11 -8
  87. data/spec/integration/mappers/unfold_spec.rb +9 -10
  88. data/spec/integration/mappers/ungroup_spec.rb +10 -11
  89. data/spec/integration/mappers/unwrap_spec.rb +10 -15
  90. data/spec/integration/mappers/wrap_spec.rb +16 -15
  91. data/spec/{unit/rom → integration}/memory/commands/create_spec.rb +7 -5
  92. data/spec/{unit/rom → integration}/memory/commands/delete_spec.rb +7 -5
  93. data/spec/{unit/rom → integration}/memory/commands/update_spec.rb +7 -5
  94. data/spec/integration/multi_env_spec.rb +16 -124
  95. data/spec/integration/multi_repo_spec.rb +9 -9
  96. data/spec/integration/relations/default_dataset_spec.rb +15 -0
  97. data/spec/integration/relations/inheritance_spec.rb +5 -7
  98. data/spec/integration/relations/reading_spec.rb +32 -65
  99. data/spec/integration/relations/registry_dsl_spec.rb +5 -4
  100. data/spec/integration/repositories/extending_relations_spec.rb +6 -7
  101. data/spec/integration/repositories/setting_logger_spec.rb +5 -7
  102. data/spec/integration/setup_spec.rb +49 -61
  103. data/spec/shared/command_graph.rb +50 -0
  104. data/spec/shared/container.rb +9 -0
  105. data/spec/shared/gateway_only.rb +6 -0
  106. data/spec/shared/no_container.rb +16 -0
  107. data/spec/shared/one_behavior.rb +4 -4
  108. data/spec/shared/users_and_tasks.rb +5 -17
  109. data/spec/spec_helper.rb +5 -3
  110. data/spec/test/memory_repository_lint_test.rb +1 -1
  111. data/spec/unit/rom/auto_registration_spec.rb +54 -0
  112. data/spec/unit/rom/commands/graph_spec.rb +18 -44
  113. data/spec/unit/rom/commands/lazy_spec.rb +246 -35
  114. data/spec/unit/rom/commands/result_spec.rb +56 -0
  115. data/spec/unit/rom/commands_spec.rb +9 -73
  116. data/spec/unit/rom/configurable_spec.rb +49 -0
  117. data/spec/unit/rom/configuration_spec.rb +61 -0
  118. data/spec/unit/rom/container_spec.rb +39 -33
  119. data/spec/unit/rom/create_container_spec.rb +151 -0
  120. data/spec/unit/rom/environment_spec.rb +123 -0
  121. data/spec/unit/rom/gateway_spec.rb +58 -2
  122. data/spec/unit/rom/global_spec.rb +10 -7
  123. data/spec/unit/rom/plugin_spec.rb +44 -25
  124. data/spec/unit/rom/plugins/relation/key_inference_spec.rb +27 -0
  125. data/spec/unit/rom/plugins/relation/view_spec.rb +47 -0
  126. data/spec/unit/rom/relation/composite_spec.rb +20 -20
  127. data/spec/unit/rom/relation/curried_spec.rb +10 -11
  128. data/spec/unit/rom/relation/graph_spec.rb +27 -27
  129. data/spec/unit/rom/relation/lazy/combine_spec.rb +26 -20
  130. data/spec/unit/rom/relation/lazy_spec.rb +38 -38
  131. data/spec/unit/rom/relation/loaded_spec.rb +2 -3
  132. data/spec/unit/rom/relation_spec.rb +39 -2
  133. metadata +58 -66
  134. data/lib/rom/commands/abstract.rb +0 -184
  135. data/lib/rom/environment_plugin.rb +0 -17
  136. data/lib/rom/environment_plugins/auto_registration.rb +0 -38
  137. data/lib/rom/repository.rb +0 -16
  138. data/lib/rom/setup_dsl/command.rb +0 -36
  139. data/lib/rom/setup_dsl/mapper.rb +0 -32
  140. data/lib/rom/setup_dsl/relation.rb +0 -30
  141. data/spec/integration/inline_setup_spec.rb +0 -65
  142. data/spec/unit/rom/repository_spec.rb +0 -12
  143. data/spec/unit/rom/setup_spec.rb +0 -253
@@ -1,27 +1,21 @@
1
1
  require 'spec_helper'
2
+ require 'rom/memory'
2
3
 
3
4
  describe 'Setting up ROM with multiple environments' do
4
- let(:environment) do
5
+ let(:configuration) do
5
6
  {
6
- one: ROM::Environment.new,
7
- two: ROM::Environment.new
8
- }
9
- end
10
- let(:setup) do
11
- {
12
- one: environment[:one].setup(:memory),
13
- two: environment[:two].setup(:memory)
7
+ one: ROM::Configuration.new(:memory),
8
+ two: ROM::Configuration.new(:memory)
14
9
  }
15
10
  end
11
+
16
12
  let(:container) do
17
13
  {
18
- one: setup[:one].finalize,
19
- two: setup[:two].finalize
14
+ one: ROM.container(configuration[:one]),
15
+ two: ROM.container(configuration[:two]),
20
16
  }
21
17
  end
22
18
 
23
- before { setup }
24
-
25
19
  context 'without :auto_registration plugin' do
26
20
  before do
27
21
  module Test
@@ -43,9 +37,9 @@ describe 'Setting up ROM with multiple environments' do
43
37
  end
44
38
 
45
39
  it 'registers items independently of other environments' do
46
- environment[:one].register_relation(Test::Users)
47
- environment[:one].register_command(Test::CreateUser)
48
- environment[:one].register_mapper(Test::UserMapper)
40
+ configuration[:one].register_relation(Test::Users)
41
+ configuration[:one].register_command(Test::CreateUser)
42
+ configuration[:one].register_mapper(Test::UserMapper)
49
43
 
50
44
  expect(container[:one].relations[:users]).to be_kind_of Test::Users
51
45
  expect(container[:one].commands[:users].create).to be_kind_of Test::CreateUser
@@ -63,115 +57,13 @@ describe 'Setting up ROM with multiple environments' do
63
57
  end
64
58
 
65
59
  it 'allows use of the same identifiers in different environments' do
66
- environment[:one].register_relation(Test::Users)
67
- environment[:one].register_command(Test::CreateUser)
68
- environment[:one].register_mapper(Test::UserMapper)
69
-
70
- expect { environment[:two].register_relation(Test::Users) }.to_not raise_error
71
- expect { environment[:two].register_command(Test::CreateUser) }.to_not raise_error
72
- expect { environment[:two].register_mapper(Test::UserMapper) }.to_not raise_error
73
- end
74
- end
75
-
76
- context 'with :auto_registration plugin' do
77
- context 'without if option' do
78
- before do
79
- environment[:one].use :auto_registration
80
-
81
- module Test
82
- class Users < ROM::Relation[:memory]
83
- dataset :users
84
- end
85
-
86
- class CreateUser < ROM::Commands::Create[:memory]
87
- register_as :create
88
- relation :users
89
- result :one
90
- end
91
-
92
- class UserMapper < ROM::Mapper
93
- relation :users
94
- register_as :entity
95
- end
96
- end
97
- end
98
-
99
- it 'registers all classes that are defined with the given environment' do
100
- expect(container[:one].relations[:users]).to be_kind_of Test::Users
101
- expect(container[:one].commands[:users].create).to be_kind_of Test::CreateUser
102
- expect(container[:one].mappers[:users].entity).to be_kind_of Test::UserMapper
103
- end
60
+ configuration[:one].register_relation(Test::Users)
61
+ configuration[:one].register_command(Test::CreateUser)
62
+ configuration[:one].register_mapper(Test::UserMapper)
104
63
 
105
- it 'works independently of other environments' do
106
- expect { container[:two].relations[:users] }.to raise_error(
107
- ROM::Registry::ElementNotFoundError
108
- )
109
- expect { container[:two].commands[:users].create }.to raise_error(
110
- ROM::Registry::ElementNotFoundError
111
- )
112
- expect { container[:two].commands[:users].create }.to raise_error(
113
- ROM::Registry::ElementNotFoundError
114
- )
115
- end
116
- end
117
-
118
- context 'with if option' do
119
- before do
120
- environment[:one].use :auto_registration, if: ->(item) do
121
- item.to_s[/(.*)(?=::)/] == 'Test'
122
- end
123
-
124
- environment[:two].use :auto_registration, if: ->(item) do
125
- item.to_s[/(.*)(?=::)/] == 'Test::API'
126
- end
127
-
128
- module Test
129
- class Users < ROM::Relation[:memory]
130
- dataset :users
131
- end
132
-
133
- class CreateUser < ROM::Commands::Create[:memory]
134
- register_as :create
135
- relation :users
136
- result :one
137
- end
138
-
139
- class UserMapper < ROM::Mapper
140
- relation :users
141
- register_as :entity
142
- end
143
-
144
- module API
145
- class Users < ROM::Relation[:memory]
146
- dataset :users
147
- end
148
-
149
- class CreateUser < ROM::Commands::Create[:memory]
150
- register_as :create
151
- relation :users
152
- result :one
153
- end
154
-
155
- class UserMapper < ROM::Mapper
156
- relation :users
157
- register_as :entity
158
- end
159
- end
160
- end
161
- end
162
-
163
- it 'registers all classes that are defined where proc returns true' do
164
- expect(container[:one].relations[:users]).to be_kind_of Test::Users
165
- expect(container[:one].commands[:users].create).to be_kind_of Test::CreateUser
166
- expect(container[:one].mappers[:users].entity).to be_kind_of Test::UserMapper
167
- expect(container[:two].relations[:users]).to be_kind_of Test::API::Users
168
- expect(container[:two].commands[:users].create).to be_kind_of(
169
- Test::API::CreateUser
170
- )
171
- expect(container[:two].mappers[:users].entity).to be_kind_of(
172
- Test::API::UserMapper
173
- )
174
- end
64
+ expect { configuration[:two].register_relation(Test::Users) }.to_not raise_error
65
+ expect { configuration[:two].register_command(Test::CreateUser) }.to_not raise_error
66
+ expect { configuration[:two].register_mapper(Test::UserMapper) }.to_not raise_error
175
67
  end
176
68
  end
177
69
  end
@@ -2,29 +2,29 @@ require 'spec_helper'
2
2
  require 'rom/memory'
3
3
 
4
4
  describe 'Using in-memory gateways for cross-repo access' do
5
- let(:setup) do
6
- ROM.setup(left: :memory, right: :memory, main: :memory)
5
+ let(:configuration) do
6
+ ROM::Configuration.new(left: :memory, right: :memory, main: :memory).use(:macros)
7
7
  end
8
8
 
9
- let(:gateways) { rom.gateways }
10
- let(:rom) { setup.finalize }
9
+ let(:container) { ROM.container(configuration) }
10
+ let(:gateways) { container.gateways }
11
11
 
12
12
  it 'works' do
13
- setup.relation(:users, gateway: :left) do
13
+ configuration.relation(:users, gateway: :left) do
14
14
  def by_name(name)
15
15
  restrict(name: name)
16
16
  end
17
17
  end
18
18
 
19
- setup.relation(:tasks, gateway: :right)
19
+ configuration.relation(:tasks, gateway: :right)
20
20
 
21
- setup.relation(:users_and_tasks, gateway: :main) do
21
+ configuration.relation(:users_and_tasks, gateway: :main) do
22
22
  def by_user(name)
23
23
  join(users.by_name(name), tasks)
24
24
  end
25
25
  end
26
26
 
27
- setup.mappers do
27
+ configuration.mappers do
28
28
  define(:users_and_tasks) do
29
29
  group tasks: [:title]
30
30
  end
@@ -35,7 +35,7 @@ describe 'Using in-memory gateways for cross-repo access' do
35
35
  gateways[:right][:tasks] << { user_id: 1, title: 'Have fun' }
36
36
  gateways[:right][:tasks] << { user_id: 2, title: 'Have fun' }
37
37
 
38
- user_and_tasks = rom.relation(:users_and_tasks)
38
+ user_and_tasks = container.relation(:users_and_tasks)
39
39
  .by_user('Jane')
40
40
  .as(:users_and_tasks)
41
41
 
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe ROM::Relation, '.dataset' do
4
+ include_context 'container'
5
+
6
+ it 'injects configured dataset when block was provided' do
7
+ configuration.relation(:users) do
8
+ dataset { restrict(name: 'Jane') }
9
+ end
10
+
11
+ expect(container.relation(:users).dataset).to eql(
12
+ container.relation(:users).dataset.restrict(name: 'Jane')
13
+ )
14
+ end
15
+ end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe 'Inheritance relation hierarchy' do
4
- before do
5
- ROM.setup(:memory)
4
+ include_context 'container'
6
5
 
6
+ before do
7
7
  module Test
8
8
  class Users < ROM::Relation[:memory]
9
9
  dataset :users
@@ -18,14 +18,12 @@ RSpec.describe 'Inheritance relation hierarchy' do
18
18
  end
19
19
  end
20
20
 
21
- ROM.finalize
21
+ configuration.register_relation(Test::Users, Test::OtherUsers)
22
22
  end
23
23
 
24
24
  it 'registers parent and descendant relations' do
25
- rom = ROM.env
26
-
27
- users = rom.relations.users
28
- other_users = rom.relations.other_users
25
+ users = container.relation(:users)
26
+ other_users = container.relation(:other_users)
29
27
 
30
28
  expect(users).to be_instance_of(Test::Users)
31
29
  expect(other_users).to be_instance_of(Test::OtherUsers)
@@ -1,22 +1,34 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'Reading relations' do
4
+ include_context 'container'
4
5
  include_context 'users and tasks'
5
6
 
6
- it 'exposes a relation reader' do
7
- setup.relation(:tasks)
7
+ before do
8
+ configuration.relation(:tasks)
8
9
 
9
- setup.relation(:users) do
10
+ configuration.relation(:users) do
10
11
  def by_name(name)
11
12
  restrict(name: name)
12
13
  end
13
14
 
15
+ def with_task
16
+ join(tasks)
17
+ end
18
+
19
+ def with_tasks
20
+ join(tasks)
21
+ end
22
+
14
23
  def sorted
15
24
  order(:name, :email)
16
25
  end
17
26
  end
27
+ end
28
+
18
29
 
19
- setup.mappers do
30
+ it 'exposes a relation reader' do
31
+ configuration.mappers do
20
32
  define(:users) do
21
33
  model name: 'Test::User'
22
34
 
@@ -25,9 +37,7 @@ describe 'Reading relations' do
25
37
  end
26
38
  end
27
39
 
28
- rom = setup.finalize
29
-
30
- users = rom.relation(:users).sorted.by_name('Jane').as(:users)
40
+ users = users_relation.sorted.by_name('Jane').as(:users)
31
41
  user = users.first
32
42
 
33
43
  expect(user).to be_an_instance_of(Test::User)
@@ -36,19 +46,7 @@ describe 'Reading relations' do
36
46
  end
37
47
 
38
48
  it 'maps grouped relations' do
39
- setup.relation(:tasks)
40
-
41
- setup.relation(:users) do
42
- def with_tasks
43
- join(tasks)
44
- end
45
-
46
- def sorted
47
- order(:name)
48
- end
49
- end
50
-
51
- setup.mappers do
49
+ configuration.mappers do
52
50
  define(:users) do
53
51
  model name: 'Test::User'
54
52
 
@@ -63,18 +61,18 @@ describe 'Reading relations' do
63
61
  end
64
62
  end
65
63
 
66
- rom = setup.finalize
64
+ container
67
65
 
68
66
  Test::User.send(:include, Equalizer.new(:name, :email))
69
67
  Test::UserWithTasks.send(:include, Equalizer.new(:name, :email, :tasks))
70
68
 
71
- user = rom.relation(:users).sorted.as(:users).first
69
+ user = container.relation(:users).sorted.as(:users).first
72
70
 
73
71
  expect(user).to eql(
74
72
  Test::User.new(name: "Jane", email: "jane@doe.org")
75
73
  )
76
74
 
77
- user = rom.relation(:users).with_tasks.sorted.as(:with_tasks).first
75
+ user = container.relation(:users).with_tasks.sorted.as(:with_tasks).first
78
76
 
79
77
  expect(user).to eql(
80
78
  Test::UserWithTasks.new(
@@ -85,19 +83,7 @@ describe 'Reading relations' do
85
83
  end
86
84
 
87
85
  it 'maps wrapped relations' do
88
- setup.relation(:tasks)
89
-
90
- setup.relation(:users) do
91
- def with_task
92
- join(tasks)
93
- end
94
-
95
- def sorted
96
- order(:name)
97
- end
98
- end
99
-
100
- setup.mappers do
86
+ configuration.mappers do
101
87
  define(:users) do
102
88
  model name: 'Test::User'
103
89
 
@@ -112,12 +98,12 @@ describe 'Reading relations' do
112
98
  end
113
99
  end
114
100
 
115
- rom = setup.finalize
101
+ container
116
102
 
117
103
  Test::User.send(:include, Equalizer.new(:name, :email))
118
104
  Test::UserWithTask.send(:include, Equalizer.new(:name, :email, :task))
119
105
 
120
- user = rom.relation(:users).sorted.with_task.as(:with_task).first
106
+ user = container.relation(:users).sorted.with_task.as(:with_task).first
121
107
 
122
108
  expect(user).to eql(
123
109
  Test::UserWithTask.new(name: "Jane", email: "jane@doe.org",
@@ -126,27 +112,17 @@ describe 'Reading relations' do
126
112
  end
127
113
 
128
114
  it 'maps hashes' do
129
- setup.relation(:users) do
130
- def by_name(name)
131
- restrict(name: name)
132
- end
133
- end
134
-
135
- setup.mappers do
115
+ configuration.mappers do
136
116
  define(:users)
137
117
  end
138
118
 
139
- rom = setup.finalize
140
-
141
- user = rom.relation(:users).by_name("Jane").as(:users).first
119
+ user = container.relation(:users).by_name("Jane").as(:users).first
142
120
 
143
121
  expect(user).to eql(name: "Jane", email: "jane@doe.org")
144
122
  end
145
123
 
146
124
  it 'allows cherry-picking of a mapper' do
147
- setup.relation(:users)
148
-
149
- setup.mappers do
125
+ configuration.mappers do
150
126
  define(:users) do
151
127
  attribute :name
152
128
  attribute :email
@@ -158,20 +134,13 @@ describe 'Reading relations' do
158
134
  end
159
135
  end
160
136
 
161
- rom = setup.finalize
162
- user = rom.relation(:users).map_with(:prefixer).first
137
+ user = container.relation(:users).map_with(:prefixer).first
163
138
 
164
139
  expect(user).to eql(user_name: 'Joe', user_email: "joe@doe.org")
165
140
  end
166
141
 
167
142
  it 'allows passing a block to retrieve relations for mapping' do
168
- setup.relation(:users) do
169
- def by_name(name)
170
- restrict(name: name)
171
- end
172
- end
173
-
174
- setup.mappers do
143
+ configuration.mappers do
175
144
  define(:users) do
176
145
  attribute :name
177
146
  attribute :email
@@ -183,17 +152,15 @@ describe 'Reading relations' do
183
152
  end
184
153
  end
185
154
 
186
- rom = setup.finalize
187
-
188
155
  expect {
189
- rom.relation(:users) { |users| users.not_here }
156
+ container.relation(:users, &:not_here)
190
157
  }.to raise_error(NoMethodError, /not_here/)
191
158
 
192
159
  expect {
193
- rom.relation(:users) { |users| users.by_name('Joe') }.as(:not_here)
160
+ container.relation(:users) { |users| users.by_name('Joe') }.as(:not_here)
194
161
  }.to raise_error(ROM::MapperMissingError, /not_here/)
195
162
 
196
- user = rom.relation(:users) { |users|
163
+ user = container.relation(:users) { |users|
197
164
  users.by_name('Joe')
198
165
  }.map_with(:prefixer).call.first
199
166