Sha256: f2f296891766a17fcf90291e30d69c1ef0c25c1a63119c3008040a8e78b06280

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

class UtilClass
  include Restcomm::REST::Utils
end

describe UtilClass do
  subject(:util) { UtilClass.new }

  it 'should convert a parameter name to a Restcomm-style name' do
    expect(util.restify('sms_url')).to eq('SmsUrl')
  end

  it 'should convert all parameter names to Restcomm-style names' do
    unrestified = {
      :sms_url => 'someUrl',
      'voiceFallbackUrl' => 'anotherUrl',
      'Status_callback' => 'yetAnotherUrl'
    }
    restified = {
      :SmsUrl => 'someUrl',
      :VoiceFallbackUrl => 'anotherUrl',
      :StatusCallback => 'yetAnotherUrl'
    }
    expect(util.restify(unrestified)).to eq(restified)
  end

  it 'should convert a Restcomm-style name to a parameter name' do
    expect(util.derestify('SmsUrl')).to eq('sms_url')
  end

  it 'should convert all Restcomm-style names to parameter names' do
    unrestified = {
      :sms_url => 'someUrl',
      :voice_fallback_url => 'anotherUrl',
      :status_callback => 'yetAnotherUrl'
    }
    restified = {
      :SmsUrl => 'someUrl',
      :VoiceFallbackUrl => 'anotherUrl',
      :StatusCallback => 'yetAnotherUrl'
    }
    expect(util.derestify(restified)).to eq(unrestified)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
restcomm-ruby-1.2.1 spec/rest/utils_spec.rb
restcomm-ruby-1.2.0 spec/rest/utils_spec.rb