Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoegel committed Jul 25, 2023
1 parent 7f04856 commit 3b1c40b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion spec/api_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@

describe '#build_request_url' do
it 'adds leading and trailing slashes to path' do
expect(api_client_default.build_request_url('test/path')).to eq('/test/path')
expect(api_client_default.build_request_url('test/path')).to eq('http://localhost/test/path')
end
end

Expand Down
26 changes: 19 additions & 7 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,31 @@
end

describe '#base_url' do
it 'Returns default base URL when server_index is nil' do
config.server_index = nil
expect(config.base_url).to eq('http://localhost')
end

it 'returns empty string when invalid operation is passed' do
expect(config.base_url('invalid_operation')).to eq('')
it 'returns default value when invalid operation is passed' do
expect(config.base_url('invalid_operation')).to eq('http://localhost')
end

it 'returns proper base URL when server index is set' do
operation, server = config.operation_server_settings.first
expect(config.base_url(operation)).to eq(server[0][:url])
end

it 'should have the default value' do
expect(config.base_url).to eq("http://localhost")
end

it 'returns default value when invalid operation is passed' do
expect(config.base_url('invalid_operation')).to eq('http://localhost')
end

it 'throws argument error when attempting to use a server index that is out of bounds' do
config.server_operation_index = {
:'MediaApi.upload_media' => 10
}
expect {
config.base_url(:'MediaApi.upload_media')
}.to raise_error(ArgumentError, 'Invalid index 10 when selecting the server. Must not be nil and must be less than 1')
end
end

describe '#api_key_with_prefix' do
Expand Down
14 changes: 10 additions & 4 deletions spec/models/message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
time: '2022-06-16T13:15:07.160Z',
segment_count: 2,
direction: 'in',
direction: Bandwidth::MessageDirectionEnum::IN,
to: ['+19195551234'],
from: '+19195554321',
media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
Expand Down Expand Up @@ -37,6 +37,12 @@
end
end

describe 'enum validation' do
it 'works' do

end
end

describe 'EnumAttributeValidator' do
it 'validates string enum' do
validator = Bandwidth::Message::EnumAttributeValidator.new(String, ['valid'])
Expand Down Expand Up @@ -65,7 +71,7 @@
applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
time: '2022-06-16T13:15:07.160Z',
segmentCount: 2,
direction: 'in',
direction: Bandwidth::MessageDirectionEnum::IN,
to: ['+19195551234'],
from: '+19195554321',
media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
Expand All @@ -80,7 +86,7 @@
expect(message_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
expect(message_from_hash.time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
expect(message_from_hash.segment_count).to eq(2)
expect(message_from_hash.direction).to eq('in')
expect(message_from_hash.direction).to eq(Bandwidth::MessageDirectionEnum::IN)
expect(message_from_hash.to).to eq(['+19195551234'])
expect(message_from_hash.from).to eq('+19195554321')
expect(message_from_hash.media).to eq(['https://dev.bandwidth.com/images/bandwidth-logo.png'])
Expand Down Expand Up @@ -131,7 +137,7 @@
applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
time: '2022-06-16T13:15:07.160Z',
segmentCount: 2,
direction: 'in',
direction: Bandwidth::MessageDirectionEnum::IN,
to: ['+19195551234'],
from: '+19195554321',
media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
Expand Down

0 comments on commit 3b1c40b

Please sign in to comment.