Skip to content

Commit

Permalink
Ensure that punchblock uses .WAV extension for wav49 format, to align…
Browse files Browse the repository at this point in the history
… it with Asterisk
  • Loading branch information
Lloyd Hughes committed Oct 13, 2016
1 parent cb30075 commit eaf3298
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/punchblock/translator/asterisk/component/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def filename
end

def recording
Punchblock::Component::Record::Recording.new :uri => "file://#{filename}.#{@format}"
ext = @format.gsub('wav49', 'WAV')
Punchblock::Component::Record::Recording.new :uri => "file://#{filename}.#{ext}"
end

def stop_reason
Expand Down
17 changes: 17 additions & 0 deletions spec/punchblock/translator/asterisk/component/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,23 @@ module Component
expect(recording.uri).to match(/.*\.mp3$/)
end
end

context "set to 'wav49'" do
let(:command_options) { { :format => 'wav49' } }
it "should execute as 'wav49'" do
expect(ami_client).to receive(:send_action).once.with('Monitor', hash_including('Format' => 'wav49'))
subject.execute
expect(original_command.response(0.1)).to be_a Ref
end

it "provides the correct filename in the recording" do
expect(ami_client).to receive(:send_action)
subject.execute
monitor_stop_event = RubyAMI::Event.new 'MonitorStop', 'Channel' => channel
mock_call.process_ami_event monitor_stop_event
expect(recording.uri).to match(/.*\.WAV$/)
end
end
end

describe 'start_beep' do
Expand Down

0 comments on commit eaf3298

Please sign in to comment.