Sha256: 7537b00326d8039d5280bd8539a4708a00f6fc70f0b8658052c3e3577a1acc66

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

#!/usr/bin/env rspec -cfd

require_relative '../../spec_helper'

require 'arborist/event/node_update'


describe Arborist::Event::NodeUpdate do

	class TestNode < Arborist::Node; end


	let( :node ) do
		TestNode.new( 'foo' ) do
			parent 'bar'
			description "The prototypical node"
			tags :chunker, :hunky, :flippin, :hippo

			update(
				'song' => 'Around the World',
				'artist' => 'Daft Punk',
				'length' => '7:09',
				'cider' => {
					'description' => 'tasty',
					'size' => '16oz',
				},
				'sausage' => {
					'description' => 'pork',
					'size' => 'monsterous',
					'price' => {
						'units' => 1200,
						'currency' => 'usd'
					}
				},
				'music' => '80s'
			)
		end
	end


	describe "subscription support" do

		it "matches a subscription with only an event type if the type is the same" do
			sub = Arborist::Subscription.new( :publisher, 'node.update' )
			event = described_class.new( node )

			expect( event ).to match( sub )
		end


		it "matches a subscription with a matching event type and matching criteria" do
			sub = Arborist::Subscription.new( :publisher, 'node.update', 'tag' => 'chunker' )
			event = described_class.new( node )

			expect( event ).to match( sub )
		end


		it "doesn't match a subscription with a matching event type if the criteria don't match" do
			sub = Arborist::Subscription.new( :publisher, 'node.update', 'tag' => 'looper' )
			event = described_class.new( node )

			expect( event ).to_not match( sub )
		end


	end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arborist-0.0.1.pre20160128152542 spec/arborist/event/node_update_spec.rb
arborist-0.0.1.pre20160106113421 spec/arborist/event/node_update_spec.rb