Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[WIP] add tests
  • Loading branch information
citin committed Sep 4, 2024
commit e488f0d82da4e2d41fbd107b109392f0463c382c
6 changes: 6 additions & 0 deletions .env.test.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
API_URL=""

CLIENT_ID=""
CLIENT_SECRET=""
REFRESH_TOKEN=""

COCKPIT_USER_ID=""
COCKPIT_USER_NAME=""
COCKPIT_USER_EMAIL=""
COCKPIT_USER_PASSWORD=""
22 changes: 22 additions & 0 deletions spec/beyond_api/services/authentication/email_address_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

RSpec.describe BeyondApi::Authentication::EmailAddress, vcr: true do
let(:client) { described_class.new(api_url: ENV.fetch('API_URL', nil), access_token: beyond_access_token) }

let(:user_id) { ENV.fetch('COCKPIT_USER_ID', nil) }
let(:user_email) { ENV.fetch('COCKPIT_USER_EMAIL', nil) }
let(:user_password) { ENV.fetch('COCKPIT_USER_PASSWORD', nil) }

let(:new_email) { '[email protected]' }

describe '#trigger_change' do
it 'change email address' do
# client.trigger_change(user_id, 'en-US', user_password, new_email)
end

after do
# # Rollback email address change
# client.trigger_change(user_id, 'en-US', user_password, user_email)
end
end
end
66 changes: 66 additions & 0 deletions spec/beyond_api/services/authentication/user_and_password_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# frozen_string_literal: true

RSpec.describe BeyondApi::Authentication::UserAndPassword, vcr: true do
let(:client) { described_class.new(api_url: ENV.fetch('API_URL', nil), access_token: beyond_access_token) }

let(:user_id) { ENV.fetch('COCKPIT_USER_ID', nil) }
let(:user_name) { ENV.fetch('COCKPIT_USER_NAME', nil) }
let(:user_email) { ENV.fetch('COCKPIT_USER_EMAIL', nil) }
let(:user_password) { ENV.fetch('COCKPIT_USER_PASSWORD', nil) }

describe '#verify_password' do
let(:new_password) { 'ValidPassword123' }

it 'sends a post request with the correct parameters' do
# client.verify_password('merchant', new_password)
end
end

describe '#change_password' do
let(:new_password) { 'ValidPassword123' }

it 'sends a post request with the correct parameters' do
# client.change_password(
# user_id,
# user_password,
# new_password
# )
end

after do
# # Rollback the password change
# client.change_password(
# user_id,
# new_password,
# user_password
# )
end
end

describe '#password_reset_email' do
it 'sends a post request with the correct parameters' do
# client.password_reset_email(user_email)
end
end

describe '#change_username' do
let(:new_name) { 'test-user' }

it 'sends a post request with the correct parameters' do
# client.change_username(
# user_id,
# user_password,
# new_name
# )
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave the tests like follows (I just put one example):

# client.change_username(
#   user_id,
#   user_password,
#   new_name
# )
it 'sends a post request with the correct parameters'

I believe that writing an it statement without a block displays a "Pending" message when running the tests.


after do
# # Rollback the username change
# client.change_username(
# user_id,
# user_password,
# user_name
# )
end
end
end