Skip to content

Commit

Permalink
Merge 69536f9 into a95afdb
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Jun 16, 2015
2 parents a95afdb + 69536f9 commit af42df8
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 163 deletions.
2 changes: 1 addition & 1 deletion punchblock.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency %q<ruby_jid>, ["~> 1.0"]

s.add_development_dependency %q<bundler>, ["~> 1.0"]
s.add_development_dependency %q<rspec>, ["~> 2.13"]
s.add_development_dependency %q<rspec>, ["~> 3.0"]
s.add_development_dependency %q<ci_reporter>, ["~> 1.6"]
s.add_development_dependency %q<yard>, ["~> 0.6"]
s.add_development_dependency %q<rake>, [">= 0"]
Expand Down
4 changes: 2 additions & 2 deletions spec/punchblock/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module Punchblock

context 'if the event can be associated with a source component' do
before do
mock_event.stub :source => mock_component
allow(mock_event).to receive_messages :source => mock_component
expect(mock_component).to receive(:add_event).with mock_event
end

Expand All @@ -84,7 +84,7 @@ module Punchblock

context 'if the event cannot be associated with a source component' do
before do
mock_event.stub :source => nil
allow(mock_event).to receive_messages :source => nil
end

it 'should call registered event handlers' do
Expand Down
2 changes: 1 addition & 1 deletion spec/punchblock/command/join_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module Command

describe "with a direction" do
[nil, :duplex, :send, :recv].each do |direction|
describe direction do
describe direction.to_s do
subject { described_class.new :direction => direction }

describe '#direction' do
Expand Down
2 changes: 1 addition & 1 deletion spec/punchblock/command/reject_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module Command

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

describe '#reason' do
Expand Down
62 changes: 30 additions & 32 deletions spec/punchblock/component/asterisk/agi/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,46 @@ module AGI
end
end

class Command
describe Complete::Success do
let :stanza do
<<-MESSAGE
describe Command::Complete::Success do
let :stanza do
<<-MESSAGE
<complete xmlns="urn:xmpp:rayo:ext:1">
<success xmlns="urn:xmpp:rayo:asterisk:agi:complete:1">
<code>200</code>
<result>0</result>
<data>1187188485.0</data>
</success>
</complete>
MESSAGE
end
MESSAGE
end

subject { RayoNode.from_xml(parse_stanza(stanza).root).reason }
subject { RayoNode.from_xml(parse_stanza(stanza).root).reason }

it { is_expected.to be_instance_of described_class }
it { is_expected.to be_instance_of described_class }

describe '#name' do
subject { super().name }
it { is_expected.to eq(:success) }
end

describe '#name' do
subject { super().name }
it { is_expected.to eq(:success) }
describe '#code' do
subject { super().code }
it { is_expected.to eq(200) }
end

describe '#result' do
subject { super().result }
it { is_expected.to eq(0) }
end

describe '#data' do
subject { super().data }
it { is_expected.to eq('1187188485.0') }
end

describe "when setting options in initializer" do
subject do
described_class.new code: 200, result: 0, data: '1187188485.0'
end

describe '#code' do
Expand All @@ -91,27 +110,6 @@ class Command
subject { super().data }
it { is_expected.to eq('1187188485.0') }
end

describe "when setting options in initializer" do
subject do
Complete::Success.new code: 200, result: 0, data: '1187188485.0'
end

describe '#code' do
subject { super().code }
it { is_expected.to eq(200) }
end

describe '#result' do
subject { super().result }
it { is_expected.to eq(0) }
end

describe '#data' do
subject { super().data }
it { is_expected.to eq('1187188485.0') }
end
end
end
end
end
Expand Down
120 changes: 58 additions & 62 deletions spec/punchblock/component/asterisk/ami/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ module AMI
end
end

class Action
class Complete
describe Success do
let :stanza do
<<-MESSAGE
describe Action::Complete::Success do
let :stanza do
<<-MESSAGE
<complete xmlns="urn:xmpp:rayo:ext:1">
<success xmlns="urn:xmpp:rayo:asterisk:ami:complete:1">
<message>Originate successfully queued</message>
Expand All @@ -118,64 +116,62 @@ class Complete
<attribute name="State" value="Ring"/>
</success>
</complete>
MESSAGE
end

