punchblock 2.5.2 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +2 -0
  3. data/CHANGELOG.md +6 -0
  4. data/README.markdown +2 -1
  5. data/lib/punchblock/translator/asterisk/call.rb +3 -3
  6. data/lib/punchblock/translator/asterisk/component/mrcp_recog_prompt.rb +15 -9
  7. data/lib/punchblock/translator/asterisk/component/output.rb +8 -1
  8. data/lib/punchblock/translator/input_component.rb +2 -0
  9. data/lib/punchblock/version.rb +1 -1
  10. data/punchblock.gemspec +1 -1
  11. data/spec/punchblock/client/component_registry_spec.rb +3 -3
  12. data/spec/punchblock/client_spec.rb +22 -15
  13. data/spec/punchblock/command/accept_spec.rb +17 -7
  14. data/spec/punchblock/command/answer_spec.rb +19 -9
  15. data/spec/punchblock/command/dial_spec.rb +76 -27
  16. data/spec/punchblock/command/hangup_spec.rb +17 -7
  17. data/spec/punchblock/command/join_spec.rb +78 -24
  18. data/spec/punchblock/command/mute_spec.rb +3 -3
  19. data/spec/punchblock/command/redirect_spec.rb +33 -12
  20. data/spec/punchblock/command/reject_spec.rb +41 -14
  21. data/spec/punchblock/command/unjoin_spec.rb +29 -12
  22. data/spec/punchblock/command/unmute_spec.rb +3 -3
  23. data/spec/punchblock/command_node_spec.rb +43 -20
  24. data/spec/punchblock/component/asterisk/agi/command_spec.rb +52 -12
  25. data/spec/punchblock/component/asterisk/ami/action_spec.rb +69 -21
  26. data/spec/punchblock/component/component_node_spec.rb +12 -12
  27. data/spec/punchblock/component/input_spec.rb +304 -87
  28. data/spec/punchblock/component/output_spec.rb +434 -173
  29. data/spec/punchblock/component/prompt_spec.rb +63 -20
  30. data/spec/punchblock/component/receive_fax_spec.rb +43 -14
  31. data/spec/punchblock/component/record_spec.rb +215 -71
  32. data/spec/punchblock/component/send_fax_spec.rb +54 -15
  33. data/spec/punchblock/connection/asterisk_spec.rb +34 -24
  34. data/spec/punchblock/connection/freeswitch_spec.rb +9 -9
  35. data/spec/punchblock/connection/xmpp_spec.rb +92 -83
  36. data/spec/punchblock/event/answered_spec.rb +14 -4
  37. data/spec/punchblock/event/asterisk/ami/event_spec.rb +34 -12
  38. data/spec/punchblock/event/complete_spec.rb +36 -16
  39. data/spec/punchblock/event/dtmf_spec.rb +9 -3
  40. data/spec/punchblock/event/end_spec.rb +43 -10
  41. data/spec/punchblock/event/input_timers_started_spec.rb +1 -1
  42. data/spec/punchblock/event/joined_spec.rb +29 -7
  43. data/spec/punchblock/event/offer_spec.rb +41 -10
  44. data/spec/punchblock/event/ringing_spec.rb +14 -4
  45. data/spec/punchblock/event/started_speaking_spec.rb +9 -3
  46. data/spec/punchblock/event/stopped_speaking_spec.rb +9 -3
  47. data/spec/punchblock/event/unjoined_spec.rb +24 -6
  48. data/spec/punchblock/protocol_error_spec.rb +16 -13
  49. data/spec/punchblock/ref_spec.rb +90 -26
  50. data/spec/punchblock/translator/asterisk/call_spec.rb +176 -161
  51. data/spec/punchblock/translator/asterisk/component/asterisk/agi_command_spec.rb +18 -18
  52. data/spec/punchblock/translator/asterisk/component/asterisk/ami_action_spec.rb +9 -9
  53. data/spec/punchblock/translator/asterisk/component/composed_prompt_spec.rb +14 -14
  54. data/spec/punchblock/translator/asterisk/component/input_spec.rb +57 -36
  55. data/spec/punchblock/translator/asterisk/component/mrcp_native_prompt_spec.rb +50 -50
  56. data/spec/punchblock/translator/asterisk/component/mrcp_prompt_spec.rb +59 -48
  57. data/spec/punchblock/translator/asterisk/component/output_spec.rb +231 -221
  58. data/spec/punchblock/translator/asterisk/component/record_spec.rb +82 -82
  59. data/spec/punchblock/translator/asterisk/component/stop_by_redirect_spec.rb +10 -10
  60. data/spec/punchblock/translator/asterisk/component_spec.rb +4 -4
  61. data/spec/punchblock/translator/asterisk_spec.rb +89 -82
  62. data/spec/punchblock/translator/freeswitch/call_spec.rb +114 -99
  63. data/spec/punchblock/translator/freeswitch/component/flite_output_spec.rb +19 -19
  64. data/spec/punchblock/translator/freeswitch/component/input_spec.rb +24 -24
  65. data/spec/punchblock/translator/freeswitch/component/output_spec.rb +23 -23
  66. data/spec/punchblock/translator/freeswitch/component/record_spec.rb +78 -78
  67. data/spec/punchblock/translator/freeswitch/component/tts_output_spec.rb +19 -19
  68. data/spec/punchblock/translator/freeswitch/component_spec.rb +8 -8
  69. data/spec/punchblock/translator/freeswitch_spec.rb +66 -59
  70. data/spec/punchblock/uri_list_spec.rb +45 -10
  71. data/spec/punchblock_spec.rb +13 -13
  72. data/spec/spec_helper.rb +18 -11
  73. data/spec/support/mock_connection_with_event_handler.rb +1 -1
  74. metadata +5 -4
