blob: 58ec1d1afca61b828cfce4482bfa69e06d1c0ccc (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Pipeline::Runner do
describe 'pipeline runner' do
before do
extractor = Class.new do
def initialize(options = {}); end
def extract(context); end
end
transformer = Class.new do
def initialize(options = {}); end
def transform(context, entry); end
end
loader = Class.new do
def initialize(options = {}); end
def load(context, entry); end
end
stub_const('BulkImports::Extractor', extractor)
stub_const('BulkImports::Transformer', transformer)
stub_const('BulkImports::Loader', loader)
pipeline = Class.new do
include BulkImports::Pipeline
extractor BulkImports::Extractor
transformer BulkImports::Transformer
loader BulkImports::Loader
end
stub_const('BulkImports::MyPipeline', pipeline)
end
it 'runs pipeline extractor, transformer, loader' do
context = instance_double(BulkImports::Pipeline::Context)
entries = [{ foo: :bar }]
expect_next_instance_of(BulkImports::Extractor) do |extractor|
expect(extractor).to receive(:extract).with(context).and_return(entries)
end
expect_next_instance_of(BulkImports::Transformer) do |transformer|
expect(transformer).to receive(:transform).with(context, entries.first).and_return(entries.first)
end
expect_next_instance_of(BulkImports::Loader) do |loader|
expect(loader).to receive(:load).with(context, entries.first)
end
BulkImports::MyPipeline.new.run(context)
end
end
end
|