Sha256: 639b654a785526f5a47a7218f77ae1d926bbf925284a52764f5a96e9ef589661
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
#!/usr/bin/env rspec -cfd require_relative '../spec_helper' require 'arborist/event' describe Arborist::Event do it "derives its type name from its class" do payload = { 'status' => ['up', 'down'] } expect( TestEvent.new(payload).type ).to eq( 'test.event' ) end it "copies the payload it's constructed with" do payload = { 'status' => ['up', 'down'] } ev = TestEvent.create( TestEvent, payload ) payload.clear expect( ev.payload ).to include( 'status' ) 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, 'test.event' ) event = described_class.create( TestEvent, [] ) expect( event ).to match( sub ) end it "always matches a subscription with a nil event type" do sub = Arborist::Subscription.new( :publisher ) event = described_class.create( TestEvent, [] ) expect( event ).to match( sub ) end end describe "serialization support" do it "can represent itself as a Hash" do payload = { 'status' => ['up', 'down'] } ev = TestEvent.create( TestEvent, payload ) result = ev.to_hash expect( result ).to include( 'type', 'data' ) expect( result['type'] ).to eq( 'test.event' ) expect( result['data'] ).to eq( payload ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
arborist-0.0.1.pre20160128152542 | spec/arborist/event_spec.rb |
arborist-0.0.1.pre20160106113421 | spec/arborist/event_spec.rb |