simmer 1.0.0.pre.alpha.7 → 1.0.0.pre.alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/simmer/version.rb +1 -1
- data/simmer.gemspec +9 -2
- metadata +11 -80
- data/spec/config/simmer.yaml.ci +0 -22
- data/spec/db/database.sql +0 -1
- data/spec/db/tables.sql +0 -20
- data/spec/db_helper.rb +0 -26
- data/spec/fixtures/agent_fixtures.yaml +0 -14
- data/spec/fixtures/configuration.yaml +0 -11
- data/spec/fixtures/noc_list.csv +0 -3
- data/spec/fixtures/specifications/load_noc_list.yaml +0 -37
- data/spec/fixtures/yaml_reader/bar.yaml +0 -2
- data/spec/fixtures/yaml_reader/baz/baz.yaml +0 -2
- data/spec/fixtures/yaml_reader/foo.yaml +0 -2
- data/spec/mocks/aws_s3_client.rb +0 -56
- data/spec/mocks/load_noc_list/pan.sh +0 -10
- data/spec/mocks/load_noc_list_bad_output/pan.sh +0 -10
- data/spec/mocks/out.rb +0 -14
- data/spec/mocks/spoon/kitchen.sh +0 -14
- data/spec/mocks/spoon/pan.sh +0 -14
- data/spec/simmer/configuration_spec.rb +0 -46
- data/spec/simmer/core_ext/hash_spec.rb +0 -16
- data/spec/simmer/database/fixture_set_spec.rb +0 -75
- data/spec/simmer/database/fixture_spec.rb +0 -57
- data/spec/simmer/externals/aws_file_system_spec.rb +0 -58
- data/spec/simmer/externals/mysql_database_spec.rb +0 -89
- data/spec/simmer/externals/spoon_client_spec.rb +0 -47
- data/spec/simmer/specification/act/params_spec.rb +0 -38
- data/spec/simmer/specification/act_spec.rb +0 -37
- data/spec/simmer/specification/assert_spec.rb +0 -29
- data/spec/simmer/specification/stage_spec.rb +0 -32
- data/spec/simmer/specification_spec.rb +0 -28
- data/spec/simmer/util/evaluator_spec.rb +0 -82
- data/spec/simmer/util/record_set_spec.rb +0 -84
- data/spec/simmer/util/record_spec.rb +0 -218
- data/spec/simmer/util/yaml_reader_spec.rb +0 -49
- data/spec/simmer_spec/files/noc_list.csv +0 -3
- data/spec/simmer_spec/fixtures/agent_fixtures.yaml +0 -14
- data/spec/simmer_spec.rb +0 -104
- data/spec/spec_helper.rb +0 -43
- /data/{bin → exe}/simmer +0 -0
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
require 'mocks/aws_s3_client'
|
12
|
-
|
13
|
-
describe Simmer::Externals::AwsFileSystem do
|
14
|
-
let(:bucket_name) { 'test' }
|
15
|
-
let(:encryption) { 'AES256' }
|
16
|
-
let(:files_dir) { File.join('spec', 'fixtures') }
|
17
|
-
let(:specification_path) { File.join('specifications', 'load_noc_list.yaml') }
|
18
|
-
let(:specification_config) { yaml_fixture(specification_path).merge(path: specification_path) }
|
19
|
-
let(:specification) { Simmer::Specification.make(specification_config) }
|
20
|
-
let(:aws_s3_client_stub) { AwsS3Client.new }
|
21
|
-
|
22
|
-
subject { described_class.new(aws_s3_client_stub, bucket_name, encryption, files_dir) }
|
23
|
-
|
24
|
-
describe 'initialization' do
|
25
|
-
it "requires bucket ends in 'test'" do
|
26
|
-
expect do
|
27
|
-
described_class.new(aws_s3_client_stub, 'hehe', encryption, files_dir)
|
28
|
-
end.to raise_error(ArgumentError)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
specify '#write transfers all files' do
|
33
|
-
subject.write!(specification.stage.files)
|
34
|
-
|
35
|
-
expected = {
|
36
|
-
'input/noc_list.csv' => {
|
37
|
-
body: "call_sign,first,last\niron_man,Tony,Stark\nhulk,Bruce,Banner\n"
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
expect(aws_s3_client_stub.store).to eq(expected)
|
42
|
-
end
|
43
|
-
|
44
|
-
specify '#clean! deletes all files' do
|
45
|
-
aws_s3_client_stub.put_object(
|
46
|
-
body: 'Test File',
|
47
|
-
bucket: bucket_name,
|
48
|
-
key: 'test_key.txt',
|
49
|
-
server_side_encryption: encryption
|
50
|
-
)
|
51
|
-
|
52
|
-
subject.clean!
|
53
|
-
|
54
|
-
expected = {}
|
55
|
-
|
56
|
-
expect(aws_s3_client_stub.store).to eq(expected)
|
57
|
-
end
|
58
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
require 'db_helper'
|
12
|
-
|
13
|
-
describe Simmer::Externals::MysqlDatabase do
|
14
|
-
let(:exclude_tables) { [] }
|
15
|
-
let(:raw_fixtures) { yaml_read('spec', 'fixtures', 'agent_fixtures.yaml') }
|
16
|
-
let(:fixture_set) { Simmer::Database::FixtureSet.new(raw_fixtures) }
|
17
|
-
let(:spec_path) { File.join('specifications', 'load_noc_list.yaml') }
|
18
|
-
let(:spec_config) { yaml_fixture(spec_path).merge(path: spec_path) }
|
19
|
-
let(:specification) { Simmer::Specification.make(spec_config) }
|
20
|
-
|
21
|
-
subject { described_class.new(db_helper_client, exclude_tables) }
|
22
|
-
|
23
|
-
before(:each) do
|
24
|
-
db_helper_clean_schema
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'initialization' do
|
28
|
-
it "requires database ends in 'test'" do
|
29
|
-
expect do
|
30
|
-
described_class.new(OpenStruct.new(query_options: { database: 'hehe' }))
|
31
|
-
end.to raise_error(ArgumentError)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
specify '#seed! adds records' do
|
36
|
-
fixtures = specification.stage.fixtures.map { |f| fixture_set.get!(f) }
|
37
|
-
|
38
|
-
subject.seed!(fixtures)
|
39
|
-
|
40
|
-
actual = db_helper_client.query('SELECT * FROM agents ORDER BY call_sign').to_a
|
41
|
-
|
42
|
-
call_signs = actual.map { |r| r['call_sign'] }
|
43
|
-
|
44
|
-
expect(call_signs).to eq(%w[hulk iron_man])
|
45
|
-
end
|
46
|
-
|
47
|
-
specify '#clean! removes all records without worrying about foreign keys' do
|
48
|
-
db_helper_client.query("INSERT INTO agents (id, call_sign) VALUES (1, 'thor')")
|
49
|
-
db_helper_client.query("INSERT INTO notes (agent_id, note) VALUES (1, 'thor')")
|
50
|
-
|
51
|
-
agent_count = db_helper_client.query('SELECT * FROM agents').to_a.length
|
52
|
-
note_count = db_helper_client.query('SELECT * FROM notes').to_a.length
|
53
|
-
|
54
|
-
expect(agent_count).to eq(1)
|
55
|
-
expect(note_count).to eq(1)
|
56
|
-
|
57
|
-
table_count = subject.clean!
|
58
|
-
|
59
|
-
expect(table_count).to eq(2)
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '#records' do
|
63
|
-
before(:each) do
|
64
|
-
db_helper_client.query("INSERT INTO agents (id, call_sign) VALUES (1, 'thor')")
|
65
|
-
db_helper_client.query("INSERT INTO agents (id, call_sign) VALUES (2, 'black_widow')")
|
66
|
-
end
|
67
|
-
|
68
|
-
specify 'when fields is empty' do
|
69
|
-
actual = subject.records(:agents)
|
70
|
-
|
71
|
-
expected = [
|
72
|
-
{
|
73
|
-
'id' => 1,
|
74
|
-
'call_sign' => 'thor',
|
75
|
-
'first' => nil,
|
76
|
-
'last' => nil
|
77
|
-
},
|
78
|
-
{
|
79
|
-
'id' => 2,
|
80
|
-
'call_sign' => 'black_widow',
|
81
|
-
'first' => nil,
|
82
|
-
'last' => nil
|
83
|
-
}
|
84
|
-
]
|
85
|
-
|
86
|
-
expect(actual).to eq(expected)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
require 'db_helper'
|
12
|
-
|
13
|
-
describe Simmer::Externals::SpoonClient do
|
14
|
-
let(:files_dir) { File.join('spec', 'fixtures') }
|
15
|
-
let(:specification_path) { File.join('specifications', 'load_noc_list.yaml') }
|
16
|
-
let(:specification_config) { yaml_fixture(specification_path).merge(path: specification_path) }
|
17
|
-
let(:specification) { Simmer::Specification.make(specification_config) }
|
18
|
-
|
19
|
-
let(:spoon) do
|
20
|
-
Pdi::Spoon.new(
|
21
|
-
dir: File.join('spec', 'mocks', 'spoon'),
|
22
|
-
args: arg
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
subject { described_class.new(files_dir, spoon) }
|
27
|
-
|
28
|
-
context 'when PDI executes successfully' do
|
29
|
-
let(:arg) { 0 }
|
30
|
-
|
31
|
-
specify '#run returns code 0 from executor' do
|
32
|
-
result = subject.run(specification, simmer_config)
|
33
|
-
|
34
|
-
expect(result.execution_result.code).to eq(0)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when PDI executes un-successfully' do
|
39
|
-
let(:arg) { 1 }
|
40
|
-
|
41
|
-
specify '#run returns non-zero code from executor' do
|
42
|
-
result = subject.run(specification, simmer_config)
|
43
|
-
|
44
|
-
expect(result.execution_result.code).to eq(1)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
|
12
|
-
describe Simmer::Specification::Act::Params do
|
13
|
-
let(:spec_path) { File.join('specifications', 'load_noc_list.yaml') }
|
14
|
-
let(:params_config) { yaml_fixture(spec_path).dig('act', 'params') }
|
15
|
-
|
16
|
-
let(:config) do
|
17
|
-
{
|
18
|
-
codes: {
|
19
|
-
the_secret_one: '123ABC'
|
20
|
-
}
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:files_path) { 'files_are_here' }
|
25
|
-
|
26
|
-
subject { described_class.make(params_config) }
|
27
|
-
|
28
|
-
it '#compile combines files and keys' do
|
29
|
-
actual = subject.compile(files_path, config)
|
30
|
-
expected_path = File.expand_path(File.join(files_path, subject.files.values.first))
|
31
|
-
expected = {
|
32
|
-
'input_file' => expected_path,
|
33
|
-
'code' => 'The secret code is: 123ABC'
|
34
|
-
}
|
35
|
-
|
36
|
-
expect(actual).to eq(expected)
|
37
|
-
end
|
38
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
|
12
|
-
describe Simmer::Specification::Act do
|
13
|
-
let(:path) { File.join('specifications', 'load_noc_list.yaml') }
|
14
|
-
|
15
|
-
let(:config) { yaml_fixture(path)['act'] }
|
16
|
-
|
17
|
-
describe 'initialization using acts_as_hashable' do
|
18
|
-
subject { described_class.make(config) }
|
19
|
-
|
20
|
-
it 'sets repository' do
|
21
|
-
expect(subject.repository).to eq('top_secret')
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'sets name' do
|
25
|
-
expect(subject.name).to eq('load_noc_list')
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'sets type' do
|
29
|
-
expect(subject.type).to eq('transformation')
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'sets params' do
|
33
|
-
expect(subject.params.files).to eq('input_file' => 'noc_list.csv')
|
34
|
-
expect(subject.params.keys).to eq('code' => 'The secret code is: {codes.the_secret_one}')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
|
12
|
-
describe Simmer::Specification::Assert do
|
13
|
-
let(:path) { File.join('specifications', 'load_noc_list.yaml') }
|
14
|
-
|
15
|
-
let(:config) { yaml_fixture(path)['assert'] }
|
16
|
-
|
17
|
-
describe 'initialization using acts_as_hashable' do
|
18
|
-
subject { described_class.make(config) }
|
19
|
-
|
20
|
-
it 'sets assertions' do
|
21
|
-
expect(subject.assertions.length).to eq(3)
|
22
|
-
expect(subject.assertions.first.name).to eq('agents')
|
23
|
-
expect(subject.assertions.first.record_set.length).to eq(2)
|
24
|
-
expect(subject.assertions[1].name).to eq('agents')
|
25
|
-
expect(subject.assertions[1].record_set.length).to eq(1)
|
26
|
-
expect(subject.assertions.last.value).to eq('output to stdout')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
|
12
|
-
describe Simmer::Specification::Stage do
|
13
|
-
let(:path) { File.join('specifications', 'load_noc_list.yaml') }
|
14
|
-
|
15
|
-
let(:config) { yaml_fixture(path)['stage'] }
|
16
|
-
|
17
|
-
describe 'initialization using acts_as_hashable' do
|
18
|
-
subject { described_class.make(config) }
|
19
|
-
|
20
|
-
it 'sets files' do
|
21
|
-
expect(subject.files.length).to eq(1)
|
22
|
-
expect(subject.files.first.src).to eq('noc_list.csv')
|
23
|
-
expect(subject.files.first.dest).to eq('input/noc_list.csv')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'sets fixtures' do
|
27
|
-
expect(subject.fixtures.length).to eq(2)
|
28
|
-
expect(subject.fixtures.first).to eq('iron_man')
|
29
|
-
expect(subject.fixtures.last).to eq('hulk')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
|
12
|
-
describe Simmer::Specification do
|
13
|
-
let(:path) { File.join('specifications', 'load_noc_list.yaml') }
|
14
|
-
|
15
|
-
let(:config) { yaml_fixture(path).merge(path: path) }
|
16
|
-
|
17
|
-
describe 'initialization using acts_as_hashable' do
|
18
|
-
subject { described_class.make(config) }
|
19
|
-
|
20
|
-
it 'sets name' do
|
21
|
-
expect(subject.name).to eq('Declassify Users')
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'sets path' do
|
25
|
-
expect(subject.path).to eq(path)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
|
12
|
-
describe Simmer::Util::Evaluator do
|
13
|
-
let(:template) do
|
14
|
-
'The {traits.speed} {animal} jumps over the {thing}.'
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#evaluate' do
|
18
|
-
context 'when input is hash with string keys' do
|
19
|
-
let(:input) do
|
20
|
-
{
|
21
|
-
'animal' => :fox,
|
22
|
-
'traits' => {
|
23
|
-
'speed' => :quick
|
24
|
-
},
|
25
|
-
'thing' => :wall
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'renders template' do
|
30
|
-
expected = 'The quick fox jumps over the wall.'
|
31
|
-
|
32
|
-
expect(subject.evaluate(template, input)).to eq(expected)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'when input is hash with symbol keys' do
|
37
|
-
let(:input) do
|
38
|
-
{
|
39
|
-
animal: :fox,
|
40
|
-
traits: {
|
41
|
-
speed: :quick
|
42
|
-
},
|
43
|
-
thing: :wall
|
44
|
-
}
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'renders template' do
|
48
|
-
expected = 'The quick fox jumps over the wall.'
|
49
|
-
|
50
|
-
expect(subject.evaluate(template, input)).to eq(expected)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'when input is OpenStruct' do
|
55
|
-
let(:input) do
|
56
|
-
OpenStruct.new(
|
57
|
-
animal: :fox,
|
58
|
-
traits: OpenStruct.new(
|
59
|
-
speed: :quick
|
60
|
-
),
|
61
|
-
thing: :wall
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'renders template' do
|
66
|
-
expected = 'The quick fox jumps over the wall.'
|
67
|
-
|
68
|
-
expect(subject.evaluate(template, input)).to eq(expected)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'when input is nil' do
|
73
|
-
let(:input) { nil }
|
74
|
-
|
75
|
-
it 'renders against nil' do
|
76
|
-
expected = 'The jumps over the .'
|
77
|
-
|
78
|
-
expect(subject.evaluate(template, input)).to eq(expected)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'spec_helper'
|
11
|
-
|
12
|
-
describe Simmer::Util::RecordSet do
|
13
|
-
let(:hash1) do
|
14
|
-
{
|
15
|
-
a: 'a',
|
16
|
-
b: 'b'
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:string_hash1) do
|
21
|
-
{
|
22
|
-
'a' => 'a',
|
23
|
-
'b' => 'b'
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
let(:hash2) do
|
28
|
-
{
|
29
|
-
c: 'c',
|
30
|
-
d: 'd'
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
let(:string_hash2) do
|
35
|
-
{
|
36
|
-
'c' => 'c',
|
37
|
-
'd' => 'd'
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
let(:hash3) do
|
42
|
-
{
|
43
|
-
e: 'e',
|
44
|
-
f: 'f'
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
subject { described_class.new([hash1, hash2]) }
|
49
|
-
|
50
|
-
describe 'equality' do
|
51
|
-
specify 'hash order does not matter' do
|
52
|
-
subject2 = described_class.new([hash2, hash1])
|
53
|
-
|
54
|
-
expect(subject).to eq(subject2)
|
55
|
-
expect(subject).to eql(subject2)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
specify '#keys includes all record keys' do
|
60
|
-
expect(subject.keys).to eq(%w[a b c d])
|
61
|
-
end
|
62
|
-
|
63
|
-
specify '#to_h includes record hashes' do
|
64
|
-
expect(subject.to_h).to eq('records' => [string_hash1, string_hash2])
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'initialization' do
|
68
|
-
specify 'can accept a hash' do
|
69
|
-
subject = described_class.new(hash1)
|
70
|
-
|
71
|
-
expect(subject.records.length).to eq(1)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
specify '#& returns intersection of both record sets' do
|
76
|
-
subject1 = described_class.new([hash1, hash2])
|
77
|
-
subject2 = described_class.new([hash1, hash3])
|
78
|
-
|
79
|
-
expected = described_class.new([hash1])
|
80
|
-
actual = subject1 & subject2
|
81
|
-
|
82
|
-
expect(actual).to eq(expected)
|
83
|
-
end
|
84
|
-
end
|