Sha256: 1c7caf666391f056de2cbb99ebfb86a9e381b280ff654e485560ba87409b7d89

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

#!/usr/bin/env rspec -cfd

require_relative '../spec_helper'

require 'arborist/node_subscription'


describe Arborist::NodeSubscription do


	it "can be created with just a node" do
		node = Arborist::Node.create( 'host', 'testy' )
		expect( described_class.new(node) ).to be_a( described_class )
	end


	it "raises an error if called with no node" do
		expect {
			described_class.new
		}.to raise_error( ArgumentError )
	end


	it "raises an error if called with something that doesn't handle events" do
		expect {
			described_class.new( "hi i'm a little teapot" )
		}.to raise_error( NameError, /handle_event/ )
	end


	it "uses its node's identifier for its ID" do
		node = Arborist::Node.create( 'host', 'testy' )
		sub = described_class.new( node )

		expect( sub.id ).to eq( 'testy-subscription' )
	end


	it "matches all events" do
		node = Arborist::Node.create( 'host', 'testy' )
		sub = described_class.new( node )
		events = [
			Arborist::Event.create( 'node_update', node ),
			Arborist::Event.create( 'node_delta', node, status: ['up', 'down'] ),
			Arborist::Event.create( 'node_update', node ),
			Arborist::Event.create( 'node_quieted', node ),
			Arborist::Event.create( 'node_acked', node )
		]

		expect( events ).to all( match sub )
	end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
arborist-0.6.0 spec/arborist/node_subscription_spec.rb
arborist-0.5.0 spec/arborist/node_subscription_spec.rb
arborist-0.4.0 spec/arborist/node_subscription_spec.rb
arborist-0.3.0 spec/arborist/node_subscription_spec.rb
arborist-0.2.0 spec/arborist/node_subscription_spec.rb