demarches-normaliennes/spec/lib/api_entreprise/privileges_adapter_spec.rb

27 lines
707 B
Ruby
Raw Normal View History

# frozen_string_literal: true
describe APIEntreprise::PrivilegesAdapter do
let(:body) { File.read('spec/fixtures/files/api_entreprise/privileges.json') }
let(:status) { 200 }
let(:token) { "secret-token" }
let(:adapter) { described_class.new(token) }
subject { adapter }
before do
2023-11-14 17:22:18 +01:00
stub_request(:get, "https://entreprise.api.gouv.fr/privileges")
.to_return(body: body, status: status)
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
end
it { is_expected.to be_valid }
context 'when token is not valid or missing' do
let(:token) { nil }
let(:status) { 403 }
let(:body) { '' }
it { is_expected.not_to be_valid }
end
end