requester_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. require 'rails_helper'
  2. RSpec.describe Import::OTRS::Requester do
  3. it 'responds to load' do
  4. expect(described_class).to respond_to('load')
  5. end
  6. it 'responds to list' do
  7. expect(described_class).to respond_to('list')
  8. end
  9. it 'responds to connection_test' do
  10. expect(described_class).to respond_to('connection_test')
  11. end
  12. context 'caching request results' do
  13. let(:response) {
  14. response = double()
  15. response_body = double()
  16. expect(response_body).to receive(:to_s).at_least(:once).and_return('{"Result": {}}')
  17. expect(response).to receive('success?').at_least(:once).and_return(true)
  18. expect(response).to receive('body').at_least(:once).and_return(response_body)
  19. response
  20. }
  21. it 'is active if no args are given' do
  22. expect(UserAgent).to receive(:post).and_return(response)
  23. described_class.load('Ticket')
  24. described_class.load('Ticket')
  25. end
  26. it 'is not active if args are given' do
  27. expect(UserAgent).to receive(:post).twice.and_return(response)
  28. described_class.load('Ticket', offset: 10)
  29. described_class.load('Ticket', offset: 20)
  30. end
  31. end
  32. end