@@ -6,19 +6,22 @@ module Punchblock
6
6
  module Component
7
7
  describe SendFax do
8
8
  it 'registers itself' do
9
- RayoNode.class_from_registration(:sendfax, 'urn:xmpp:rayo:fax:1').should be == described_class
9
+ expect(RayoNode.class_from_registration(:sendfax, 'urn:xmpp:rayo:fax:1')).to eq(described_class)
10
10
  end
11
11
 
12
12
  subject do
13
13
  SendFax.new render_documents: [SendFax::FaxDocument.new(url: 'http://example.com/faxes/document.tiff', pages: [1..4,5,7..9])]
14
14
  end
15
15
 
16
- its(:render_documents) { should be == [SendFax::FaxDocument.new(url: 'http://example.com/faxes/document.tiff', pages: [1..4,5,7..9])] }
16
+ describe '#render_documents' do
17
+ subject { super().render_documents }
18
+ it { should be == [SendFax::FaxDocument.new(url: 'http://example.com/faxes/document.tiff', pages: [1..4,5,7..9])] }
19
+ end
17
20
 
18
21
  describe "exporting to Rayo" do
19
22
  it "should export to XML that can be understood by its parser" do
20
23
  new_instance = RayoNode.from_xml Nokogiri::XML(subject.to_rayo.to_xml, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).root
21
- new_instance.render_documents.should be == [SendFax::FaxDocument.new(url: 'http://example.com/faxes/document.tiff', pages: [1..4,5,7..9])]
24
+ expect(new_instance.render_documents).to eq([SendFax::FaxDocument.new(url: 'http://example.com/faxes/document.tiff', pages: [1..4,5,7..9])])
22
25
  end
23
26
  end
24
27
 
@@ -30,7 +33,7 @@ module Punchblock
30
33
  describe "exporting to Rayo" do
31
34
  it "should export to XML that can be understood by its parser" do
32
35
  new_instance = RayoNode.from_xml Nokogiri::XML(subject.to_rayo.to_xml, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).root
33
- new_instance.render_documents.should be == [SendFax::FaxDocument.new(url: 'http://example.com/faxes/document.tiff')]
36
+ expect(new_instance.render_documents).to eq([SendFax::FaxDocument.new(url: 'http://example.com/faxes/document.tiff')])
34
37
  end
35
38
  end
36
39
  end
@@ -47,7 +50,10 @@ module Punchblock
47
50
  MESSAGE
48
51
  end
49
52
 
50
- its(:render_documents) { should be == [SendFax::FaxDocument.new(url: 'http://shakespere.lit/my_fax.tiff', identity: '+14045555555', header: 'Hello world', pages: [1..4,5,7..9])] }
53
+ describe '#render_documents' do
54
+ subject { super().render_documents }
55
+ it { should be == [SendFax::FaxDocument.new(url: 'http://shakespere.lit/my_fax.tiff', identity: '+14045555555', header: 'Hello world', pages: [1..4,5,7..9])] }
56
+ end
51
57
 
52
58
  context "without optional attributes" do
53
59
  let :stanza do
@@ -58,30 +64,63 @@ module Punchblock
58
64
  MESSAGE
59
65
  end
60
66
 
61
- its(:render_documents) { should be == [SendFax::FaxDocument.new(url: 'http://shakespere.lit/my_fax.tiff')] }
67
+ describe '#render_documents' do
68
+ subject { super().render_documents }
69
+ it { should be == [SendFax::FaxDocument.new(url: 'http://shakespere.lit/my_fax.tiff')] }
70
+ end
62
71
  end
