Sha256: 847953ae6439f8cc37f192f48304d54892d1f011d4f4e7a4b896a28f80d6f6a1
Contents?: true
Size: 1.94 KB
Versions: 2
Compression:
Stored size: 1.94 KB
Contents
#!/usr/bin/env rspec -cfd require_relative '../../spec_helper' require 'arborist/node/resource' describe Arborist::Node::Resource do let( :host ) do Arborist::Node.create( 'host', 'testhost' ) do address '192.168.118.3' end end it "can be created without reasonable defaults based on its identifier" do result = described_class.new( 'disk', host ) expect( result.identifier ).to eq( "testhost-disk" ) end it "defaults the category to the identifier" do result = described_class.new( 'load', host ) expect( result.category ).to eq( 'load' ) end it "raises a sensible error when created without a host" do expect { described_class.new( 'load', nil ) }.to raise_error( Arborist::NodeError, /no host/i ) end describe "matching" do let( :host ) do Arborist::Node.create( 'host', 'testhost' ) do address '192.168.66.12' address '10.1.33.8' end end let( :node ) do described_class.new( 'disk', host ) end it "knows its family catagorization" do expect( host.family ).to eq( :host ) expect( node.family ).to eq( :resource ) end it "can be matched with one of its host's addresses" do expect( node ).to match_criteria( address: '192.168.66.12' ) expect( node ).to_not match_criteria( address: '127.0.0.1' ) end it "can be matched with a netblock that includes one of its host's addresses" do expect( node ).to match_criteria( address: '192.168.66.0/24' ) expect( node ).to match_criteria( address: '10.0.0.0/8' ) expect( node ).to_not match_criteria( address: '192.168.66.64/27' ) expect( node ).to_not match_criteria( address: '127.0.0.0/8' ) end it "can be matched with a category" do expect( node ).to match_criteria( category: 'disk' ) expect( node ).to match_criteria( category: [ 'chungwatch', 'disk' ] ) expect( node ).to_not match_criteria( category: [ 'chungwatch', 'snippersnapper' ] ) expect( node ).to_not match_criteria( category: 'processes' ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
arborist-0.6.0 | spec/arborist/node/resource_spec.rb |
arborist-0.5.0 | spec/arborist/node/resource_spec.rb |