|
| 1 | +# Unit tests for Bandwidth::Bxml::Refer |
| 2 | +describe 'Bandwidth::Bxml::Refer' do |
| 3 | + let(:initial_attributes) { |
| 4 | + { |
| 5 | + refer_complete_url: 'https://example.com/handleRefer', |
| 6 | + refer_complete_method: 'POST', |
| 7 | + tag: 'initial_tag' |
| 8 | + } |
| 9 | + } |
| 10 | + |
| 11 | + let(:new_attributes) { |
| 12 | + { |
| 13 | + refer_complete_url: 'https://new.com/handleRefer', |
| 14 | + refer_complete_method: 'GET', |
| 15 | + tag: 'new_tag' |
| 16 | + } |
| 17 | + } |
| 18 | + |
| 19 | + let(:sip_uri) { Bandwidth::Bxml::SipUri.new('sip:alice@atlanta.example.com') } |
| 20 | + |
| 21 | + let(:instance) { Bandwidth::Bxml::Refer.new([], initial_attributes) } |
| 22 | + let(:instance_nested) { Bandwidth::Bxml::Refer.new(sip_uri, initial_attributes) } |
| 23 | + |
| 24 | + describe 'test an instance of Refer' do |
| 25 | + it 'validates instance of Refer' do |
| 26 | + expect(instance).to be_instance_of(Bandwidth::Bxml::Refer) |
| 27 | + expect(instance).to be_a(Bandwidth::Bxml::Verb) |
| 28 | + end |
| 29 | + |
| 30 | + it 'tests the to_bxml method of the Refer instance' do |
| 31 | + expected = "\n<Refer referCompleteUrl=\"https://example.com/handleRefer\" referCompleteMethod=\"POST\" tag=\"initial_tag\"/>\n" |
| 32 | + expect(instance.to_bxml).to eq(expected) |
| 33 | + end |
| 34 | + |
| 35 | + it 'tests the set_attributes method of the Refer instance' do |
| 36 | + instance.set_attributes(new_attributes) |
| 37 | + expected = "\n<Refer referCompleteUrl=\"https://new.com/handleRefer\" referCompleteMethod=\"GET\" tag=\"new_tag\"/>\n" |
| 38 | + expect(instance.to_bxml).to eq(expected) |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + describe 'test an instance of Refer with nested SipUri' do |
| 43 | + it 'validates instance of Refer' do |
| 44 | + expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Refer) |
| 45 | + expect(instance_nested).to be_a(Bandwidth::Bxml::Verb) |
| 46 | + end |
| 47 | + |
| 48 | + it 'tests the to_bxml method of the nested Refer instance' do |
| 49 | + expected = "\n<Refer referCompleteUrl=\"https://example.com/handleRefer\" referCompleteMethod=\"POST\" tag=\"initial_tag\">\n <SipUri>sip:alice@atlanta.example.com</SipUri>\n</Refer>\n" |
| 50 | + expect(instance_nested.to_bxml).to eq(expected) |
| 51 | + end |
| 52 | + |
| 53 | + it 'tests the add_sip_uri method of the nested Refer instance' do |
| 54 | + sip_uri_2 = Bandwidth::Bxml::SipUri.new('sip:bob@biloxi.example.com') |
| 55 | + instance_nested.add_sip_uri(sip_uri_2) |
| 56 | + expected = "\n<Refer referCompleteUrl=\"https://example.com/handleRefer\" referCompleteMethod=\"POST\" tag=\"initial_tag\">\n <SipUri>sip:alice@atlanta.example.com</SipUri>\n <SipUri>sip:bob@biloxi.example.com</SipUri>\n</Refer>\n" |
| 57 | + expect(instance_nested.to_bxml).to eq(expected) |
| 58 | + end |
| 59 | + end |
| 60 | +end |
| 61 | + |
0 commit comments