spec/punchblock/ref_spec.rb in punchblock-2.5.2 vs spec/punchblock/ref_spec.rb in punchblock-2.5.3
- old
+ new
@@ -3,102 +3,166 @@
require 'spec_helper'
module Punchblock
describe Ref do
it 'registers itself' do
- RayoNode.class_from_registration(:ref, 'urn:xmpp:rayo:1').should be == described_class
+ expect(RayoNode.class_from_registration(:ref, 'urn:xmpp:rayo:1')).to eq(described_class)
end
describe "from a stanza" do
let(:uri) { 'some_uri' }
let(:stanza) { "<ref uri='#{uri}' xmlns='urn:xmpp:rayo:1' />" }
subject { RayoNode.from_xml parse_stanza(stanza).root, '9f00061', '1' }
it { should be_instance_of described_class }
- its(:target_call_id) { should be == '9f00061' }
+ describe '#target_call_id' do
+ subject { super().target_call_id }
+ it { should be == '9f00061' }
+ end
+
context "when the URI isn't actually a URI" do
let(:uri) { 'fgh4590' }
- its(:uri) { should be == URI('fgh4590') }
- its(:scheme) { should be == nil }
- its(:call_id) { should be == 'fgh4590' }
- its(:domain) { should be == nil }
- its(:component_id) { should be == 'fgh4590' }
+ describe '#uri' do
+ subject { super().uri }
+ it { should be == URI('fgh4590') }
+ end
+
+ describe '#scheme' do
+ subject { super().scheme }
+ it { should be == nil }
+ end
+
+ describe '#call_id' do
+ subject { super().call_id }
+ it { should be == 'fgh4590' }
+ end
+
+ describe '#domain' do
+ subject { super().domain }
+ it { should be == nil }
+ end
+
+ describe '#component_id' do
+ subject { super().component_id }
+ it { should be == 'fgh4590' }
+ end
end
context "when the URI is an XMPP JID" do
let(:uri) { 'xmpp:fgh4590@rayo.net/abc123' }
- its(:uri) { should be == URI('xmpp:fgh4590@rayo.net/abc123') }
- its(:scheme) { should be == 'xmpp' }
- its(:call_id) { should be == 'fgh4590' }
- its(:domain) { should be == 'rayo.net' }
- its(:component_id) { should be == 'abc123' }
+ describe '#uri' do
+ subject { super().uri }
+ it { should be == URI('xmpp:fgh4590@rayo.net/abc123') }
+ end
+
+ describe '#scheme' do
+ subject { super().scheme }
+ it { should be == 'xmpp' }
+ end
+
+ describe '#call_id' do
+ subject { super().call_id }
+ it { should be == 'fgh4590' }
+ end
+
+ describe '#domain' do
+ subject { super().domain }
+ it { should be == 'rayo.net' }
+ end
+
+ describe '#component_id' do
+ subject { super().component_id }
+ it { should be == 'abc123' }
+ end
end
context "when the URI is an asterisk UUID" do
let(:uri) { 'asterisk:fgh4590' }
- its(:uri) { should be == URI('asterisk:fgh4590') }
- its(:scheme) { should be == 'asterisk' }
- its(:call_id) { should be == 'fgh4590' }
- its(:domain) { should be == nil }
- its(:component_id) { should be == 'fgh4590' }
+ describe '#uri' do
+ subject { super().uri }
+ it { should be == URI('asterisk:fgh4590') }
+ end
+
+ describe '#scheme' do
+ subject { super().scheme }
+ it { should be == 'asterisk' }
+ end
+
+ describe '#call_id' do
+ subject { super().call_id }
+ it { should be == 'fgh4590' }
+ end
+
+ describe '#domain' do
+ subject { super().domain }
+ it { should be == nil }
+ end
+
+ describe '#component_id' do
+ subject { super().component_id }
+ it { should be == 'fgh4590' }
+ end
end
end
describe "when setting options in initializer" do
subject { Ref.new uri: uri }
let(:uri) { 'xmpp:fgh4590@rayo.net/abc123' }
- its(:uri) { should be == URI('xmpp:fgh4590@rayo.net/abc123') }
+ describe '#uri' do
+ subject { super().uri }
+ it { should be == URI('xmpp:fgh4590@rayo.net/abc123') }
+ end
describe "exporting to Rayo" do
context "when the URI isn't actually a URI" do
let(:uri) { 'fgh4590' }
it "should export to XML that can be understood by its parser" do
new_instance = RayoNode.from_xml subject.to_rayo
- new_instance.should be_instance_of described_class
- new_instance.uri.should == URI('fgh4590')
+ expect(new_instance).to be_instance_of described_class
+ expect(new_instance.uri).to eq(URI('fgh4590'))
end
end
context "when the URI is an XMPP JID" do
let(:uri) { 'xmpp:fgh4590@rayo.net' }
it "should export to XML that can be understood by its parser" do
new_instance = RayoNode.from_xml subject.to_rayo
- new_instance.should be_instance_of described_class
- new_instance.uri.should == URI('xmpp:fgh4590@rayo.net')
+ expect(new_instance).to be_instance_of described_class
+ expect(new_instance.uri).to eq(URI('xmpp:fgh4590@rayo.net'))
end
end
context "when the URI is an asterisk UUID" do
let(:uri) { 'asterisk:fgh4590' }
it "should export to XML that can be understood by its parser" do
new_instance = RayoNode.from_xml subject.to_rayo
- new_instance.should be_instance_of described_class
- new_instance.uri.should == URI('asterisk:fgh4590')
+ expect(new_instance).to be_instance_of described_class
+ expect(new_instance.uri).to eq(URI('asterisk:fgh4590'))
end
end
it "should render to a parent node if supplied" do
doc = Nokogiri::XML::Document.new
parent = Nokogiri::XML::Node.new 'foo', doc
doc.root = parent
rayo_doc = subject.to_rayo(parent)
- rayo_doc.should == parent
+ expect(rayo_doc).to eq(parent)
end
context "when attributes are not set" do
subject { described_class.new }
it "should not include them in the XML representation" do
- subject.to_rayo['uri'].should be_nil
+ expect(subject.to_rayo['uri']).to be_nil
end
end
end
end
end