Sha256: 320908dc12dd8f85acac2112e5e3069a424378d4b527f26f49e25e4aec3c6764

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'helper'

describe CheckMobi::Resources::Voice::Actions::Hangup do

  before do
    @endpoint = 'https://api.checkmobi.com/v1/call'

    CheckMobi.api_key = ENV['API_KEY']

    @resource = CheckMobi::Resources::Voice::Call.new(
        to: ENV['PHONE_NUMBER'],
        platform: 'android'
    )

    @hangup_action = CheckMobi::Resources::Voice::Actions::Hangup.new(reason: 'rejected')
  end

  it 'should set action name implicitly' do
    @hangup_action.action.must_equal 'hangup'
  end

  it 'should not allow setting action name' do
    @hangup_action.respond_to?(:action=).must_equal false
  end

  it 'should request properly' do
    stub_post_request(@endpoint)
    @resource.events << @hangup_action
    @resource.perform
    assert_requested(:post, @endpoint,
                     body: {
                         from: nil,
                         to: ENV['PHONE_NUMBER'],
                         notification_callback: nil, platform: 'android',
                         events: [{action: 'hangup', reason: 'rejected'}]
                     },
                     headers: headers_with_authorization,
                     times: 1
    )
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
check_mobi-1.0.5 test/check_mobi/resources/voice/actions/hangup_action_test.rb
check_mobi-1.0.4 test/check_mobi/resources/voice/actions/hangup_action_test.rb
check_mobi-1.0.3 test/check_mobi/resources/voice/actions/hangup_action_test.rb
check_mobi-1.0.2 test/check_mobi/resources/voice/actions/hangup_action_test.rb
check_mobi-1.0.1 test/check_mobi/resources/voice/actions/hangup_action_test.rb