/
splitter_test.rb
39 lines (29 loc) · 974 Bytes
/
splitter_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require_relative '../../helper'
require 'integrate/handlers/splitter'
require 'integrate/channel'
module Integrate
class SplitterTest < MiniTest::Unit::TestCase
def test_instantiation
splitter = Splitter.new(in: Channel.new,
out: Channel.new)
refute_nil(splitter)
end
def test_instantiation_with_block
splitter = Splitter.new(in: Channel.new,
out: Channel.new) {}
refute_nil(splitter)
end
def test_splits_correctly
splitter = Splitter.new(in: Channel.new,
out: Channel.new) do |message|
message["items"].each_with_object([]) do |item_id, result|
result << {"item_id" => item_id}
end
end
in_message = {"items" => [1,5,54]}
assert_equal([{"item_id" => 1},
{"item_id" => 5},
{"item_id" => 54}], splitter.split(in_message))
end
end
end