vcr with capybara-webkit

后端 未结 2 2032
-上瘾入骨i
-上瘾入骨i 2021-02-04 08:06

I\'m using capybara-webkit to test integration with a third party website (I need javascript).

I want to use vcr to record requests made during the integration test but

2条回答
  •  日久生厌
    2021-02-04 08:35

    I've written a small ruby library (puffing-billy) for rspec+capybara that does exactly this -- it injects a proxy in between your browser and the outside world and allows you to fake responses to specific requests.

    Example:

    describe 'fetching badges from stackoverflow API' do
      it 'should show a nice message when you have no badges' do
        # stub some JSONP
        proxy.stub('http://api.stackoverflow.com/1.1/users/1/badges',
                   :jsonp => { :badges => [] })
    
        visit '/my_badges'
        page.should have_content("You don't have any badges :(")
      end
    end
    

提交回复
热议问题