rom 2.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -7
- data/.yardopts +2 -0
- data/CHANGELOG.md +35 -1
- data/Gemfile +17 -2
- data/Rakefile +7 -2
- data/lib/rom/array_dataset.rb +44 -0
- data/lib/rom/association_set.rb +11 -5
- data/lib/rom/auto_curry.rb +55 -0
- data/lib/rom/command.rb +331 -47
- data/lib/rom/command_registry.rb +7 -18
- data/lib/rom/commands/class_interface.rb +120 -6
- data/lib/rom/commands/composite.rb +0 -1
- data/lib/rom/commands/graph.rb +7 -15
- data/lib/rom/commands/lazy/update.rb +1 -1
- data/lib/rom/configuration.rb +2 -0
- data/lib/rom/configuration_dsl/command.rb +6 -8
- data/lib/rom/configuration_dsl/mapper.rb +2 -3
- data/lib/rom/configuration_dsl/mapper_dsl.rb +0 -1
- data/lib/rom/configuration_dsl/relation.rb +4 -4
- data/lib/rom/configuration_dsl.rb +0 -4
- data/lib/rom/constants.rb +7 -1
- data/lib/rom/container.rb +11 -17
- data/lib/rom/create_container.rb +0 -2
- data/lib/rom/data_proxy.rb +94 -0
- data/lib/rom/enumerable_dataset.rb +68 -0
- data/lib/rom/gateway.rb +74 -32
- data/lib/rom/global/plugin_dsl.rb +0 -2
- data/lib/rom/global.rb +0 -2
- data/lib/rom/initializer.rb +26 -0
- data/lib/rom/lint/gateway.rb +17 -0
- data/lib/rom/mapper_registry.rb +1 -1
- data/lib/rom/memory/commands.rb +0 -2
- data/lib/rom/memory/dataset.rb +1 -2
- data/lib/rom/memory/relation.rb +14 -1
- data/lib/rom/memory/schema.rb +13 -0
- data/lib/rom/plugin_registry.rb +1 -1
- data/lib/rom/plugins/command/schema.rb +2 -2
- data/lib/rom/plugins/configuration/configuration_dsl.rb +6 -2
- data/lib/rom/plugins/relation/key_inference.rb +4 -2
- data/lib/rom/plugins/relation/registry_reader.rb +5 -1
- data/lib/rom/registry.rb +50 -0
- data/lib/rom/relation/class_interface.rb +142 -30
- data/lib/rom/relation/curried.rb +15 -15
- data/lib/rom/relation/view_dsl.rb +31 -0
- data/lib/rom/relation.rb +101 -41
- data/lib/rom/schema/attribute.rb +367 -0
- data/lib/rom/schema/dsl.rb +14 -10
- data/lib/rom/schema.rb +337 -19
- data/lib/rom/setup/auto_registration.rb +20 -17
- data/lib/rom/setup/auto_registration_strategies/base.rb +8 -3
- data/lib/rom/setup/auto_registration_strategies/custom_namespace.rb +4 -3
- data/lib/rom/setup/auto_registration_strategies/no_namespace.rb +5 -4
- data/lib/rom/setup/auto_registration_strategies/with_namespace.rb +3 -3
- data/lib/rom/setup/finalize/finalize_commands.rb +1 -1
- data/lib/rom/setup/finalize/finalize_mappers.rb +1 -1
- data/lib/rom/setup/finalize/finalize_relations.rb +4 -2
- data/lib/rom/setup/finalize.rb +1 -1
- data/lib/rom/transaction.rb +24 -0
- data/lib/rom/types.rb +9 -1
- data/lib/rom/version.rb +1 -1
- data/lib/rom.rb +4 -8
- data/rom.gemspec +5 -4
- data/spec/integration/command_registry_spec.rb +1 -14
- data/spec/integration/commands/create_spec.rb +5 -25
- data/spec/integration/commands/delete_spec.rb +1 -1
- data/spec/integration/commands/error_handling_spec.rb +1 -1
- data/spec/integration/commands/graph_spec.rb +20 -14
- data/spec/integration/commands/update_spec.rb +4 -27
- data/spec/integration/commands_spec.rb +1 -1
- data/spec/integration/{repositories → gateways}/extending_relations_spec.rb +1 -1
- data/spec/integration/{repositories → gateways}/setting_logger_spec.rb +2 -2
- data/spec/integration/mappers/combine_spec.rb +1 -1
- data/spec/integration/mappers/deep_embedded_spec.rb +1 -1
- data/spec/integration/mappers/definition_dsl_spec.rb +1 -1
- data/spec/integration/mappers/embedded_spec.rb +1 -1
- data/spec/integration/mappers/exclude_spec.rb +1 -1
- data/spec/integration/mappers/fold_spec.rb +1 -1
- data/spec/integration/mappers/group_spec.rb +1 -1
- data/spec/integration/mappers/overwrite_attributes_value_spec.rb +1 -1
- data/spec/integration/mappers/prefix_separator_spec.rb +1 -1
- data/spec/integration/mappers/prefix_spec.rb +1 -1
- data/spec/integration/mappers/prefixing_attributes_spec.rb +1 -1
- data/spec/integration/mappers/registering_custom_mappers_spec.rb +1 -1
- data/spec/integration/mappers/renaming_attributes_spec.rb +1 -1
- data/spec/integration/mappers/reusing_mappers_spec.rb +1 -1
- data/spec/integration/mappers/step_spec.rb +1 -1
- data/spec/integration/mappers/symbolizing_attributes_spec.rb +1 -1
- data/spec/integration/mappers/unfold_spec.rb +1 -1
- data/spec/integration/mappers/ungroup_spec.rb +2 -2
- data/spec/integration/mappers/unwrap_spec.rb +2 -2
- data/spec/integration/mappers/wrap_spec.rb +1 -1
- data/spec/integration/memory/commands/create_spec.rb +1 -1
- data/spec/integration/memory/commands/delete_spec.rb +1 -1
- data/spec/integration/memory/commands/update_spec.rb +1 -1
- data/spec/integration/multi_env_spec.rb +1 -1
- data/spec/integration/multi_repo_spec.rb +1 -1
- data/spec/integration/relations/default_dataset_spec.rb +1 -1
- data/spec/integration/relations/reading_spec.rb +1 -1
- data/spec/integration/relations/registry_dsl_spec.rb +1 -1
- data/spec/integration/setup_spec.rb +10 -4
- data/spec/shared/command_graph.rb +8 -4
- data/spec/shared/enumerable_dataset.rb +1 -1
- data/spec/spec_helper.rb +7 -9
- data/spec/support/schema.rb +14 -0
- data/spec/unit/rom/array_dataset_spec.rb +59 -0
- data/spec/unit/rom/association_set_spec.rb +4 -0
- data/spec/unit/rom/auto_curry_spec.rb +63 -0
- data/spec/unit/rom/commands/graph_spec.rb +12 -11
- data/spec/unit/rom/commands/lazy_spec.rb +8 -5
- data/spec/unit/rom/commands/pre_and_post_processors_spec.rb +336 -0
- data/spec/unit/rom/commands/result_spec.rb +1 -1
- data/spec/unit/rom/commands_spec.rb +26 -3
- data/spec/unit/rom/configuration_spec.rb +1 -1
- data/spec/unit/rom/container_spec.rb +15 -5
- data/spec/unit/rom/create_container_spec.rb +1 -1
- data/spec/unit/rom/enumerable_dataset_spec.rb +15 -0
- data/spec/unit/rom/gateway_spec.rb +1 -1
- data/spec/unit/rom/mapper_registry_spec.rb +1 -1
- data/spec/unit/rom/memory/commands_spec.rb +1 -1
- data/spec/unit/rom/memory/dataset_spec.rb +1 -1
- data/spec/unit/rom/memory/{repository_spec.rb → gateway_spec.rb} +1 -1
- data/spec/unit/rom/memory/inheritance_spec.rb +32 -0
- data/spec/unit/rom/memory/relation_spec.rb +15 -3
- data/spec/unit/rom/memory/storage_spec.rb +1 -1
- data/spec/unit/rom/plugin_spec.rb +1 -1
- data/spec/unit/rom/plugins/command/schema_spec.rb +5 -5
- data/spec/unit/rom/plugins/relation/key_inference_spec.rb +1 -1
- data/spec/unit/rom/registry_spec.rb +86 -0
- data/spec/unit/rom/relation/attribute_reader_spec.rb +17 -0
- data/spec/unit/rom/relation/call_spec.rb +51 -0
- data/spec/unit/rom/relation/composite_spec.rb +1 -1
- data/spec/unit/rom/relation/graph_spec.rb +1 -1
- data/spec/unit/rom/relation/lazy/combine_spec.rb +1 -1
- data/spec/unit/rom/relation/lazy_spec.rb +1 -1
- data/spec/unit/rom/relation/loaded_spec.rb +1 -1
- data/spec/unit/rom/relation/schema_spec.rb +50 -6
- data/spec/unit/rom/relation/view_spec.rb +122 -0
- data/spec/unit/rom/relation_spec.rb +20 -5
- data/spec/unit/rom/schema/accessing_attributes_spec.rb +52 -0
- data/spec/unit/rom/schema/append_spec.rb +17 -0
- data/spec/unit/rom/schema/exclude_spec.rb +15 -0
- data/spec/unit/rom/schema/finalize_spec.rb +59 -0
- data/spec/unit/rom/schema/key_predicate_spec.rb +15 -0
- data/spec/unit/rom/schema/merge_spec.rb +17 -0
- data/spec/unit/rom/schema/prefix_spec.rb +16 -0
- data/spec/unit/rom/schema/project_spec.rb +15 -0
- data/spec/unit/rom/schema/rename_spec.rb +22 -0
- data/spec/unit/rom/schema/type_spec.rb +49 -0
- data/spec/unit/rom/schema/uniq_spec.rb +21 -0
- data/spec/unit/rom/schema/wrap_spec.rb +17 -0
- data/spec/unit/rom/schema_spec.rb +2 -2
- metadata +79 -17
- data/lib/rom/plugins/relation/view/dsl.rb +0 -32
- data/lib/rom/plugins/relation/view.rb +0 -95
- data/spec/unit/rom/plugins/relation/view_spec.rb +0 -51
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'ROM::CommandRegistry' do
|
3
|
+
RSpec.describe 'ROM::CommandRegistry' do
|
4
4
|
include_context 'container'
|
5
5
|
|
6
6
|
let(:users) { container.command(:users) }
|
@@ -11,7 +11,6 @@ describe 'ROM::CommandRegistry' do
|
|
11
11
|
configuration.register_command(Class.new(ROM::Commands::Create[:memory]) do
|
12
12
|
register_as :create
|
13
13
|
relation :users
|
14
|
-
validator proc { |input| raise(ROM::CommandError) unless input[:name] }
|
15
14
|
end)
|
16
15
|
end
|
17
16
|
|
@@ -41,18 +40,6 @@ describe 'ROM::CommandRegistry' do
|
|
41
40
|
expect(result).to match_array([{ name: 'Jane' }])
|
42
41
|
end
|
43
42
|
|
44
|
-
it 'returns a failure result object on failed execution' do
|
45
|
-
result = users.try { users.create.call({}) }
|
46
|
-
|
47
|
-
expect(result.value).to be(nil)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'returns a failure result on unsuccessful curried-command execution' do
|
51
|
-
result = users.try { users.create.curry({}) }
|
52
|
-
|
53
|
-
expect(result.value).to be(nil)
|
54
|
-
end
|
55
|
-
|
56
43
|
it 'allows checking if a command is available using respond_to?' do
|
57
44
|
expect(users).to respond_to(:create)
|
58
45
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'dry-struct'
|
3
3
|
|
4
|
-
describe 'Commands / Create' do
|
4
|
+
RSpec.describe 'Commands / Create' do
|
5
5
|
include_context 'container'
|
6
6
|
include_context 'users and tasks'
|
7
7
|
|
@@ -9,18 +9,6 @@ describe 'Commands / Create' do
|
|
9
9
|
let(:tasks) { container.commands.tasks }
|
10
10
|
|
11
11
|
before do
|
12
|
-
module Test
|
13
|
-
UserValidator = Class.new do
|
14
|
-
ValidationError = Class.new(ROM::CommandError)
|
15
|
-
|
16
|
-
def self.call(params)
|
17
|
-
unless params[:name] && params[:email]
|
18
|
-
raise ValidationError, ":name and :email are required"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
12
|
configuration.relation(:users)
|
25
13
|
configuration.relation(:tasks)
|
26
14
|
|
@@ -28,16 +16,16 @@ describe 'Commands / Create' do
|
|
28
16
|
relation :users
|
29
17
|
register_as :create
|
30
18
|
result :one
|
31
|
-
validator Test::UserValidator
|
32
19
|
end
|
33
20
|
|
34
21
|
class Test::CreateTask < ROM::Commands::Create[:memory]
|
35
22
|
relation :tasks
|
36
23
|
register_as :create
|
37
24
|
result :one
|
25
|
+
before :associate
|
38
26
|
|
39
|
-
def
|
40
|
-
|
27
|
+
def associate(task, user)
|
28
|
+
task.merge(name: user.to_h[:name])
|
41
29
|
end
|
42
30
|
end
|
43
31
|
|
@@ -89,14 +77,6 @@ describe 'Commands / Create' do
|
|
89
77
|
expect(result.value).to eql(name: 'Piotr', title: 'Finish command-api')
|
90
78
|
end
|
91
79
|
|
92
|
-
it 'returns validation object with errors on failed validation' do
|
93
|
-
result = users.try { users.create.call(name: 'Piotr') }
|
94
|
-
|
95
|
-
expect(result.error).to be_instance_of(Test::ValidationError)
|
96
|
-
expect(result.error.message).to eql(":name and :email are required")
|
97
|
-
expect(container.relations.users.count).to be(2)
|
98
|
-
end
|
99
|
-
|
100
80
|
describe '"result" option' do
|
101
81
|
it 'returns a single tuple when set to :one' do
|
102
82
|
configuration.commands(:users) do
|
@@ -122,7 +102,7 @@ describe 'Commands / Create' do
|
|
122
102
|
end
|
123
103
|
end
|
124
104
|
container
|
125
|
-
}.to raise_error(
|
105
|
+
}.to raise_error(Dry::Types::ConstraintError)
|
126
106
|
end
|
127
107
|
end
|
128
108
|
|
@@ -1,15 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'Building up a command graph for nested input' do
|
3
|
+
RSpec.describe 'Building up a command graph for nested input' do
|
4
4
|
include_context 'command graph'
|
5
5
|
|
6
6
|
it 'creates a command graph for nested input :one result as root' do
|
7
7
|
configuration.commands(:tasks) do
|
8
8
|
define(:create) do
|
9
9
|
result :one
|
10
|
+
before :associate
|
10
11
|
|
11
|
-
def
|
12
|
-
|
12
|
+
def associate(tuple, user)
|
13
|
+
tuple.merge(user: user.fetch(:name))
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -66,8 +67,10 @@ describe 'Building up a command graph for nested input' do
|
|
66
67
|
it 'creates a command graph for nested input with :many results as root' do
|
67
68
|
configuration.commands(:tasks) do
|
68
69
|
define(:create) do
|
69
|
-
|
70
|
-
|
70
|
+
before :associate
|
71
|
+
|
72
|
+
def associate(tuples, user)
|
73
|
+
tuples.map { |t| t.merge(user: user.fetch(:name)) }
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|
@@ -120,16 +123,19 @@ describe 'Building up a command graph for nested input' do
|
|
120
123
|
it 'updates graph elements cleanly' do
|
121
124
|
configuration.commands(:tasks) do
|
122
125
|
define(:create) do
|
123
|
-
|
124
|
-
|
126
|
+
before :associate
|
127
|
+
|
128
|
+
def associate(tuples, user)
|
129
|
+
tuples.map { |t| t.merge(user: user.fetch(:name)) }
|
125
130
|
end
|
126
131
|
end
|
127
132
|
|
128
133
|
define(:update) do
|
129
134
|
result :one
|
135
|
+
before :associate
|
130
136
|
|
131
|
-
def
|
132
|
-
|
137
|
+
def associate(tuple, user)
|
138
|
+
tuple.merge(user: user.fetch(:name))
|
133
139
|
end
|
134
140
|
end
|
135
141
|
|
@@ -186,9 +192,7 @@ describe 'Building up a command graph for nested input' do
|
|
186
192
|
|
187
193
|
create.call(initial)
|
188
194
|
|
189
|
-
container.command(:tasks).create.
|
190
|
-
[{ title: 'Task One'}], { name: 'Jane' }
|
191
|
-
)
|
195
|
+
container.command(:tasks).create.with([{ title: 'Task One'}]).(name: 'Jane')
|
192
196
|
|
193
197
|
expect(container.relation(:tasks)).to match_array([
|
194
198
|
{ title: 'Change Name', user: 'Johnny' },
|
@@ -233,8 +237,10 @@ describe 'Building up a command graph for nested input' do
|
|
233
237
|
|
234
238
|
configuration.commands(:tasks) do
|
235
239
|
define(:create) do
|
236
|
-
|
237
|
-
|
240
|
+
before :associate
|
241
|
+
|
242
|
+
def associate(tuples, user)
|
243
|
+
tuples.map { |t| t.merge(user: user.fetch(:name)) }
|
238
244
|
end
|
239
245
|
end
|
240
246
|
end
|
@@ -1,23 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'dry-struct'
|
3
3
|
|
4
|
-
describe 'Commands / Update' do
|
4
|
+
RSpec.describe 'Commands / Update' do
|
5
5
|
include_context 'container'
|
6
6
|
include_context 'users and tasks'
|
7
7
|
|
8
8
|
subject(:users) { container.commands.users }
|
9
9
|
|
10
10
|
before do
|
11
|
-
module Test
|
12
|
-
UserValidator = Class.new do
|
13
|
-
ValidationError = Class.new(ROM::CommandError)
|
14
|
-
|
15
|
-
def self.call(params)
|
16
|
-
raise ValidationError, ":email is required" unless params[:email]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
11
|
configuration.relation(:users) do
|
22
12
|
register_as :users
|
23
13
|
|
@@ -31,13 +21,11 @@ describe 'Commands / Update' do
|
|
31
21
|
end
|
32
22
|
|
33
23
|
configuration.commands(:users) do
|
34
|
-
define(:update)
|
35
|
-
validator Test::UserValidator
|
36
|
-
end
|
24
|
+
define(:update)
|
37
25
|
end
|
38
26
|
end
|
39
27
|
|
40
|
-
it 'update tuples
|
28
|
+
it 'update tuples' do
|
41
29
|
result = users.try {
|
42
30
|
users.update.all(name: 'Jane').call(email: 'jane.doe@test.com')
|
43
31
|
}
|
@@ -46,17 +34,6 @@ describe 'Commands / Update' do
|
|
46
34
|
.to match_array([{ name: 'Jane', email: 'jane.doe@test.com' }])
|
47
35
|
end
|
48
36
|
|
49
|
-
it 'returns validation object with errors on failed validation' do
|
50
|
-
result = users.try { users.update.all(name: 'Jane').call(email: nil) }
|
51
|
-
|
52
|
-
expect(result.error).to be_instance_of(Test::ValidationError)
|
53
|
-
expect(result.error.message).to eql(':email is required')
|
54
|
-
|
55
|
-
expect(container.relations.users.restrict(name: 'Jane')).to match_array([
|
56
|
-
{ name: 'Jane', email: 'jane@doe.org' }
|
57
|
-
])
|
58
|
-
end
|
59
|
-
|
60
37
|
describe '"result" option' do
|
61
38
|
it 'returns a single tuple when set to :one' do
|
62
39
|
configuration.commands(:users) do
|
@@ -80,7 +57,7 @@ describe 'Commands / Update' do
|
|
80
57
|
end
|
81
58
|
end
|
82
59
|
container
|
83
|
-
}.to raise_error(
|
60
|
+
}.to raise_error(Dry::Types::ConstraintError)
|
84
61
|
end
|
85
62
|
end
|
86
63
|
|
@@ -3,7 +3,7 @@ require 'rom/memory'
|
|
3
3
|
|
4
4
|
require 'logger'
|
5
5
|
|
6
|
-
describe '
|
6
|
+
RSpec.describe 'Gateways / Setting logger' do
|
7
7
|
let(:logger_class) do
|
8
8
|
Class.new do
|
9
9
|
attr_reader :messages
|
@@ -26,7 +26,7 @@ describe 'Repositories / Setting logger' do
|
|
26
26
|
container = ROM.container(:memory) do |config|
|
27
27
|
config.gateways[:default].use_logger(logger)
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
container.gateways[:default].logger.info("test")
|
31
31
|
|
32
32
|
expect(logger.messages).to eql(["test"])
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'rom/memory'
|
3
3
|
|
4
|
-
describe 'Mapper definition DSL' do
|
4
|
+
RSpec.describe 'Mapper definition DSL' do
|
5
5
|
include_context 'container'
|
6
6
|
|
7
7
|
before do
|
@@ -16,7 +16,7 @@ describe 'Mapper definition DSL' do
|
|
16
16
|
{ type: 'home' },
|
17
17
|
{}
|
18
18
|
])
|
19
|
-
users.insert(name: 'Jane')
|
19
|
+
users.insert(name: 'Jane', emails: [])
|
20
20
|
end
|
21
21
|
|
22
22
|
describe 'ungroup' do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'Mapper definition DSL' do
|
3
|
+
RSpec.describe 'Mapper definition DSL' do
|
4
4
|
include_context 'container'
|
5
5
|
include_context 'users and tasks'
|
6
6
|
|
@@ -14,7 +14,7 @@ describe 'Mapper definition DSL' do
|
|
14
14
|
tuple.merge(user: users.restrict(name: tuple[:name]).first)
|
15
15
|
}
|
16
16
|
|
17
|
-
|
17
|
+
new(tuples)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'rom/memory'
|
3
3
|
|
4
|
-
describe 'Using in-memory gateways for cross-repo access' do
|
4
|
+
RSpec.describe 'Using in-memory gateways for cross-repo access' do
|
5
5
|
let(:configuration) do
|
6
6
|
ROM::Configuration.new(left: :memory, right: :memory, main: :memory)
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'dry-struct'
|
3
3
|
|
4
|
-
describe 'Configuring ROM' do
|
4
|
+
RSpec.describe 'Configuring ROM' do
|
5
5
|
context 'with existing schema' do
|
6
6
|
include_context 'container'
|
7
7
|
include_context 'users and tasks'
|
@@ -41,9 +41,8 @@ describe 'Configuring ROM' do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe 'defining classes' do
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
let(:container) do
|
45
|
+
ROM.container(:memory) do |config|
|
47
46
|
class Test::UserRelation < ROM::Relation[:memory]
|
48
47
|
dataset :users
|
49
48
|
|
@@ -64,7 +63,9 @@ describe 'Configuring ROM' do
|
|
64
63
|
config.register_relation(Test::UserRelation, Test::TaskRelation)
|
65
64
|
config.register_command(Test::CreateUser)
|
66
65
|
end
|
66
|
+
end
|
67
67
|
|
68
|
+
it 'sets up registries based on class definitions' do
|
68
69
|
expect(container.relations.users).to be_kind_of(Test::UserRelation)
|
69
70
|
expect(container.relations.users.tasks).to be(container.relations.tasks)
|
70
71
|
|
@@ -73,6 +74,11 @@ describe 'Configuring ROM' do
|
|
73
74
|
expect(container.relations.tasks).to be_kind_of(Test::TaskRelation)
|
74
75
|
expect(container.relations.tasks.users).to be(container.relations.users)
|
75
76
|
end
|
77
|
+
|
78
|
+
it 'sets empty schemas by default' do
|
79
|
+
expect(container.relations[:users].schema).to be_empty
|
80
|
+
expect(container.relations[:tasks].schema).to be_empty
|
81
|
+
end
|
76
82
|
end
|
77
83
|
|
78
84
|
describe 'quick setup' do
|
@@ -33,16 +33,20 @@ shared_context 'command graph' do
|
|
33
33
|
|
34
34
|
configuration.commands(:books) do
|
35
35
|
define(:create) do
|
36
|
-
|
37
|
-
|
36
|
+
before :associate
|
37
|
+
|
38
|
+
def associate(tuples, user)
|
39
|
+
tuples.map { |t| t.merge(user: user.fetch(:name)) }
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
44
|
configuration.commands(:tags) do
|
43
45
|
define(:create) do
|
44
|
-
|
45
|
-
|
46
|
+
before :associate
|
47
|
+
|
48
|
+
def associate(tuples, task)
|
49
|
+
tuples.map { |t| t.merge(task: task.fetch(:title)) }
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|