63
72
  end
64
73
  end
65
74
 
66
75
  describe SendFax::FaxDocument do
67
76
  it "registers itself" do
68
- RayoNode.class_from_registration(:document, 'urn:xmpp:rayo:fax:1').should be == described_class
77
+ expect(RayoNode.class_from_registration(:document, 'urn:xmpp:rayo:fax:1')).to eq(described_class)
69
78
  end
70
79
 
71
80
  subject { SendFax::FaxDocument.new(url: 'http://shakespere.lit/my_fax.tiff', identity: '+14045555555', header: 'Hello world', pages: [1..4,5,7..9]) }
72
81
 
73
- its(:url) { should == 'http://shakespere.lit/my_fax.tiff' }
74
- its(:identity) { should == '+14045555555' }
75
- its(:header) { should == 'Hello world' }
76
- its(:pages) { should == [1..4,5,7..9] }
82
+ describe '#url' do
83
+ subject { super().url }
84
+ it { should == 'http://shakespere.lit/my_fax.tiff' }
85
+ end
86
+
87
+ describe '#identity' do
88
+ subject { super().identity }
89
+ it { should == '+14045555555' }
90
+ end
91
+
92
+ describe '#header' do
93
+ subject { super().header }
94
+ it { should == 'Hello world' }
95
+ end
96
+
97
+ describe '#pages' do
98
+ subject { super().pages }
99
+ it { should == [1..4,5,7..9] }
100
+ end
77
101
 
78
102
  context "without optional attributes" do
79
103
  subject { SendFax::FaxDocument.new(url: 'http://shakespere.lit/my_fax.tiff') }
80
104
 
81
- its(:url) { should == 'http://shakespere.lit/my_fax.tiff' }
82
- its(:identity) { should be_nil }
83
- its(:header) { should be_nil }
84
- its(:pages) { should be_nil }
105
+ describe '#url' do
106
+ subject { super().url }
107
+ it { should == 'http://shakespere.lit/my_fax.tiff' }
108
+ end
109
+
110
+ describe '#identity' do
111
+ subject { super().identity }
112
+ it { should be_nil }
113
+ end
114
+
115
+ describe '#header' do
116
+ subject { super().header }
117
+ it { should be_nil }
118
+ end
119
+
120
+ describe '#pages' do
121
+ subject { super().pages }
122
+ it { should be_nil }
123
+ end
85
124
  end
86
125
 
87
126
  describe "comparison" do
@@ -16,59 +16,69 @@ module Punchblock
16
16
 
17
17
  let(:mock_event_handler) { double('Event Handler').as_null_object }
18
18
 
19
- let(:connection) { Asterisk.new options }
20
-
21
- subject { connection }
19
+ subject(:connection) { Asterisk.new options }
22
20
 
23
21
  before do
24
- subject.event_handler = mock_event_handler
22
+ connection.event_handler = mock_event_handler
23
+ end
24
+
25
+ describe '#ami_client' do
26
+ subject { connection.ami_client }
27
+
28
+ it { should be_a RubyAMIStreamProxy }
25
29
  end
26
30
 
27
- its(:ami_client) { should be_a RubyAMIStreamProxy }
28
- its('ami_client.stream') { should be_a RubyAMI::Stream }
31
+ describe '#ami_client' do
32
+ describe '#stream' do
33
+ subject { connection.ami_client.stream }
34
+
35
+ it { should be_a RubyAMI::Stream }
36
+ end
37
+ end
29
38
 
30
39
  it 'should set the connection on the translator' do
31
- subject.translator.connection.should be subject
40
+ expect(subject.translator.connection).to be subject
32
41
  end
33
42
 
34
43
  describe '#run' do
35
44
  it 'starts the RubyAMI::Stream' do
36
- subject.ami_client.async.should_receive(:run).once do
45
+ expect(subject.ami_client.async).to receive(:run).once do
37
46
  subject.ami_client.terminate
38
47
  end
39
- lambda { subject.run }.should raise_error DisconnectedError
48
+ expect { subject.run }.to raise_error DisconnectedError
40
49
  end
41
50
 
42
51
  it 'rebuilds the RubyAMI::Stream if dead' do
43
- subject.ami_client.async.should_receive(:run).once do
52
+ pending
53
+ expect(subject.ami_client.async).to receive(:run).once do
44
54
  subject.ami_client.terminate
45
55
  end
