Sha256: fb0019e8d26c2e0ade84e11b79072df988bdc39258470661581670cdf53cb397
Contents?: true
Size: 1.28 KB
Versions: 6
Compression:
Stored size: 1.28 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( '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 {} 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_h 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
6 entries across 6 versions & 1 rubygems