-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a few tests and update CHANGELOG and CI for delivery
- Loading branch information
1 parent
8494908
commit 317f4af
Showing
5 changed files
with
115 additions
and
56 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,62 @@ | ||
name: Ruby | ||
name: Ruby CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
branches: | ||
- master | ||
pull_request: | ||
branches: [ master ] | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
test: | ||
|
||
integration-tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
ruby-version: ['2.7', '3.0', '3.1', '3.2'] | ||
ruby-version: ["2.7", "3.0", "3.1", "3.2"] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby-version }} | ||
bundler-cache: true | ||
- name: Run tests | ||
if: ${{ matrix.ruby-version == '3.2' && | ||
github.repository_owner == 'onfido' && | ||
github.actor != 'dependabot[bot]' }} | ||
run: bundle exec rspec spec | ||
env: | ||
ONFIDO_API_TOKEN: ${{ secrets.ONFIDO_API_TOKEN }} | ||
ONFIDO_SAMPLE_APPLICANT_ID: ${{ secrets.ONFIDO_SAMPLE_APPLICANT_ID }} | ||
ONFIDO_SAMPLE_VIDEO_ID_1: ${{ secrets.ONFIDO_SAMPLE_VIDEO_ID_1 }} | ||
ONFIDO_SAMPLE_VIDEO_ID_2: ${{ secrets.ONFIDO_SAMPLE_VIDEO_ID_2 }} | ||
ONFIDO_SAMPLE_MOTION_ID_1: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_1 }} | ||
ONFIDO_SAMPLE_MOTION_ID_2: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_2 }} | ||
- uses: actions/checkout@v4 | ||
- name: Set up Ruby ${{ matrix.ruby-version }} | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby-version }} | ||
bundler-cache: true | ||
- name: Run integration tests | ||
if: ${{ matrix.ruby-version == '3.2' && | ||
github.repository_owner == 'onfido' && | ||
github.actor != 'dependabot[bot]' }} | ||
run: bundle exec rspec spec | ||
env: | ||
ONFIDO_API_TOKEN: ${{ secrets.ONFIDO_API_TOKEN }} | ||
ONFIDO_SAMPLE_APPLICANT_ID: ${{ secrets.ONFIDO_SAMPLE_APPLICANT_ID }} | ||
ONFIDO_SAMPLE_VIDEO_ID_1: ${{ secrets.ONFIDO_SAMPLE_VIDEO_ID_1 }} | ||
ONFIDO_SAMPLE_VIDEO_ID_2: ${{ secrets.ONFIDO_SAMPLE_VIDEO_ID_2 }} | ||
ONFIDO_SAMPLE_MOTION_ID_1: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_1 }} | ||
ONFIDO_SAMPLE_MOTION_ID_2: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_2 }} | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
needs: integration-tests | ||
if: github.event_name == 'release' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Ruby 2.7 | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "2.7" | ||
|
||
- name: Publish to RubyGems | ||
run: | | ||
mkdir -p $HOME/.gem | ||
touch $HOME/.gem/credentials | ||
chmod 0600 $HOME/.gem/credentials | ||
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | ||
gem build *.gemspec | ||
gem push *.gem | ||
env: | ||
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
require 'onfido' | ||
|
||
describe Onfido::ApiClient do | ||
describe '#user agent header' do | ||
it 'contains a user agent header' do | ||
expect(subject.default_headers['User-Agent']).to match(/^onfido-ruby\/\d+\.\d+\.\d+$/) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
require 'onfido' | ||
|
||
describe Onfido::Configuration do | ||
describe '#authorization header' do | ||
it 'sets the authorization header from the given token' do | ||
subject.api_token = 'api_token' | ||
|
||
expect(subject.api_key).to eq ({'Token'=> 'Token token=api_token'}) | ||
end | ||
end | ||
|
||
describe '#region selection' do | ||
it 'allows setting the EU region' do | ||
subject.region = Onfido::Configuration::REGIONS[:EU] | ||
|
||
expect(subject.base_url).to eq ("https://api.eu.onfido.com/v3.6") | ||
end | ||
|
||
it 'allows setting the US region' do | ||
subject.region = Onfido::Configuration::REGIONS[:US] | ||
|
||
expect(subject.base_url).to eq ("https://api.us.onfido.com/v3.6") | ||
end | ||
|
||
it 'allows setting the CA region' do | ||
subject.region = Onfido::Configuration::REGIONS[:CA] | ||
|
||
expect(subject.base_url).to eq ("https://api.ca.onfido.com/v3.6") | ||
end | ||
|
||
it 'use EU region if region was not provided' do | ||
expect(subject.base_url).to eq ("https://api.eu.onfido.com/v3.6") | ||
end | ||
|
||
it 'throws an error for unknown regions' do | ||
subject.region = "abc" | ||
expect{ | ||
subject.base_url | ||
}.to raise_error(ArgumentError) | ||
end | ||
|
||
end | ||
|
||
describe '#timeout' do | ||
it 'allows changing the default timeout' do | ||
subject.timeout = 123 | ||
|
||
expect(subject.timeout).to eq (123) | ||
end | ||
end | ||
end |