46
- lambda { subject.run }.should raise_error DisconnectedError
47
- subject.ami_client.alive?.should be_false
48
- subject.should_receive(:new_ami_stream).once do
49
- subject.ami_client.alive?.should be_true
50
- subject.ami_client.async.should_receive(:run).once
56
+ expect { subject.run }.to raise_error DisconnectedError
57
+ expect(subject.ami_client.alive?).to be_false
58
+ expect(subject).to receive(:new_ami_stream).once.and_return do
59
+ expect(subject.ami_client.alive?).to be true
60
+ expect(subject.ami_client.async).to receive(:run).once
51
61
  end
52
- lambda { subject.run }.should_not raise_error DisconnectedError
62
+ expect { subject.run }.not_to raise_error
53
63
  end
54
64
  end
55
65
 
56
66
  describe '#stop' do
57
67
  it 'stops the RubyAMI::Stream' do
58
- subject.ami_client.should_receive(:terminate).once
68
+ expect(subject.ami_client).to receive(:terminate).once
59
69
  subject.stop
60
70
  end
61
71
 
62
72
  it 'shuts down the translator' do
63
- subject.translator.should_receive(:terminate).once
73
+ expect(subject.translator).to receive(:terminate).once
64
74
  subject.stop
65
75
  end
66
76
  end
67
77
 
68
78
  it 'sends events from RubyAMI to the translator' do
69
79
  event = RubyAMI::Event.new 'FullyBooted'
70
- subject.translator.async.should_receive(:handle_ami_event).once.with event
71
- subject.translator.async.should_receive(:handle_ami_event).once.with RubyAMI::Stream::Disconnected.new
80
+ expect(subject.translator.async).to receive(:handle_ami_event).once.with event
81
+ expect(subject.translator.async).to receive(:handle_ami_event).once.with RubyAMI::Stream::Disconnected.new
72
82
  subject.ami_client.message_received event
73
83
  end
74
84
 
@@ -76,7 +86,7 @@ module Punchblock
76
86
  it 'sends a command to the translator' do
77
87
  command = double 'Command'
78
88
  options = {:foo => :bar}
79
- subject.translator.async.should_receive(:execute_command).once.with command, options
89
+ expect(subject.translator.async).to receive(:execute_command).once.with command, options
80
90
  subject.write command, options
81
91
  end
82
92
  end
@@ -86,7 +96,7 @@ module Punchblock
86
96
  offer = Event::Offer.new
87
97
  offer.target_call_id = '9f00061'
88
98
 
89
- mock_event_handler.should_receive(:call).once.with offer
99
+ expect(mock_event_handler).to receive(:call).once.with offer
90
100
  subject.handle_event offer
91
101
  end
92
102
  end
@@ -94,13 +104,13 @@ module Punchblock
94
104
  describe '#new_call_uri' do
95
105
  it "should return a random UUID" do
96
106
  stub_uuids 'foobar'
97
- subject.new_call_uri.should == 'foobar'
107
+ expect(subject.new_call_uri).to eq('foobar')
98
108
  end
99
109
  end
100
110
 
101
111
  describe '#send_message' do
102
112
  it 'passes the message to the translator for dispatch' do
103
- subject.translator.should_receive(:send_message).once.with(:foo)
113
+ expect(subject.translator).to receive(:send_message).once.with(:foo)
104
114
  subject.send_message :foo
105
115
  end
106
116
  end
@@ -26,33 +26,33 @@ module Punchblock
26
26
  end
27
27
 
28
28
  it 'should set the connection on the translator' do
29
- subject.translator.connection.should be subject
29
+ expect(subject.translator.connection).to be subject
30
30
  end
31
31
 
32
32
  describe '#run' do
33
33
  it 'starts a RubyFS stream' do
34
34
  # subject.should_receive(:new_fs_stream).once.with('127.0.0.1', 8021, 'test').and_return mock_stream
35
- subject.stream.should_receive(:run).once
36
- lambda { subject.run }.should raise_error(DisconnectedError)
35
+ expect(subject.stream).to receive(:run).once
36
+ expect { subject.run }.to raise_error(DisconnectedError)
37
37
  end
38
38
  end
39
39
 
40
40
  describe '#stop' do
41
41
  it 'stops the RubyFS::Stream' do
42
- subject.stream.should_receive(:shutdown).once
42
+ expect(subject.stream).to receive(:shutdown).once
43
43
  subject.stop
44
44
  end
45
45
 
46
46
  it 'shuts down the translator' do
47
- subject.translator.should_receive(:terminate).once
47
+ expect(subject.translator).to receive(:terminate).once
48
48
  subject.stop
49
49
  end
50
50
  end
51
51
 
52
52
  it 'sends events from RubyFS to the translator' do
53
53
  event = double 'RubyFS::Event'
