punchblock 2.5.2 → 2.5.3

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb567322334ceb90d6813db4059f8daa82d68e2e
4
- data.tar.gz: b9b41cf838b4a5507ff24c0bed04967d9b9e6f69
3
+ metadata.gz: 63ef1da0eed86d39e520b4e10984e068c8dc62e6
4
+ data.tar.gz: 6b48e400972ac2516337faae2a52f85089dab0cc
5
5
  SHA512:
6
- metadata.gz: 0fa93d60594fe156ed0edb84f3b59cb82943fe79be860770f2fb5a047d5189fdc6114b859a899f8819189dc66a162c5beaf1c0fe8b701bf4c16b80607c997e33
7
- data.tar.gz: 9d67e526bec8927736dfe9f5178655f7deb9957643c6171bbb97702010234b8e26eb59226899d690bcac247c0bb819662888ff16adeacfcb30a3a59f1bfd9dc3
6
+ metadata.gz: f8b33066c0816e1ac83c9911e3a8ba5b9ca717344d9bd970709a3555ba92e52f3170886ba3261d5b9b66ed95dd49e4edee63311723dc026f4f302d60c7e058d8
7
+ data.tar.gz: 6156cb56046135c814b3e11fe1844236d075a227e12972c2efa63a56ad5079314791a131b2e22136222a7626497af1f23beca04596f0200bb0732ec67b4448cd
data/.hound.yml ADDED
@@ -0,0 +1,2 @@
1
+ LineLength:
2
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # [develop](https://github.com/adhearsion/punchblock)
2
2
 
