Sha256: f177baf336b82f9b4a158b3d4c6b3f645c864383e5c96ec419ffc4ffc0e6aa03

Contents?: true

Size: 1.43 KB

Versions: 14

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

module Punchblock
  module Command
    describe Reject do
      it 'registers itself' do
        RayoNode.class_from_registration(:reject, 'urn:xmpp:rayo:1').should == Reject
      end

      describe "when setting options in initializer" do
        subject { Reject.new :reason => :busy, :headers => { :x_skill => 'agent', :x_customer_id => 8877 } }

        it_should_behave_like 'command_headers'

        its(:reason) { should == :busy }
      end

      describe "from a stanza" do
        let :stanza do
          <<-MESSAGE
<reject xmlns='urn:xmpp:rayo:1'>
  <busy />
  <!-- Sample Headers (optional) -->
  <header name="x-reason-internal" value="bad-skill" />
</reject>
          MESSAGE
        end

        subject { RayoNode.import parse_stanza(stanza).root, '9f00061', '1' }

        it { should be_instance_of Reject }

        its(:reason) { should == :busy }
        its(:headers_hash) { should == { :x_reason_internal => 'bad-skill' } }
      end

      describe "with the reason" do
        [:decline, :busy, :error].each do |reason|
          describe reason do
            subject { Reject.new :reason => reason }

            its(:reason) { should == reason }
          end
        end

        describe "blahblahblah" do
          it "should raise an error" do
            expect { Reject.new(:reason => :blahblahblah) }.to raise_error ArgumentError
          end
        end
      end
    end
  end
end # Punchblock

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
punchblock-0.9.2 spec/punchblock/command/reject_spec.rb
punchblock-0.9.1 spec/punchblock/command/reject_spec.rb
punchblock-0.9.0 spec/punchblock/command/reject_spec.rb
punchblock-0.8.4 spec/punchblock/command/reject_spec.rb
punchblock-0.8.3 spec/punchblock/command/reject_spec.rb
punchblock-0.8.2 spec/punchblock/command/reject_spec.rb
punchblock-0.8.1 spec/punchblock/command/reject_spec.rb
punchblock-0.8.0 spec/punchblock/command/reject_spec.rb
punchblock-0.7.2 spec/punchblock/command/reject_spec.rb
punchblock-0.7.1 spec/punchblock/command/reject_spec.rb
punchblock-0.7.0 spec/punchblock/command/reject_spec.rb
punchblock-0.6.2 spec/punchblock/command/reject_spec.rb
punchblock-0.6.1 spec/punchblock/command/reject_spec.rb
punchblock-0.6.0 spec/punchblock/command/reject_spec.rb