54
- subject.translator.async.should_receive(:handle_es_event).once.with event
55
- subject.translator.async.should_receive(:handle_es_event).once.with RubyFS::Stream::Disconnected.new
54
+ expect(subject.translator.async).to receive(:handle_es_event).once.with event
55
+ expect(subject.translator.async).to receive(:handle_es_event).once.with RubyFS::Stream::Disconnected.new
56
56
  subject.stream.fire_event event
57
57
  end
58
58
 
@@ -60,7 +60,7 @@ module Punchblock
60
60
  it 'sends a command to the translator' do
61
61
  command = double 'Command'
62
62
  options = {:foo => :bar}
63
- subject.translator.async.should_receive(:execute_command).once.with command, options
63
+ expect(subject.translator.async).to receive(:execute_command).once.with command, options
64
64
  subject.write command, options
65
65
  end
66
66
  end
@@ -70,7 +70,7 @@ module Punchblock
70
70
  offer = Event::Offer.new
71
71
  offer.target_call_id = '9f00061'
72
72
 
73
- mock_event_handler.should_receive(:call).once.with offer
73
+ expect(mock_event_handler).to receive(:call).once.with offer
74
74
  subject.handle_event offer
75
75
  end
76
76
  end
@@ -22,11 +22,14 @@ module Punchblock
22
22
  context "with no domains specified, and a JID of 1@app.rayo.net" do
23
23
  let(:options) { { :username => '1@app.rayo.net' } }
24
24
 
25
- its(:root_domain) { should be == 'app.rayo.net' }
25
+ describe '#root_domain' do
26
+ subject { super().root_domain }
27
+ it { should be == 'app.rayo.net' }
28
+ end
26
29
 
27
30
  describe '#new_call_uri' do
28
31
  it "should return an appropriate random call URI" do
29
- subject.new_call_uri.should == 'xmpp:randomcallid@app.rayo.net'
32
+ expect(subject.new_call_uri).to eq('xmpp:randomcallid@app.rayo.net')
30
33
  end
31
34
  end
32
35
  end
@@ -34,11 +37,14 @@ module Punchblock
34
37
  context "with only a rayo domain set" do
35
38
  let(:options) { { :rayo_domain => 'rayo.org' } }
36
39
 
37
- its(:root_domain) { should be == 'rayo.org' }
40
+ describe '#root_domain' do
41
+ subject { super().root_domain }
42
+ it { should be == 'rayo.org' }
43
+ end
38
44
 
39
45
  describe '#new_call_uri' do
40
46
  it "should return an appropriate random call URI" do
41
- subject.new_call_uri.should == 'xmpp:randomcallid@rayo.org'
47
+ expect(subject.new_call_uri).to eq('xmpp:randomcallid@rayo.org')
42
48
  end
43
49
  end
44
50
  end
@@ -46,11 +52,14 @@ module Punchblock
46
52
  context "with only a root domain set" do
47
53
  let(:options) { { :root_domain => 'rayo.org' } }
48
54
 
49
- its(:root_domain) { should be == 'rayo.org' }
55
+ describe '#root_domain' do
56
+ subject { super().root_domain }
57
+ it { should be == 'rayo.org' }
58
+ end
50
59
 
51
60
  describe '#new_call_uri' do
52
61
  it "should return an appropriate random call URI" do
53
- subject.new_call_uri.should == 'xmpp:randomcallid@rayo.org'
62
+ expect(subject.new_call_uri).to eq('xmpp:randomcallid@rayo.org')
54
63
  end
55
64
  end
56
65
  end
@@ -65,7 +74,7 @@ module Punchblock
65
74
  old_logger = Punchblock.logger
66
75
  Punchblock.logger = :foo
67
76
  XMPP.new :username => '1@call.rayo.net', :password => 1
68
- Blather.logger.should be :foo
77
+ expect(Blather.logger).to be :foo
69
78
  Punchblock.logger = old_logger
70
79
  end
71
80
 
@@ -86,9 +95,9 @@ module Punchblock
86
95
  </output>
87
96
  MSG
88
97
  output = RayoNode.import parse_stanza(output).root
89
- connection.should_receive(:write_to_stream).once.and_return true
98
+ expect(connection).to receive(:write_to_stream).once.and_return true
90
99
  iq = Blather::Stanza::Iq.new :set, '9f00061@call.rayo.net'
91
- connection.should_receive(:create_iq).and_return iq
100
+ expect(connection).to receive(:create_iq).and_return iq
92
101
 
93
102
  write_thread = Thread.new do
94
103
  connection.write offer.call_id, output
@@ -106,9 +115,9 @@ module Punchblock
106
115
 
107
116
  write_thread.join
