Skip to content

Commit

Permalink
[wip] Specs for TravelPay::ClaimsController
Browse files Browse the repository at this point in the history
  • Loading branch information
Athif Wulandana committed Mar 5, 2024
1 parent 0c3140d commit 9d70123
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
21 changes: 21 additions & 0 deletions modules/travel_pay/spec/controllers/claims_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe TravelPay::ClaimsController, type: :controller do
before do
veis_response = double
allow(veis_response).to receive(:body).and_return( {'access_token' => 'sample_token'} )
allow_any_instance_of(TravelPay::Client).to receive(:request_veis_token).and_return(veis_response)
btsss_ping_response = double
allow(btsss_ping_response).to receive(:status).and_return('online')
allow_any_instance_of(TravelPay::Client).to receive(:ping).and_return(btsss_ping_response)
end

describe '#index' do
it 'requests a token and sends a ping to BTSSS' do
get(:index)
expect(response.body).to eq('Received ping from upstream server with status online.')
end
end
end
13 changes: 8 additions & 5 deletions modules/travel_pay/spec/services/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
require 'rails_helper'

describe TravelPay::Client do
before do
@stubs = Faraday::Adapter::Test::Stubs.new
conn = Faraday.new { |b| b.adapter(:test, @stubs) }
allow_any_instance_of(TravelPay::Client).to receive(:connection).and_return(conn)
veis_params_stub = {
let(:veis_params_stub) do
{
client_id: 'sample_id',
client_secret: 'sample_client',
client_info: 1,
grant_type: 'client_credentials',
resource: 'sample_resource'
}
end

before do
@stubs = Faraday::Adapter::Test::Stubs.new
conn = Faraday.new { |b| b.adapter(:test, @stubs) }
allow_any_instance_of(TravelPay::Client).to receive(:connection).and_return(conn)
allow_any_instance_of(TravelPay::Client).to receive(:veis_params).and_return(veis_params_stub)
end

Expand Down

0 comments on commit 9d70123

Please sign in to comment.