spec/resources/phone_number_spec.rb in phaxio-2.1.0.pre vs spec/resources/phone_number_spec.rb in phaxio-2.1.0
- old
+ new
@@ -1,18 +1,23 @@
require 'spec_helper'
RSpec.describe PhoneNumber do
- describe 'provisioning a number' do
- let(:action) { PhoneNumber.create params }
- let(:params) { {country_code: 1, area_code: 225} }
-
- around do |example|
- VCR.use_cassette('resources/phone_number/create') do
- example.run
+ describe PhoneNumber::Reference, vcr: 'phone_number/reference' do
+ describe '#get' do
+ it 'returns information about the referenced number' do
+ reference = PhoneNumber::Reference.new TEST_NUMBER
+ result = reference.get
+ expect(result).to be_a(PhoneNumber)
+ expect(result.phone_number).to eq(TEST_NUMBER)
end
end
+ end
+ describe 'provisioning a number', vcr: 'phone_number/create' do
+ let(:action) { PhoneNumber.create params }
+ let(:params) { {country_code: 1, area_code: 225} }
+
it 'makes the request to Phaxio' do
expect_api_request :post, 'phone_numbers', params
action
end
@@ -20,21 +25,15 @@
result = action
expect(result).to be_a(PhoneNumber)
end
end
- describe 'getting information about a number' do
+ describe 'getting information about a number', vcr: 'phone_number/get' do
let(:action) { PhoneNumber.get phone_number, params }
- let(:phone_number) { '12258675309' }
+ let(:phone_number) { TEST_NUMBER }
let(:params) { {} }
- around do |example|
- VCR.use_cassette('resources/phone_number/get') do
- example.run
- end
- end
-
it 'makes the request to Phaxio' do
expect_api_request :get, "phone_numbers/#{phone_number}"
action
end
@@ -42,20 +41,14 @@
result = action
expect(result).to be_a(PhoneNumber)
end
end
- describe 'listing numbers' do
+ describe 'listing numbers', vcr: 'phone_number/list' do
let(:action) { PhoneNumber.list params }
let(:params) { {} }
- around do |example|
- VCR.use_cassette('resources/phone_number/list') do
- example.run
- end
- end
-
it 'makes the request to Phaxio' do
expect_api_request :get, 'phone_numbers', params
action
end
@@ -63,19 +56,15 @@
result = action
expect(result).to be_a(Phaxio::Resource::Collection)
end
end
- describe 'releasing a number' do
+ describe 'releasing a number', vcr: 'phone_number/release' do
let(:action) { PhoneNumber.release phone_number, params }
- let(:phone_number) { '+12258675309' }
+ let(:phone_number) {
+ PhoneNumber.provision(country_code: 1, area_code: 225).phone_number
+ }
let(:params) { {} }
-
- around do |example|
- VCR.use_cassette('resources/phone_number/release') do
- example.run
- end
- end
it 'sends the request to Phaxio' do
expect_api_request :delete, "phone_numbers/#{phone_number}", params
action
end