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

Version Path
puffing-billy-3.0.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-2.4.1 spec/features/examples/intercept_request_spec.rb
puffing-billy-2.4.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-2.3.1 spec/features/examples/intercept_request_spec.rb
puffing-billy-2.3.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-2.2.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-2.1.1 spec/features/examples/intercept_request_spec.rb
puffing-billy-2.1.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-2.0.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-1.1.3 spec/features/examples/intercept_request_spec.rb
puffing-billy-1.1.2 spec/features/examples/intercept_request_spec.rb
puffing-billy-1.1.1 spec/features/examples/intercept_request_spec.rb
puffing-billy-1.1.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-1.0.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-0.12.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-0.11.1 spec/features/examples/intercept_request_spec.rb
puffing-billy-0.11.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-0.10.1 spec/features/examples/intercept_request_spec.rb
puffing-billy-0.10.0 spec/features/examples/intercept_request_spec.rb
puffing-billy-0.9.2 spec/features/examples/intercept_request_spec.rb