File tree Expand file tree Collapse file tree 4 files changed +78
-0
lines changed Expand file tree Collapse file tree 4 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 7
7
8
8
require_relative 'factories/config/destination_factory'
9
9
require_relative 'factories/config/source_factory'
10
+ require_relative 'factories/destination/one_drive_factory'
10
11
require_relative 'factories/service/one_drive_factory'
11
12
require_relative 'factories/source/url_factory'
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../../lib/destination/one_drive'
4
+
5
+ FactoryBot . define do
6
+ factory :destination_one_drive , class : DocumentTransfer ::Destination ::OneDrive do
7
+ transient do
8
+ config { build ( :config_destination , type : :onedrive , path : 'rspec-docs' ) }
9
+ end
10
+
11
+ initialize_with { new ( config ) }
12
+ end
13
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../lib/destination'
4
+
5
+ RSpec . describe DocumentTransfer ::Destination do
6
+ describe '.load' do
7
+ let ( :config ) { build ( :config_destination , type : destination_type ) }
8
+ let ( :destination ) { build ( :destination_one_drive ) }
9
+ let ( :destination_type ) { :onedrive }
10
+
11
+ before do
12
+ allow ( destination . class ) . to receive ( :new ) . and_return ( destination )
13
+ end
14
+
15
+ it 'returns the proper destination' do
16
+ expect ( described_class . load ( config ) ) . to eq ( destination )
17
+ end
18
+
19
+ context 'when an invalid destination type is provided' do
20
+ before do
21
+ # If we try to set an invalid type directly on the config object, it
22
+ # will raise an error.
23
+ allow ( config ) . to receive ( :type ) . and_return ( :invalid )
24
+ end
25
+
26
+ it 'raises an exception' do
27
+ expect { described_class . load ( config ) } . to \
28
+ raise_error ( DocumentTransfer ::Destination ::InvalidDestinationError )
29
+ end
30
+ end
31
+ end
32
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../lib/source'
4
+
5
+ RSpec . describe DocumentTransfer ::Source do
6
+ describe '.load' do
7
+ let ( :config ) { build ( :config_source , type : source_type ) }
8
+ let ( :source ) { build ( :source_url ) }
9
+ let ( :source_type ) { :url }
10
+
11
+ before do
12
+ allow ( source . class ) . to receive ( :new ) . and_return ( source )
13
+ end
14
+
15
+ it 'returns the proper source' do
16
+ expect ( described_class . load ( config ) ) . to eq ( source )
17
+ end
18
+
19
+ context 'when an invalid source type is provided' do
20
+ before do
21
+ # If we try to set an invalid type directly on the config object, it
22
+ # will raise an error.
23
+ allow ( config ) . to receive ( :type ) . and_return ( :invalid )
24
+ end
25
+
26
+ it 'raises an exception' do
27
+ expect { described_class . load ( config ) } . to \
28
+ raise_error ( DocumentTransfer ::Source ::InvalidSourceError )
29
+ end
30
+ end
31
+ end
32
+ end
You can’t perform that action at this time.
0 commit comments