3
+ # [v2.5.3](https://github.com/adhearsion/punchblock/compare/v2.5.2...v2.5.3) - [2014-09-22](https://rubygems.org/gems/punchblock/versions/2.5.3)
4
+ * Bugfix: Prevent Asterisk translator death due to dead DTMF recognizers ([#221](https://github.com/adhearsion/punchblock/pull/221), [adhearsion/adhearsion#479](https://github.com/adhearsion/adhearsion/issues/479))
5
+ * Bugfix: Be more intelligent about only stripping true file extensions off filenames for playback on Asterisk ([adhearsion/adhearsion#482](https://github.com/adhearsion/adhearsion/issues/482))
6
+ * Bugfix: Handle a corner case crash where a recognition request is interrupted directly after a successful recognition has completed
7
+ * Bugfix: Avoid cases where executing AGI commands (reported as sending SIP messages) might block indefinitely due to a race condition in fetching their response value
8
+
3
9
  # [v2.5.2](https://github.com/adhearsion/punchblock/compare/v2.5.1...v2.5.2) - [2014-04-03](https://rubygems.org/gems/punchblock/versions/2.5.2)
4
10
  * Bugfix: No longer confound start and stop beeps on record commands (#220)
5
11
 
data/README.markdown CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Dependency Status](https://gemnasium.com/adhearsion/punchblock.png?travis)](https://gemnasium.com/adhearsion/punchblock)
4
4
  [![Code Climate](https://codeclimate.com/github/adhearsion/punchblock.png)](https://codeclimate.com/github/adhearsion/punchblock)
5
5
  [![Coverage Status](https://coveralls.io/repos/adhearsion/punchblock/badge.png?branch=develop)](https://coveralls.io/r/adhearsion/punchblock)
6
+ [![Inline docs](http://inch-ci.org/github/adhearsion/punchblock.png?branch=develop)](http://inch-ci.org/github/adhearsion/punchblock)
6
7
 
7
8
  # Punchblock
8
9
  Punchblock is a middleware library for telephony applications. Like Rack is to Rails and Sinatra, Punchblock provides a consistent API on top of several underlying third-party call control protocols.
@@ -38,4 +39,4 @@ The best available usage documentation available for Punchblock is by example, i
38
39
 
39
40
  ## Copyright
40
41
 
41
- Copyright (c) 2013 Adhearsion Foundation Inc. MIT licence (see LICENSE for details).
42
+ Copyright (c) 2014 Adhearsion Foundation Inc. MIT licence (see LICENSE for details).
@@ -254,12 +254,12 @@ module Punchblock
254
254
  # @raises RubyAMI::Error, ChannelGoneError
255
255
  def execute_agi_command(command, *params)
256
256
  agi = AGICommand.new Punchblock.new_uuid, channel, command, *params
257
- condition = Celluloid::Condition.new
257
+ response = Celluloid::Future.new
258
258
  register_tmp_handler :ami, name: 'AsyncAGI', [:[], 'SubEvent'] => 'Exec', [:[], 'CommandID'] => agi.id do |event|
259
- condition.signal event
259
+ response.signal Celluloid::SuccessResponse.new(nil, event)
260
260
  end
261
261
  agi.execute @ami_client
262
- event = condition.wait
262
+ event = response.value
263
263
  return unless event
264
264
  agi.parse_result event
265
265
  end
@@ -38,7 +38,6 @@ module Punchblock
38
38
 
39
39
  def execute_app(app, *args)
40
40
  UniMRCPApp.new(app, *args, unimrcp_app_options).execute @call
41
- raise UniMRCPError if @call.channel_var('RECOG_STATUS') == 'ERROR'
42
41
  end
43
42
 
44
43
  def unimrcp_app_options
@@ -85,14 +84,21 @@ module Punchblock
85
84
  end
86
85
 
87
86
  def complete
88
- send_complete_event case @call.channel_var('RECOG_COMPLETION_CAUSE')
89
- when '000'
90
- nlsml = RubySpeech.parse URI.decode(@call.channel_var('RECOG_RESULT'))
91
- Punchblock::Component::Input::Complete::Match.new nlsml: nlsml
92
- when '001'
93
- Punchblock::Component::Input::Complete::NoMatch.new
94
- when '002'
95
- Punchblock::Component::Input::Complete::NoInput.new
87
+ case @call.channel_var('RECOG_STATUS')
88
+ when 'INTERRUPTED'
89
+ send_complete_event Punchblock::Component::Input::Complete::NoMatch.new
90
+ when 'ERROR'
91
+ raise UniMRCPError
92
+ else
93
+ send_complete_event case @call.channel_var('RECOG_COMPLETION_CAUSE')
94
+ when '000'
95
+ nlsml = RubySpeech.parse URI.decode(@call.channel_var('RECOG_RESULT'))
96
+ Punchblock::Component::Input::Complete::Match.new nlsml: nlsml
97
+ when '001'
98
+ Punchblock::Component::Input::Complete::NoMatch.new
99
+ when '002'
100
+ Punchblock::Component::Input::Complete::NoInput.new
101
+ end
96
102
  end
97
103
  end
98
104
  end
@@ -126,7 +126,14 @@ module Punchblock
126
126
  end
127
127
 
128
128
  def path_for_audio_node(node)
129
- node.src.sub('file://', '').gsub(/\.[^\.]*$/, '')
129
+ path = node.src.sub('file://', '')
130
+ dir = File.dirname(path)
131
+ basename = File.basename(path, '.*')
132
+ if dir == '.'
133
+ basename
134
+ else
135
+ File.join(dir, basename)
136
+ end
130
137
  end
131
138
 
132
139
  def filenames(doc, check_audio_only_policy = -> {})
@@ -14,6 +14,8 @@ module Punchblock
14
14
 
15
15
  def process_dtmf(digit)
16
16
  @recognizer << digit
17
+ rescue Celluloid::DeadActorError
18
+ pb_logger.warn 'DTMF digit received into a dead recognizer. Dropping digit.'
17
19
  end
18
20
 
19
21
  def execute_command(command)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Punchblock
4
- VERSION = "2.5.2"
4
+ VERSION = "2.5.3"
5
5
  end
data/punchblock.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency %q<state_machine>, ["~> 1.0"]
29
29
  s.add_runtime_dependency %q<future-resource>, ["~> 1.0"]
30
30
  s.add_runtime_dependency %q<has-guarded-handlers>, ["~> 1.5"]
31
- s.add_runtime_dependency %q<celluloid>, ["~> 0.14"]
31
+ s.add_runtime_dependency %q<celluloid>, ["~> 0.15.2"]
32
32
  s.add_runtime_dependency %q<ruby_ami>, ["~> 2.2"]
33
33
  s.add_runtime_dependency %q<ruby_fs>, ["~> 1.1"]
34
34
  s.add_runtime_dependency %q<ruby_speech>, ["~> 2.3"]
@@ -10,14 +10,14 @@ module Punchblock
10
10
 
11
11
  it 'should store components and allow lookup by ID' do
12
12
  subject << component
13
- subject.find_by_uri(uri).should be component
13
+ expect(subject.find_by_uri(uri)).to be component
14
14
  end
15
15
 
16
16
  it 'should allow deletion of components' do
17
17
  subject << component
18
- subject.find_by_uri(uri).should be component
18
+ expect(subject.find_by_uri(uri)).to be component
19
19
  subject.delete component
20
- subject.find_by_uri(uri).should be_nil
20
+ expect(subject.find_by_uri(uri)).to be_nil
21
21
  end
22
22
  end
23
23
  end
@@ -8,8 +8,15 @@ module Punchblock
8
8
 
9
9
  subject { Client.new :connection => connection }
10
10
 
11
- its(:connection) { should be connection }
12
- its(:component_registry) { should be_a Client::ComponentRegistry }
11
+ describe '#connection' do
12
+ subject { super().connection }
13
+ it { should be connection }
14
+ end
15
+
16
+ describe '#component_registry' do
17
+ subject { super().component_registry }
18
+ it { should be_a Client::ComponentRegistry }
19
+ end
13
20
 
14
21
  let(:call_id) { 'abc123' }
15
22
  let(:mock_event) { double('Event').as_null_object }
@@ -20,14 +27,14 @@ module Punchblock
20
27
 
21
28
  describe '#run' do
22
29
  it 'should start up the connection' do
23
- connection.should_receive(:run).once
30
+ expect(connection).to receive(:run).once
24
31
  subject.run
25
32
  end
26
33
  end
27
34
 
28
35
  describe '#stop' do
29
36
  it 'should stop the connection' do
30
- connection.should_receive(:stop).once
37
+ expect(connection).to receive(:stop).once
31
38
  subject.stop
32
39
  end
33
40
  end
@@ -35,7 +42,7 @@ module Punchblock
35
42
  describe '#send_message' do
36
43
  it 'should send a message' do
37
44
  args = [ "someone", "example.org", "Hello World!" ]
38
- connection.should_receive(:send_message).with(*args).once
45
+ expect(connection).to receive(:send_message).with(*args).once
39
46
  subject.send_message *args
40
47
  end
41
48
  end
@@ -43,12 +50,12 @@ module Punchblock
43
50
  describe '#new_call_uri' do
44
51
  it 'should return the connection-specific fresh call ID' do
45
52
  stub_uuids 'foobar'
46
- subject.new_call_uri.should == 'xmpp:foobar@call.rayo.net'
53
+ expect(subject.new_call_uri).to eq('xmpp:foobar@call.rayo.net')
47
54
  end
48
55
  end
49
56
 
50
57
  it 'should handle connection events' do
51
- subject.should_receive(:handle_event).with(mock_event).once
58
+ expect(subject).to receive(:handle_event).with(mock_event).once
52
59
  connection.event_handler.call mock_event
53
60
  end
54
61
 
@@ -56,18 +63,18 @@ module Punchblock
56
63
  it "sets the event's client" do
57
64
  event = Event::Offer.new
58
65
  subject.handle_event event
59
- event.client.should be subject
66
+ expect(event.client).to be subject
60
67
  end
61
68
 
62
69
  context 'if the event can be associated with a source component' do
63
70
  before do
64
71
  mock_event.stub :source => mock_component
65
- mock_component.should_receive(:add_event).with mock_event
72
+ expect(mock_component).to receive(:add_event).with mock_event
66
73
  end
67
74
 
68
75
  it 'should not call event handlers' do
69
76
  handler = double 'handler'
70
- handler.should_receive(:call).never
77
+ expect(handler).to receive(:call).never
71
78
  subject.register_event_handler do |event|
72
79
  handler.call event
73
80
  end
@@ -82,7 +89,7 @@ module Punchblock
82
89
 
83
90
  it 'should call registered event handlers' do
84
91
  handler = double 'handler'
85
- handler.should_receive(:call).once.with mock_event
92
+ expect(handler).to receive(:call).once.with mock_event
86
93
  subject.register_event_handler do |event|
87
94
  handler.call event
88
95
  end
@@ -93,7 +100,7 @@ module Punchblock
93
100
 
94
101
  it 'should be able to register and retrieve components' do
95
102
  subject.register_component mock_component
96
- subject.find_component_by_uri(component_uri).should be mock_component
103
+ expect(subject.find_component_by_uri(component_uri)).to be mock_component
97
104
  end
98
105
 
99
106
  describe '#execute_command' do
@@ -101,7 +108,7 @@ module Punchblock
101
108
  let(:event) { Event::Complete.new }
102
109
 
103
110
  before do
104
- connection.should_receive(:write).once.with component, :call_id => call_id
111
+ expect(connection).to receive(:write).once.with component, :call_id => call_id
105
112
  end
106
113
 
107
114
  let :execute_command do
@@ -114,11 +121,11 @@ module Punchblock
114
121
 
115
122
  it "should set the command's client" do
116
123
  execute_command
117
- component.client.should be subject
124
+ expect(component.client).to be subject
118
125
  end
119
126
 
120
127
  it "should handle a component's events" do
121
- subject.should_receive(:trigger_handler).with(:event, event).once
128
+ expect(subject).to receive(:trigger_handler).with(:event, event).once
122
129
  execute_command
123
130
  component.request!
124
131
  component.execute!
@@ -6,7 +6,7 @@ module Punchblock
6
6
  module Command
7
7
  describe Accept do
8
8
  it 'registers itself' do
9
- RayoNode.class_from_registration(:accept, 'urn:xmpp:rayo:1').should be == described_class
9
+ expect(RayoNode.class_from_registration(:accept, 'urn:xmpp:rayo:1')).to eq(described_class)
10
10
  end
11
11
 
12
12
  describe "from a stanza" do
@@ -22,25 +22,35 @@ module Punchblock
22
22
  subject { RayoNode.from_xml parse_stanza(stanza).root, '9f00061', '1' }
23
23
 
24
24
  it { should be_instance_of described_class }
25
- its(:headers) { should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
25
+
26
+ describe '#headers' do
27
+ subject { super().headers }
28
+ it { should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
29
+ end
26
30
 
27
31
  context "with no headers provided" do
28
32
  let(:stanza) { '<accept xmlns="urn:xmpp:rayo:1"/>' }
29
33
 
30
- its(:headers) { should == {} }
34
+ describe '#headers' do
35
+ subject { super().headers }
36
+ it { should == {} }
37
+ end
31
38
  end
32
39
  end
33
40
 
34
41
  describe "when setting options in initializer" do
35
42
  subject { described_class.new headers: { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
36
43
 
37
- its(:headers) { should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
44
+ describe '#headers' do
45
+ subject { super().headers }
46
+ it { should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
47
+ end
38
48
 
39
49
  describe "exporting to Rayo" do
40
50
  it "should export to XML that can be understood by its parser" do
41
51
  new_instance = RayoNode.from_xml subject.to_rayo
42
- new_instance.should be_instance_of described_class
43
- new_instance.headers.should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' }
52
+ expect(new_instance).to be_instance_of described_class
53
+ expect(new_instance.headers).to eq({ 'X-skill' => 'agent', 'X-customer-id' => '8877' })
44
54
  end
45
55
 
46
56
  it "should render to a parent node if supplied" do
@@ -48,7 +58,7 @@ module Punchblock
48
58
  parent = Nokogiri::XML::Node.new 'foo', doc
49
59
  doc.root = parent
50
60
  rayo_doc = subject.to_rayo(parent)
51
- rayo_doc.should == parent
61
+ expect(rayo_doc).to eq(parent)
52
62
  end
53
63
  end
54
64
  end
@@ -6,7 +6,7 @@ module Punchblock
6
6
  module Command
7
7
  describe Answer do
8
8
  it 'registers itself' do
9
- RayoNode.class_from_registration(:answer, 'urn:xmpp:rayo:1').should be == described_class
9
+ expect(RayoNode.class_from_registration(:answer, 'urn:xmpp:rayo:1')).to eq(described_class)
10
10
  end
11
11
 
12
12
  describe "from a stanza" do
@@ -22,25 +22,35 @@ module Punchblock
22
22
  subject { RayoNode.from_xml parse_stanza(stanza).root, '9f00061', '1' }
23
23
 
24
24
  it { should be_instance_of described_class }
25
- its(:headers) { should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
25
+
26
+ describe '#headers' do
27
+ subject { super().headers }
28
+ it { should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
29
+ end
26
30
 
27
31
  context "with no headers provided" do
28
32
  let(:stanza) { '<answer xmlns="urn:xmpp:rayo:1"/>' }
29
33
 
30
- its(:headers) { should == {} }
34
+ describe '#headers' do
35
+ subject { super().headers }
36
+ it { should == {} }
37
+ end
31
38
  end
32
39
  end
33
40
 
34
41
  describe "when setting options in initializer" do
35
42
  subject { described_class.new headers: { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
36
43
 
37
- its(:headers) { should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
44
+ describe '#headers' do
45
+ subject { super().headers }
46
+ it { should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
47
+ end
38
48
 
39
49
  describe "exporting to Rayo" do
40
50
  it "should export to XML that can be understood by its parser" do
41
51
  new_instance = RayoNode.from_xml subject.to_rayo
42
- new_instance.should be_instance_of described_class
43
- new_instance.headers.should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' }
52
+ expect(new_instance).to be_instance_of described_class
53
+ expect(new_instance.headers).to eq({ 'X-skill' => 'agent', 'X-customer-id' => '8877' })
44
54
  end
45
55
 
46
56
  it "should render to a parent node if supplied" do
@@ -48,7 +58,7 @@ module Punchblock
48
58
  parent = Nokogiri::XML::Node.new 'foo', doc
49
59
  doc.root = parent
50
60
  rayo_doc = subject.to_rayo(parent)
51
- rayo_doc.should == parent
61
+ expect(rayo_doc).to eq(parent)
52
62
  end
53
63
 
54
64
  context "with multiple headers of the same name" do
@@ -56,8 +66,8 @@ module Punchblock
56
66
 
57
67
  it "should export to XML that can be understood by its parser" do
58
68
  new_instance = RayoNode.from_xml subject.to_rayo
59
- new_instance.should be_instance_of described_class
60
- new_instance.headers.should == { 'X-skill' => ['sales', 'complaints'] }
69
+ expect(new_instance).to be_instance_of described_class
70
+ expect(new_instance.headers).to eq({ 'X-skill' => ['sales', 'complaints'] })
61
71
  end
62
72
  end
63
73
  end
@@ -7,7 +7,7 @@ module Punchblock
7
7
  describe Dial do
8
8
 
9
9
  it 'registers itself' do
10
- RayoNode.class_from_registration(:dial, 'urn:xmpp:rayo:1').should be == described_class
10
+ expect(RayoNode.class_from_registration(:dial, 'urn:xmpp:rayo:1')).to eq(described_class)
11
11
  end
12
12
 
13
13
  let(:join_params) { {:call_uri => 'abc123'} }
@@ -15,23 +15,46 @@ module Punchblock
15
15
  describe "when setting options in initializer" do
16
16
  subject { described_class.new to: 'tel:+14155551212', from: 'tel:+13035551212', uri: 'xmpp:foo@bar.com', timeout: 30000, headers: { 'X-skill' => 'agent', 'X-customer-id' => '8877' }, join: join_params }
17
17
 
18
- its(:to) { should be == 'tel:+14155551212' }
19
- its(:from) { should be == 'tel:+13035551212' }
20
- its(:uri) { should be == 'xmpp:foo@bar.com' }
21
- its(:timeout) { should be == 30000 }
22
- its(:join) { should be == Join.new(join_params) }
23
- its(:headers) { should be == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
18
+ describe '#to' do
19
+ subject { super().to }
20
+ it { should be == 'tel:+14155551212' }
21
+ end
22
+
23
+ describe '#from' do
24
+ subject { super().from }
25
+ it { should be == 'tel:+13035551212' }
26
+ end
27
+
28
+ describe '#uri' do
29
+ subject { super().uri }
30
+ it { should be == 'xmpp:foo@bar.com' }
31
+ end
32
+
33
+ describe '#timeout' do
34
+ subject { super().timeout }
35
+ it { should be == 30000 }
36
+ end
37
+
38
+ describe '#join' do
39
+ subject { super().join }
40
+ it { should be == Join.new(join_params) }
41
+ end
42
+
43
+ describe '#headers' do
44
+ subject { super().headers }
45
+ it { should be == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
46
+ end
24
47
 
25
48
  describe "exporting to Rayo" do
26
49
  it "should export to XML that can be understood by its parser" do
27
50
  new_instance = RayoNode.from_xml subject.to_rayo
28
- new_instance.should be_instance_of described_class
29
- new_instance.to.should == 'tel:+14155551212'
30
- new_instance.from.should == 'tel:+13035551212'
31
- new_instance.uri.should == 'xmpp:foo@bar.com'
32
- new_instance.timeout.should == 30000
33
- new_instance.join.should == Join.new(join_params)
34
- new_instance.headers.should == { 'X-skill' => 'agent', 'X-customer-id' => '8877' }
51
+ expect(new_instance).to be_instance_of described_class
52
+ expect(new_instance.to).to eq('tel:+14155551212')
53
+ expect(new_instance.from).to eq('tel:+13035551212')
54
+ expect(new_instance.uri).to eq('xmpp:foo@bar.com')
55
+ expect(new_instance.timeout).to eq(30000)
56
+ expect(new_instance.join).to eq(Join.new(join_params))
57
+ expect(new_instance.headers).to eq({ 'X-skill' => 'agent', 'X-customer-id' => '8877' })
35
58
  end
36
59
 
37
60
  it "should render to a parent node if supplied" do
@@ -39,15 +62,15 @@ module Punchblock
39
62
  parent = Nokogiri::XML::Node.new 'foo', doc
40
63
  doc.root = parent
41
64
  rayo_doc = subject.to_rayo(parent)
42
- rayo_doc.should == parent
65
+ expect(rayo_doc).to eq(parent)
43
66
  end
44
67
 
45
68
  context "when attributes are not set" do
46
69
  subject { described_class.new to: 'abc123' }
47
70
 
48
71
  it "should not include them in the XML representation" do
49
- subject.to_rayo['to'].should == 'abc123'
50
- subject.to_rayo['from'].should be_nil
72
+ expect(subject.to_rayo['to']).to eq('abc123')
73
+ expect(subject.to_rayo['from']).to be_nil
51
74
  end
52
75
  end
53
76
  end
@@ -68,17 +91,43 @@ module Punchblock
68
91
 
69
92
  it { should be_instance_of described_class }
70
93
 
71
- its(:to) { should be == 'tel:+14155551212' }
72
- its(:from) { should be == 'tel:+13035551212' }
73
- its(:uri) { should be == 'xmpp:foo@bar.com' }
74
- its(:timeout) { should be == 30000 }
75
- its(:join) { should be == Join.new(join_params) }
76
- its(:headers) { should be == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
94
+ describe '#to' do
95
+ subject { super().to }
96
+ it { should be == 'tel:+14155551212' }
97
+ end
98
+
99
+ describe '#from' do
100
+ subject { super().from }
101
+ it { should be == 'tel:+13035551212' }
102
+ end
103
+
104
+ describe '#uri' do
105
+ subject { super().uri }
106
+ it { should be == 'xmpp:foo@bar.com' }
107
+ end
108
+
109
+ describe '#timeout' do
110
+ subject { super().timeout }
111
+ it { should be == 30000 }
112
+ end
113
+
114
+ describe '#join' do
115
+ subject { super().join }
116
+ it { should be == Join.new(join_params) }
117
+ end
118
+
119
+ describe '#headers' do
120
+ subject { super().headers }
121
+ it { should be == { 'X-skill' => 'agent', 'X-customer-id' => '8877' } }
122
+ end
77
123
 
78
124
  context "with no headers provided" do
79
125
  let(:stanza) { '<dial xmlns="urn:xmpp:rayo:1"/>' }
80
126
 
81
- its(:headers) { should == {} }
127
+ describe '#headers' do
128
+ subject { super().headers }
129
+ it { should == {} }
130
+ end
82
131
  end
83
132
  end
84
133
 
@@ -94,17 +143,17 @@ module Punchblock
94
143
 
95
144
  it "should set the transport from the ref" do
96
145
  subject.response = ref
97
- subject.transport.should be == 'xmpp'
146
+ expect(subject.transport).to eq('xmpp')
98
147
  end
99
148
 
100
149
  it "should set the call ID from the ref" do
101
150
  subject.response = ref
102
- subject.target_call_id.should be == call_id
151
+ expect(subject.target_call_id).to eq(call_id)
103
152
  end
104
153
 
105
154
  it "should set the domain from the ref" do
106
155
  subject.response = ref
107
- subject.domain.should be == domain
156
+ expect(subject.domain).to eq(domain)
108
157
  end
109
158
  end
110
159
  end