trabajo-afectivo/spec/lib/sequencer/unit/freshdesk/connected_spec.rb

30 lines
909 B
Ruby
Raw Normal View History

2021-05-25 12:30:12 +00:00
require 'rails_helper'
RSpec.describe Sequencer::Unit::Freshdesk::Connected, sequencer: :unit do
context 'when checking the connection to Freshdesk' do
let(:params) do
{
dry_run: false,
import_job: instance_double(ImportJob),
field_map: {},
id_map: {},
}
end
let(:response_ok) { Net::HTTPOK.new(1.0, '200', 'OK') }
let(:response_unauthorized) { Net::HTTPUnauthorized.new(1.0, '401', 'Unauthorized') }
it 'check for correct connection' do
allow(described_class).to receive(:perform_request).with(any_args).and_return(response_ok)
expect(process(params)).to eq({ connected: true })
end
it 'check for unauthorized connection' do
allow(described_class).to receive(:perform_request).with(any_args).and_return(response_unauthorized)
expect(process(params)).to eq({ connected: false })
end
end
end