Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unitTests #156

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
30 changes: 30 additions & 0 deletions .github/workflows/unitTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: UnitTests

on:
push:
branches: [ unitTests ]
pull_request:
branches: [ master ]

jobs:
build:
name: UnitTests
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: [ 'head', '2.4', '2.3', '2.2' ,'2.1', '2.0' ]

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Dependencies Installation
run: |
bundle install --without development
- name: Run Tests
run: |
ruby --version
bundle exec rake
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ group :test do
gem 'rspec', '~> 3.0'
gem 'simplecov'
gem 'json'
gem 'rexml'
end
1 change: 1 addition & 0 deletions spec/resource_lookup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
method: "GET",
data: nil)
expect(response.phone_number).to eql("+14154305555")
puts response
end
end
13 changes: 13 additions & 0 deletions spec/resource_media_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ def to_json_list(list_object)
offset: 4
})
end

def to_json(media)
{
api_id: media.api_id,
content_type: media.content_type,
file_name: media.file_name,
size: media.size,
media_id: media.media_id,
upload_time: media.upload_time,
url: media.url,
}.to_json
end

it 'fetches details of a media' do
contents = File.read(Dir.pwd + '/spec/mocks/mediaGetResponse.json')
mock(200, JSON.parse(contents))
Expand Down
28 changes: 20 additions & 8 deletions spec/resource_powerpacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def to_json_list(list_object)
meta: list_object[:meta],
objects: objects_json
}.to_json
end
end

it 'lists all powerpack' do
contents = File.read(Dir.pwd + '/spec/mocks/powerpackListResponse.json')
Expand All @@ -30,6 +30,21 @@ def to_json_list(list_object)
offset: 4
})
end

def to_json(media)
{
api_id: media.api_id,
application_id: media.application_id,
application_type: media.application_type,
created_on: media.created_on,
local_connect: media.local_connect,
name: media.name,
number_pool: media.number_pool,
sticky_sender: media.sticky_sender,
uuid: media.uuid,
}.to_json
end

it 'fetches details of a powerpack' do
contents = File.read(Dir.pwd + '/spec/mocks/powerpackResponse.json')
mock(200, JSON.parse(contents))
Expand Down Expand Up @@ -104,7 +119,7 @@ def to_json_list(list_object)
.get(
'86bbb125-97bb-4d72-89fd-81d5c515b015'
)
response = powerpack.find_numbers('14845733594')
response = powerpack.find_number('14845733594')
# response = powerpack.numberpool.numbers.find('14845733594')
expect(JSON.parse(to_json(response)))
.to eql(JSON.parse(contents))
Expand All @@ -122,7 +137,7 @@ def to_json_list(list_object)
.get(
'86bbb125-97bb-4d72-89fd-81d5c515b015'
)
response = powerpack.add_numbers('14845733594')
response = powerpack.add_number('14845733594')
# response = powerpack.numberpool.numbers.add('14845733594')
expect(JSON.parse(to_json(response)))
.to eql(JSON.parse(contents))
Expand Down Expand Up @@ -189,11 +204,8 @@ def to_json_list(list_object)
it 'remove shortcode' do
contents = File.read(Dir.pwd + '/spec/mocks/powerpackDelete.json')
mock(200, JSON.parse(contents))
powerpack = @api.powerpacks
.get(
'86bbb125-97bb-4d72-89fd-81d5c515b015'
)
response = powerpack.remove_tollfree('444444')
powerpack = @api.powerpacks.get("86bbb125-97bb-4d72-89fd-81d5c515b015")
response = powerpack.remove_shortcode('444444')
expect(JSON.parse(to_json(response)))
.to eql(JSON.parse(contents))
compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Shortcode/444444/'\
Expand Down