rom 2.0.2 → 3.0.0.beta1
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 -4
- data/CHANGELOG.md +34 -1
- data/Gemfile +16 -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 +70 -41
- data/lib/rom/command_registry.rb +7 -18
- data/lib/rom/commands/class_interface.rb +7 -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_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 +1 -1
- data/lib/rom/container.rb +0 -2
- 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 +23 -6
- 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/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 +94 -26
- data/lib/rom/relation/curried.rb +15 -15
- data/lib/rom/relation/view_dsl.rb +31 -0
- data/lib/rom/relation.rb +49 -34
- data/lib/rom/schema/dsl.rb +7 -9
- data/lib/rom/schema/type.rb +115 -0
- data/lib/rom/schema.rb +218 -18
- 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 +3 -1
- 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 +4 -3
- 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 +1 -1
- 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 +269 -0
- data/spec/unit/rom/commands/result_spec.rb +1 -1
- data/spec/unit/rom/commands_spec.rb +9 -3
- data/spec/unit/rom/configuration_spec.rb +1 -1
- data/spec/unit/rom/container_spec.rb +11 -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/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/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 +10 -6
- data/spec/unit/rom/relation/view_spec.rb +112 -0
- data/spec/unit/rom/relation_spec.rb +16 -2
- data/spec/unit/rom/schema/accessing_attributes_spec.rb +52 -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/wrap_spec.rb +17 -0
- data/spec/unit/rom/schema_spec.rb +2 -2
- metadata +69 -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,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,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
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# this is needed for guard to work, not sure why :(
|
4
|
-
require "bundler"
|
5
|
-
Bundler.setup
|
6
|
-
|
7
|
-
if ENV['COVERAGE'] == 'true' && RUBY_ENGINE == 'ruby' && RUBY_VERSION='2.3.1'
|
1
|
+
if ENV['COVERAGE'] == 'true' && RUBY_ENGINE == 'ruby' && RUBY_VERSION == '2.3.1'
|
8
2
|
require "simplecov"
|
9
3
|
SimpleCov.start do
|
10
4
|
add_filter '/spec/'
|
@@ -13,8 +7,8 @@ end
|
|
13
7
|
|
14
8
|
SPEC_ROOT = root = Pathname(__FILE__).dirname
|
15
9
|
|
16
|
-
require '
|
17
|
-
|
10
|
+
require 'dry/core/deprecations'
|
11
|
+
Dry::Core::Deprecations.set_logger!(SPEC_ROOT.join('../log/deprecations.log'))
|
18
12
|
|
19
13
|
require 'rom'
|
20
14
|
|
@@ -42,6 +36,8 @@ def T(*args)
|
|
42
36
|
end
|
43
37
|
|
44
38
|
RSpec.configure do |config|
|
39
|
+
config.include(SchemaHelpers)
|
40
|
+
|
45
41
|
config.after do
|
46
42
|
Test.remove_constants
|
47
43
|
end
|
@@ -49,4 +45,6 @@ RSpec.configure do |config|
|
|
49
45
|
config.around do |example|
|
50
46
|
ConstantLeakFinder.find(example)
|
51
47
|
end
|
48
|
+
|
49
|
+
config.disable_monkey_patching!
|
52
50
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'dry-types'
|
2
|
+
|
3
|
+
module SchemaHelpers
|
4
|
+
def define_schema(source, attrs)
|
5
|
+
ROM::Schema.define(
|
6
|
+
source,
|
7
|
+
attributes: attrs.map { |name, type| define_type(name, type, source: source) }
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
def define_type(name, id, **opts)
|
12
|
+
ROM::Types.const_get(id).meta(name: name, **opts)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rom/array_dataset'
|
2
|
+
|
3
|
+
RSpec.describe ROM::ArrayDataset do
|
4
|
+
let(:klass) do
|
5
|
+
Class.new do
|
6
|
+
include ROM::ArrayDataset
|
7
|
+
|
8
|
+
def self.row_proc
|
9
|
+
-> i { i.each_with_object({}) { |(k,v),h| h[k.to_sym] = v } }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it_behaves_like 'an enumerable dataset' do
|
15
|
+
describe '#flatten' do
|
16
|
+
let(:data) { [[{ 'name' => 'Jane' }], [{ 'name' => 'Joe' }]] }
|
17
|
+
|
18
|
+
it 'returns a new dataset with flattened data' do
|
19
|
+
result = dataset.flatten
|
20
|
+
|
21
|
+
expect(result).to match_array([{ name: 'Jane' }, { name: 'Joe' }])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#map!' do
|
26
|
+
context 'with a block' do
|
27
|
+
it 'returns a new dataset with mapped data' do
|
28
|
+
dataset.map! do |row|
|
29
|
+
row.merge(age: 21)
|
30
|
+
end
|
31
|
+
|
32
|
+
expect(dataset).to match_array([
|
33
|
+
{ name: 'Jane', age: 21 }, { name: 'Joe', age: 21 }
|
34
|
+
])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'without a block' do
|
39
|
+
it 'returns an enumerator' do
|
40
|
+
result = dataset.map!
|
41
|
+
|
42
|
+
expect(result).to be_instance_of(Enumerator)
|
43
|
+
|
44
|
+
expect(result).to match_array([
|
45
|
+
{ name: 'Jane' }, { name: 'Joe' }
|
46
|
+
])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#values_at' do
|
52
|
+
it 'returns a new dataset with rows at given indices' do
|
53
|
+
result = dataset.values_at(1)
|
54
|
+
|
55
|
+
expect(result).to match_array([{ name: 'Joe' }])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|