Sha256: 7ffbf6b6c0729f2b51b3ea0cbeeb2fddbe0e621f20f447b09f022ff5122bd102
Contents?: true
Size: 1019 Bytes
Versions: 1
Compression:
Stored size: 1019 Bytes
Contents
require 'spec_helper' describe TS::HTTP do %i( get delete post put ).each do |method| it method do url = 'https://www.tanga.com' response = double(parsed_response: 'body', code: 200) expect(HTTParty).to receive(method).with(url, options: ['here']) { response } body = described_class.send(method, 'https://www.tanga.com', options: ['here']) expect(body).to be == response end end it 'handles json parse error' do VCR.use_cassette('invalid json') do expect do described_class.get('https://rawgit.com/joevandyk/a370a1fd94a3e6f88e08/raw/9acc356880ee36e8fd1585db1f1c1582ab3c89ad/bad.json') end.to raise_error(described_class::Exception, /unexpected token/) end end it 'puts response code on invalid requests' do VCR.use_cassette('422 request') do begin described_class.get('https://httpbin.org/status/418') fail 'i should not get here' rescue => e expect(e.code).to be == 418 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tanga_services-0.0.13 | spec/http_spec.rb |