108
117
 
109
- output.state_name.should be == :executing
118
+ expect(output.state_name).to eq(:executing)
110
119
 
111
- connection.original_component_from_id('fgh4590').should be == output
120
+ expect(connection.original_component_from_id('fgh4590')).to eq(output)
112
121
 
113
122
  example_complete = import_stanza <<-MSG
114
123
  <presence to='16577@app.rayo.net/1' from='9f00061@call.rayo.net/fgh4590'>
@@ -119,80 +128,80 @@ module Punchblock
119
128
  MSG
120
129
 
121
130
  connection.__send__ :handle_presence, example_complete
122
- output.complete_event(0.5).source.should be == output
131
+ expect(output.complete_event(0.5).source).to eq(output)
123
132
 
124
- output.component_id.should be == 'fgh4590'
133
+ expect(output.component_id).to eq('fgh4590')
125
134
  end
126
135
 
127
136
  let(:client) { connection.send :client }
128
- before { client.stub :write }
137
+ before { allow(client).to receive :write }
129
138
 
130
139
  describe "sending a command" do
131
140
  let(:command) { Punchblock::Command::Answer.new request_id: 'fooobarrr', target_call_id: 'foo', domain: 'bar.com' }
132
141
 
133
142
  it "should write an IQ containing the command to the socket" do
134
- client.should_receive(:write).once.with do |stanza|
135
- stanza.should be_a Blather::Stanza::Iq
136
- stanza.to.should be == 'foo@bar.com'
137
- stanza.type.should be == :set
138
- end
143
+ expect(client).to receive(:write).once.with { |stanza|
144
+ expect(stanza).to be_a Blather::Stanza::Iq
145
+ expect(stanza.to).to eq('foo@bar.com')
146
+ expect(stanza.type).to eq(:set)
147
+ }
139
148
  connection.write command
140
149
  end
141
150
 
142
151
  it "should put the command in a requested state" do
143
152
  connection.write command
144
- command.should be_requested
153
+ expect(command).to be_requested
145
154
  end
146
155
 
147
156
  it "should use the command's request_id as the ID id" do
148
- client.should_receive(:write).once.with do |stanza|
149
- stanza.id.should be == 'fooobarrr'
150
- end
157
+ expect(client).to receive(:write).once.with { |stanza|
158
+ expect(stanza.id).to eq('fooobarrr')
159
+ }
151
160
  connection.write command
152
161
  end
153
162
  end
154
163
 
155
164
  it 'should send a "Chat" presence when ready' do
156
- client.should_receive(:write).once.with do |stanza|
157
- stanza.to.should be == 'rayo.net'
158
- stanza.should be_a Blather::Stanza::Presence::Status
159
- stanza.chat?.should be true
160
- end
165
+ expect(client).to receive(:write).once.with { |stanza|
166
+ expect(stanza.to).to eq('rayo.net')
167
+ expect(stanza).to be_a Blather::Stanza::Presence::Status
168
+ expect(stanza.chat?).to be true
169
+ }
161
170
  connection.ready!
162
171
  end
163
172
 
164
173
  it 'should send a "Do Not Disturb" presence when not_ready' do
165
- client.should_receive(:write).once.with do |stanza|
166
- stanza.to.should be == 'rayo.net'
167
- stanza.should be_a Blather::Stanza::Presence::Status
168
- stanza.dnd?.should be true
169
- end
174
+ expect(client).to receive(:write).once.with { |stanza|
175
+ expect(stanza.to).to eq('rayo.net')
176
+ expect(stanza).to be_a Blather::Stanza::Presence::Status
177
+ expect(stanza.dnd?).to be true
178
+ }
170
179
  connection.not_ready!
171
180
  end
172
181
 
173
182
  describe '#send_message' do
174
183
  it 'should send a "normal" message to the given user and domain' do
175
- client.should_receive(:write).once.with do |stanza|
176
- stanza.to.should be == 'someone@example.org'
177
- stanza.should be_a Blather::Stanza::Message
178
- stanza.type.should == :normal
179
- stanza.body.should be == 'Hello World!'
180
- stanza.subject.should be_nil
181
- end
184
+ expect(client).to receive(:write).once.with { |stanza|
185
+ expect(stanza.to).to eq('someone@example.org')
186
+ expect(stanza).to be_a Blather::Stanza::Message
187
+ expect(stanza.type).to eq(:normal)
188
+ expect(stanza.body).to eq('Hello World!')
189
+ expect(stanza.subject).to be_nil
190
+ }
182
191
  connection.send_message 'someone', 'example.org', 'Hello World!'
183
192
  end
184
193
 
185
194
  it 'should default to the root domain' do
