Last Updated: February 25, 2016
·
1.96K
· oesmith

Webmock for your browser

Have you ever wondered what your twitter or facebook client-side javascript code does when the API goes down? Have you thought about handling it gracefully, but couldn't work out how to test it actually works?

Try puffing-billy, a new library for stubbing and mocking requests in rspec+capybara request specs. It's like webmock, but it works on requests made by your browser.

Example:

proxy.stub("https://graph.facebook.com:443/me").and_return(:code => 500)
visit "/my/user/page"
page.should have_content "We're sorry, facebook is unavailable. Please try again later"