subject { RayoNode.from_xml(parse_stanza(stanza).root).reason }

it { is_expected.to be_instance_of described_class }

describe '#name' do
subject { super().name }
it { is_expected.to eq(:success) }
end

describe '#message' do
subject { super().message }
it { is_expected.to eq("Originate successfully queued") }
end

describe '#text_body' do
subject { super().text_body }
it { is_expected.to eq('Some thing happened') }
end

describe '#headers' do
subject { super().headers }
it { is_expected.to eq({'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}) }
end

describe '#attributes' do
subject { super().attributes }
it { is_expected.to eq({'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}) }
end # For BC

describe "when setting options in initializer" do
subject do
described_class.new message: 'Originate successfully queued', text_body: 'Some thing happened', headers: {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}
end

describe '#message' do
subject { super().message }
it { is_expected.to eq('Originate successfully queued') }
end

describe '#text_body' do
subject { super().text_body }
it { is_expected.to eq('Some thing happened') }
end

describe '#headers' do
subject { super().headers }
it { is_expected.to eq({'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}) }
end

describe '#attributes' do
subject { super().attributes }
it { is_expected.to eq({'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}) }
end # For BC
end
MESSAGE
end

subject { RayoNode.from_xml(parse_stanza(stanza).root).reason }

it { is_expected.to be_instance_of described_class }

describe '#name' do
subject { super().name }
it { is_expected.to eq(:success) }
end

describe '#message' do
subject { super().message }
it { is_expected.to eq("Originate successfully queued") }
end

describe '#text_body' do
subject { super().text_body }
it { is_expected.to eq('Some thing happened') }
end

describe '#headers' do
subject { super().headers }
it { is_expected.to eq({'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}) }
end

describe '#attributes' do
subject { super().attributes }
it { is_expected.to eq({'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}) }
end # For BC

describe "when setting options in initializer" do
subject do
described_class.new message: 'Originate successfully queued', text_body: 'Some thing happened', headers: {'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}
end

describe '#message' do
subject { super().message }
it { is_expected.to eq('Originate successfully queued') }
end

describe '#text_body' do
subject { super().text_body }
it { is_expected.to eq('Some thing happened') }
end

describe '#headers' do
subject { super().headers }
it { is_expected.to eq({'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}) }
end

describe '#attributes' do
subject { super().attributes }
it { is_expected.to eq({'Channel' => 'SIP/101-3f3f', 'State' => 'Ring'}) }
end # For BC
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/punchblock/component/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module Component

describe "with a direction" do
[nil, :duplex, :send, :recv].each do |direction|
describe direction do
describe direction.to_s do
subject { described_class.new :direction => direction }

describe '#direction' do
Expand Down
4 changes: 3 additions & 1 deletion spec/punchblock/connection/asterisk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module Connection

describe '#run' do
it 'starts the RubyAMI::Stream' do
expect(subject.ami_client.async).to receive(:run).once do
expect(subject.ami_client.wrapped_object).to receive(:run).once do
subject.ami_client.terminate
end
expect { subject.run }.to raise_error DisconnectedError
Expand Down Expand Up @@ -76,6 +76,7 @@ module Connection
end

it 'sends events from RubyAMI to the translator' do
pending "Replace with integration tests"
event = RubyAMI::Event.new 'FullyBooted'
expect(subject.translator.async).to receive(:handle_ami_event).once.with event
expect(subject.translator.async).to receive(:handle_ami_event).once.with RubyAMI::Stream::Disconnected.new
Expand All @@ -84,6 +85,7 @@ module Connection

describe '#write' do
it 'sends a command to the translator' do
pending "Replace with integration tests"
command = double 'Command'
options = {:foo => :bar}
expect(subject.translator.async).to receive(:execute_command).once.with command, options
Expand Down
2 changes: 1 addition & 1 deletion spec/punchblock/connection/xmpp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ module Connection

before do
@now = DateTime.now
DateTime.stub now: @now
allow(DateTime).to receive_messages now: @now
end

let(:example_event) { import_stanza offer_xml }
Expand Down

0 comments on commit af42df8

Please sign in to comment.