require 'spec_helper' module Punchblock class Event describe Complete do it 'registers itself' do RayoNode.class_from_registration(:complete, 'urn:xmpp:rayo:ext:1').should == Complete end describe "from a stanza" do let :stanza do <<-MESSAGE MESSAGE end subject { RayoNode.import parse_stanza(stanza).root, '9f00061', '1' } it { should be_instance_of Complete } it_should_behave_like 'event' its(:reason) { should be_instance_of Component::Output::Complete::Success } end end describe Complete::Stop do let :stanza do <<-MESSAGE MESSAGE end subject { RayoNode.import(parse_stanza(stanza).root).reason } it { should be_instance_of Complete::Stop } its(:name) { should == :stop } end describe Complete::Hangup do let :stanza do <<-MESSAGE MESSAGE end subject { RayoNode.import(parse_stanza(stanza).root).reason } it { should be_instance_of Complete::Hangup } its(:name) { should == :hangup } end describe Complete::Error do let :stanza do <<-MESSAGE Something really bad happened MESSAGE end subject { RayoNode.import(parse_stanza(stanza).root).reason } it { should be_instance_of Complete::Error } its(:name) { should == :error } its(:details) { should == "Something really bad happened" } describe "when setting options in initializer" do subject do Complete::Error.new :details => 'Ooops' end its(:details) { should == 'Ooops' } end end end end # Punchblock