@@ -214,33 +214,26 @@ def delete(context, _name); end
214
214
it { expect { provider . set ( context , changes ) } . to raise_error %r{SimpleProvider cannot be used with a Type that is not ensurable} }
215
215
end
216
216
217
- context 'with a type with multiple namevars' do
218
- let ( :should_values ) { { name : 'title' , parent : 'foo' , wibble : 'wub' , ensure : 'present' } }
219
- let ( :title ) { 'foo#wub' }
217
+ context 'with changes from a composite namevar type' do
220
218
let ( :changes ) do
221
- { title =>
222
- {
223
- should : should_values ,
224
- } }
225
- end
226
- let ( :name_hash ) do
227
219
{
228
- title : title ,
229
- parent : 'foo' ,
230
- wibble : 'wub' ,
220
+ { name1 : 'value1' , name2 : 'value2' } =>
221
+ {
222
+ should : { name1 : 'value1' , name2 : 'value2' , ensure : 'present' } ,
223
+ } ,
231
224
}
232
225
end
233
226
234
227
before ( :each ) do
235
- allow ( context ) . to receive ( :creating ) . with ( title ) . and_yield
236
- allow ( context ) . to receive ( :type ) . and_return ( type_def )
237
- allow ( type_def ) . to receive ( :feature? ) . with ( 'simple_get_filter' )
228
+ allow ( context ) . to receive ( :creating ) . with ( name1 : 'value1' , name2 : 'value2' ) . and_yield
229
+ allow ( type_def ) . to receive ( :feature? ) . with ( 'simple_get_filter' ) . and_return ( true )
230
+ allow ( type_def ) . to receive ( :namevars ) . and_return ( [ :name1 , :name2 ] )
238
231
allow ( type_def ) . to receive ( :check_schema )
239
- allow ( type_def ) . to receive ( :namevars ) . and_return ( [ :parent , :wibble ] )
240
232
end
241
233
242
- it 'calls create once' do
243
- expect ( provider ) . to receive ( :create ) . with ( context , name_hash , should_values ) . once
234
+ it 'calls the crud methods with the right title' do
235
+ expect ( provider ) . to receive ( :create ) . with ( context , { name1 : 'value1' , name2 : 'value2' } , hash_including ( name1 : 'value1' ) )
236
+
244
237
provider . set ( context , changes )
245
238
end
246
239
end
0 commit comments