186
- client.should_receive(:write).once.with do |stanza|
187
- stanza.to.should be == 'someone@rayo.net'
188
- end
195
+ expect(client).to receive(:write).once.with { |stanza|
196
+ expect(stanza.to).to eq('someone@rayo.net')
197
+ }
189
198
  connection.send_message "someone", nil, nil
190
199
  end
191
200
 
192
201
  it 'should send a message with the given subject' do
193
- client.should_receive(:write).once.with do |stanza|
194
- stanza.subject.should be == "Important Message"
195
- end
202
+ expect(client).to receive(:write).once.with { |stanza|
203
+ expect(stanza.subject).to eq("Important Message")
204
+ }
196
205
  connection.send_message nil, nil, nil, :subject => "Important Message"
197
206
  end
198
207
  end
@@ -210,15 +219,15 @@ module Punchblock
210
219
 
211
220
  let(:example_complete) { import_stanza complete_xml }
212
221
 
213
- it { example_complete.should be_a Blather::Stanza::Presence }
222
+ it { expect(example_complete).to be_a Blather::Stanza::Presence }
214
223
 
215
224
  describe "accessing the rayo node for a presence stanza" do
216
225
  it "should import the rayo node" do
217
- example_complete.rayo_node.should be_a Punchblock::Event::Complete
226
+ expect(example_complete.rayo_node).to be_a Punchblock::Event::Complete
218
227
  end
219
228
 
220
229
  it "should be memoized" do
221
- example_complete.rayo_node.should be example_complete.rayo_node
230
+ expect(example_complete.rayo_node).to be example_complete.rayo_node
222
231
  end
223
232
  end
224
233
 
@@ -244,17 +253,17 @@ module Punchblock
244
253
 
245
254
  let(:example_event) { import_stanza offer_xml }
246
255
 
247
- it { example_event.should be_a Blather::Stanza::Presence }
256
+ it { expect(example_event).to be_a Blather::Stanza::Presence }
248
257
 
249
258
  it 'should call the event handler with the event' do
250
- mock_event_handler.should_receive(:call).once.with do |event|
251
- event.should be_instance_of Event::Offer
252
- event.target_call_id.should be == '9f00061'
253
- event.source_uri.should be == 'xmpp:9f00061@call.rayo.net'
254
- event.domain.should be == 'call.rayo.net'
255
- event.transport.should be == 'xmpp'
256
- event.timestamp.should be == @now
257
- end
259
+ expect(mock_event_handler).to receive(:call).once.with { |event|
260
+ expect(event).to be_instance_of Event::Offer
261
+ expect(event.target_call_id).to eq('9f00061')
262
+ expect(event.source_uri).to eq('xmpp:9f00061@call.rayo.net')
263
+ expect(event.domain).to eq('call.rayo.net')
264
+ expect(event.transport).to eq('xmpp')
265
+ expect(event.timestamp).to eq(@now)
266
+ }
258
267
  handle_presence
259
268
  end
260
269
 
@@ -269,9 +278,9 @@ module Punchblock
269
278
  end
270
279
 
271
280
  it 'should stamp that time on the rayo event' do
272
- mock_event_handler.should_receive(:call).once.with do |event|
273
- event.timestamp.should be == DateTime.new(2002, 9, 10, 23, 8, 25, 0)
274
- end
281
+ expect(mock_event_handler).to receive(:call).once.with { |event|
282
+ expect(event.timestamp).to eq(DateTime.new(2002, 9, 10, 23, 8, 25, 0))
283
+ }
275
284
  handle_presence
276
285
  end
277
286
  end
@@ -289,16 +298,16 @@ module Punchblock
289
298
  let(:example_event) { import_stanza irrelevant_xml }
290
299
 
291
300
  it 'should not be considered to be a rayo event' do
292
- example_event.rayo_event?.should be_false
301
+ expect(example_event.rayo_event?).to be_false
293
302
  end
294
303
 
295
304
  it 'should have a nil rayo_node' do
296
- example_event.rayo_node.should be_nil
305
+ expect(example_event.rayo_node).to be_nil
297
306
  end
298
307
 
299
308
  it 'should not handle the event' do
300
- mock_event_handler.should_receive(:call).never
301
- lambda { handle_presence }.should throw_symbol(:pass)
309
+ expect(mock_event_handler).to receive(:call).never
310
+ expect { handle_presence }.to throw_symbol(:pass)
302
311
  end
303
312
  end
304
313
  end
@@ -330,19 +339,19 @@ module Punchblock
330
339
  subject { cmd.response }
331
340
 
332
341
  it "should have the correct call ID" do
