Sha256: 95c697748254c38988ce537ab346218abad223eac9e1b3cdf871b71591c51e81
Contents?: true
Size: 904 Bytes
Versions: 23
Compression:
Stored size: 904 Bytes
Contents
require 'spec_helper' require 'timeout' describe 'intercept request example', type: :feature, js: true do before do Billy.config.record_stub_requests = true end it 'should intercept a GET request directly' do stub = proxy.stub('http://example.com/').and_return( headers: { 'Access-Control-Allow-Origin' => '*' }, code: 200 ) visit 'http://example.com/' expect(stub.has_requests?).to be true expect(stub.requests).not_to be_empty end it 'should intercept a POST request through an intermediary page' do stub = proxy.stub('http://example.com/', method: 'post').and_return( headers: { 'Access-Control-Allow-Origin' => '*' }, code: 200 ) visit '/intercept_request.html' Timeout::timeout(5) do sleep(0.1) until stub.has_requests? end request = stub.requests.shift expect(request[:body]).to eql 'foo=bar' end end
Version data entries
23 entries across 23 versions & 1 rubygems