spec/arborist/node_spec.rb in arborist-0.0.1.pre20160606141735 vs spec/arborist/node_spec.rb in arborist-0.0.1.pre20160829140603

- old
+ new

@@ -354,10 +354,12 @@ depends_on( all_of('postgres', 'rabbitmq', 'memcached', on: 'svchost'), any_of('webproxy', on: ['fe-host1','fe-host2','fe-host3']) ) + config os: 'freebsd-10' + update( 'song' => 'Around the World', 'artist' => 'Daft Punk', 'length' => '7:09' ) end end @@ -398,20 +400,22 @@ old_node = Marshal.load( Marshal.dump(node) ) node_copy = Marshal.load( Marshal.dump(node) ) old_node.instance_variable_set( :@parent, 'foo' ) old_node.instance_variable_set( :@description, 'Some older description' ) + old_node.instance_variable_set( :@config, {'os' => 'freebsd-8'} ) old_node.tags( :bunker, :lucky, :tickle, :trucker ) old_node.source = '/somewhere/else' node.restore( old_node ) expect( node.parent ).to eq( node_copy.parent ) expect( node.description ).to eq( node_copy.description ) expect( node.tags ).to eq( node_copy.tags ) expect( node.source ).to eq( node_copy.source ) expect( node.dependencies ).to eq( node_copy.dependencies ) + expect( node.config ).to eq( node_copy.config ) end it "doesn't replace dependencies if they've changed" do old_node = Marshal.load( Marshal.dump(node) ) @@ -463,30 +467,29 @@ expect( cloned_node ).to eq( node ) end - it "an ACKed node goes back to ACKed when re-added to the tree" do + it "can be marshalled" do + data = Marshal.dump( node ) + cloned_node = Marshal.load( data ) + expect( cloned_node ).to eq( node ) + end + + + it "an ACKed node stays ACKed when serialized and restored" do node.update( error: "there's a fire" ) node.update( ack: { message: 'We know about the fire. It rages on.', sender: '1986 Labyrinth David Bowie' }) - cloned_node = concrete_class.from_hash( node.to_h ) - node_added_event = Arborist::Event.create( :sys_node_added, cloned_node ) - cloned_node.handle_event( node_added_event ) + expect( node ).to be_acked - expect( cloned_node ).to be_acked - end + restored_node = Marshal.load( Marshal.dump(node) ) - - it "can be marshalled" do - data = Marshal.dump( node ) - cloned_node = Marshal.load( data ) - - expect( cloned_node ).to eq( node ) + expect( restored_node ).to be_acked end end @@ -637,10 +640,11 @@ let( :node ) do concrete_class.new( 'foo' ) do parent 'bar' description "The prototypical node" tags :chunker, :hunky, :flippin, :hippo + config os: 'freebsd-10' update( 'song' => 'Around the World', 'artist' => 'Daft Punk', 'length' => '7:09', @@ -687,9 +691,15 @@ it "can be matched with its identifier" do expect( node ).to match_criteria( identifier: 'foo' ) expect( node ).to_not match_criteria( identifier: 'bar' ) + end + + + it "can be matched with config values" do + expect( node ).to match_criteria( config: {os: 'freebsd-10'} ) + expect( node ).to_not match_criteria( config: {os: 'macosx-10.11.3'} ) end it "can be matched with its user properties" do expect( node ).to match_criteria( song: 'Around the World' )