spec/punchblock/event/complete_spec.rb in punchblock-0.8.2 vs spec/punchblock/event/complete_spec.rb in punchblock-0.8.3

- old
+ new

@@ -5,9 +5,67 @@ describe Complete do it 'registers itself' do RayoNode.class_from_registration(:complete, 'urn:xmpp:rayo:ext:1').should == Complete end + describe "comparing for equality" do + subject do + Complete.new.tap do |c| + c.reason = Complete::Stop.new + c.call_id = '1234' + c.component_id = 'abcd' + end + end + + let :other_complete do + Complete.new.tap do |c| + c.reason = reason + c.call_id = call_id + c.component_id = component_id + end + end + + context 'with reason, call id and component id the same' do + let(:reason) { Complete::Stop.new } + let(:call_id) { '1234' } + let(:component_id) { 'abcd' } + + it "should be equal" do + subject.should == other_complete + end + end + + context 'with a different reason' do + let(:reason) { Complete::Hangup.new } + let(:call_id) { '1234' } + let(:component_id) { 'abcd' } + + it "should not be equal" do + subject.should_not == other_complete + end + end + + context 'with a different call id' do + let(:reason) { Complete::Stop.new } + let(:call_id) { '5678' } + let(:component_id) { 'abcd' } + + it "should not be equal" do + subject.should_not == other_complete + end + end + + context 'with a different component id' do + let(:reason) { Complete::Stop.new } + let(:call_id) { '1234' } + let(:component_id) { 'efgh' } + + it "should not be equal" do + subject.should_not == other_complete + end + end + end + describe "from a stanza" do let :stanza do <<-MESSAGE <complete xmlns='urn:xmpp:rayo:ext:1'> <success xmlns='urn:xmpp:rayo:output:complete:1' />