333
- subject.call_id.should be == call_id
342
+ expect(subject.call_id).to eq(call_id)
334
343
  end
335
344
 
336
345
  it "should have the correct component ID" do
337
- subject.component_id.should be == component_id
346
+ expect(subject.component_id).to eq(component_id)
338
347
  end
339
348
 
340
349
  it "should have the correct name" do
341
- subject.name.should be == :item_not_found
350
+ expect(subject.name).to eq(:item_not_found)
342
351
  end
343
352
 
344
353
  it "should have the correct text" do
345
- subject.text.should be == 'Could not find call [id=f6d437f4-1e18-457b-99f8-b5d853f50347]'
354
+ expect(subject.text).to eq('Could not find call [id=f6d437f4-1e18-457b-99f8-b5d853f50347]')
346
355
  end
347
356
  end
348
357
 
@@ -355,7 +364,7 @@ module Punchblock
355
364
 
356
365
  it "should use the correct JID" do
357
366
  stanza = subject.prep_command_for_execution command
358
- stanza.to.should be == expected_jid
367
+ expect(stanza.to).to eq(expected_jid)
359
368
  end
360
369
  end
361
370
 
@@ -364,7 +373,7 @@ module Punchblock
364
373
  let(:expected_jid) { 'abc123@rayo.net' }
365
374
 
366
375
  it "should use the correct JID" do
367
- stanza.to.should be == expected_jid
376
+ expect(stanza.to).to eq(expected_jid)
368
377
  end
369
378
 
370
379
  context "with a domain specified" do
@@ -372,7 +381,7 @@ module Punchblock
372
381
 
373
382
  it "should use the specified domain in the JID" do
374
383
  stanza = subject.prep_command_for_execution command, domain: 'calls.rayo.net'
375
- stanza.to.should be == expected_jid
384
+ expect(stanza.to).to eq(expected_jid)
376
385
  end
377
386
  end
378
387
  end
@@ -382,7 +391,7 @@ module Punchblock
382
391
  let(:expected_jid) { 'abc123@rayo.net' }
383
392
 
384
393
  it "should use the correct JID" do
385
- stanza.to.should be == expected_jid
394
+ expect(stanza.to).to eq(expected_jid)
386
395
  end
387
396
  end
388
397
 
@@ -391,7 +400,7 @@ module Punchblock
391
400
  let(:expected_jid) { 'abc123@rayo.net/foobar' }
392
401
 
393
402
  it "should use the correct JID" do
394
- stanza.to.should be == expected_jid
403
+ expect(stanza.to).to eq(expected_jid)
395
404
  end
396
405
  end
397
406
 
@@ -400,7 +409,7 @@ module Punchblock
400
409
  let(:expected_jid) { 'abc123@rayo.net' }
401
410
 
402
411
  it "should use the correct JID" do
403
- stanza.to.should be == expected_jid
412
+ expect(stanza.to).to eq(expected_jid)
404
413
  end
405
414
  end
406
415
 
@@ -409,7 +418,7 @@ module Punchblock
409
418
  let(:expected_jid) { 'abc123@rayo.net/foobar' }
410
419
 
411
420
  it "should use the correct JID" do
412
- stanza.to.should be == expected_jid
421
+ expect(stanza.to).to eq(expected_jid)
413
422
  end
414
423
  end
415
424
  end
@@ -417,7 +426,7 @@ module Punchblock
417
426
  describe "receiving events from a mixer" do
418
427
  context "after joining the mixer" do
419
428
  before do
420
- client.should_receive :write_with_handler
429
+ expect(client).to receive :write_with_handler
421
430
  subject.write Command::Join.new(:mixer_name => 'foomixer')
422
431
  end
423
432
 
@@ -432,12 +441,12 @@ module Punchblock
432
441
  let(:active_speaker_event) { import_stanza active_speaker_xml }
433
442
 
434
443
  it "should tag those events with a mixer name, rather than a call ID" do
435
- mock_event_handler.should_receive(:call).once.with do |event|
436
- event.should be_instance_of Event::StartedSpeaking
437
- event.target_mixer_name.should be == 'foomixer'
438
- event.target_call_id.should be nil
439
- event.domain.should be == 'rayo.net'
440
- end
444
+ expect(mock_event_handler).to receive(:call).once.with { |event|
445
+ expect(event).to be_instance_of Event::StartedSpeaking
446
+ expect(event.target_mixer_name).to eq('foomixer')
447
+ expect(event.target_call_id).to be nil
448
+ expect(event.domain).to eq('rayo.net')
449
+ }
441
450
  connection.__send__ :handle_presence, active_speaker_event
442
451
  end
443
452
  end