-
Notifications
You must be signed in to change notification settings - Fork 2
/
assemble_marc_files_spec.rb
79 lines (56 loc) · 2.01 KB
/
assemble_marc_files_spec.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# frozen_string_literal: true
require 'rails_helper'
require 'support/mock_boxr'
module Boxr
MOCK_ROOT = Rails.root.join('spec', 'fixtures')
class Client
def initialize
@init = true
end
def file_from_path(path)
mock_client.file_from_path(File.join(MOCK_ROOT, path))
end
def folder_from_path(path)
mock_client.folder_from_path(File.join(MOCK_ROOT, path))
end
def folder_items(folder, options)
mock_client.folder_items(folder, options)
end
def download_file(file)
mock_client.download_file(file)
end
def upload_file(path, folder)
mock_client.upload_file(path, folder)
end
private
def mock_client
@mock_client ||= MockBoxr::Client.new
end
end
end
RSpec.describe AssembleMarcFiles::AssembleMarcFiles do
subject(:program) { described_class.new }
before { program }
describe '#execute' do
subject { program.execute }
let(:lib_ptg_box) { instance_double(LibPtgBox::LibPtgBox, 'lib_ptg_box', product_families: [product_family]) }
let(:product_family) { instance_double(LibPtgBox::ProductFamily, 'product_family') }
before do
allow(LibPtgBox::LibPtgBox).to receive(:new).and_return(lib_ptg_box)
allow(program).to receive(:synchronize).with(lib_ptg_box).and_return("synchronize\n")
allow(program).to receive(:assemble_marc_files).with(product_family).and_return("product_family\n")
end
it { is_expected.to eq("synchronize\nproduct_family\n") }
end
describe '#synchronize' do
subject { program.synchronize(lib_ptg_box) }
# let(:lib_ptg_box) { instance_double(LibPtgBox::LibPtgBox, 'lib_ptg_box') }
let(:lib_ptg_box) { LibPtgBox::LibPtgBox.new }
it { is_expected.to eq("synchronize\n") }
end
describe '#assemble_marc_files' do
subject { program.assemble_marc_files(product_family) }
let(:product_family) { instance_double(LibPtgBox::ProductFamily, 'product_family', name: 'product_name') }
it { is_expected.to eq(product_family.name + "\n") }
end
end