File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ def connect(name, connection_info)
3333
3434 def self . validate ( name , connection_info )
3535 @transports ||= { }
36+ require "puppet/transport/schema/#{ name } " unless @transports . key? name
3637 transport_schema = @transports [ name ]
3738 raise Puppet ::DevError , 'Transport for `%{target}` not registered' % { target : name } if transport_schema . nil?
3839
Original file line number Diff line number Diff line change 129129
130130 describe '#self.validate' do
131131 context 'when the transport being validated has not be registered' do
132- it { expect { described_class . validate ( 'wibble' , { } ) } . to raise_error Puppet :: DevError , %r{Transport for `wibble` not registered } }
132+ it { expect { described_class . validate ( 'wibble' , { } ) } . to raise_error LoadError , %r{cannot load such file -- puppet/transport/schema/wibble } }
133133 end
134134
135135 context 'when the transport being validated has been registered' do
136136 let ( :schema ) { { name : 'validate' , desc : 'a minimal connection' , connection_info : { } } }
137+ let ( :schema_def ) { instance_double ( 'Puppet::ResourceApi::TransportSchemaDef' , 'schema_def' ) }
138+
139+ it 'validates the connection_info' do
140+ allow ( Puppet ::ResourceApi ::TransportSchemaDef ) . to receive ( :new ) . with ( schema ) . and_return ( schema_def )
137141
138- it 'continues to validate the connection_info' do
139- # rubocop:disable RSpec/AnyInstance
140- expect_any_instance_of ( Puppet ::ResourceApi ::TransportSchemaDef ) . to receive ( :check_schema ) . with ( { } )
141- expect_any_instance_of ( Puppet ::ResourceApi ::TransportSchemaDef ) . to receive ( :validate ) . with ( { } )
142- # rubocop:enable RSpec/AnyInstance
143142 described_class . register ( schema )
144- described_class . validate ( 'validate' , { } )
143+
144+ expect ( schema_def ) . to receive ( :check_schema ) . with ( 'connection_info' ) . and_return ( nil )
145+ expect ( schema_def ) . to receive ( :validate ) . with ( 'connection_info' ) . and_return ( nil )
146+
147+ described_class . validate ( 'validate' , 'connection_info' )
145148 end
146149 end
147150 end
You can’t perform that action at this time.
0 commit comments