Sha256: 107af7dc117b1c656d89fa17e2f705586b501920995a6d4b2360b0e1a06758e7
Contents?: true
Size: 1.2 KB
Versions: 49
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe LHC::Request do context 'encoding url' do let(:url) { 'http://local.ch/something with spaces' } it 'can request urls with spaces inside' do stub_request(:get, URI.encode(url)) LHC.get(url) end end context 'encoding params' do let(:url) { 'http://local.ch/api/search?name=:name' } it 'can do requests with params including spaces' do stub_request(:get, 'http://local.ch/api/search?name=My%20name%20is%20rabbit') LHC.get(url, params: { name: 'My name is rabbit' }) end end context 'skip encoding' do let(:url) { 'http://local.ch/api/search?names[]=seba&names[]=david' } it 'does not encode if encoding is skipped' do stub_request(:get, 'http://local.ch/api/search?names%5B%5D%3Dseba%26names%5B%5D%3Ddavid') LHC.get('http://local.ch/api/search?names%5B%5D%3Dseba%26names%5B%5D%3Ddavid', url_encoding: false) end it 'does double encoding, if you really want to' do stub_request(:get, 'http://local.ch/api/search?names%255B%255D%253Dseba%2526names%255B%255D%253Ddavid') LHC.get('http://local.ch/api/search?names%5B%5D%3Dseba%26names%5B%5D%3Ddavid') end end end
Version data entries
49 entries across 49 versions & 1 rubygems