Testing that HTTP-request is not made in Rails

fakeweb, rspec, ruby-on-rails

Solution

You should probably try WebMock. It allows you to check the number of times some url was requested.

assert_requested :post, "http://www.example.com", :times => 0

Problem

What is the easiest way to test if HTTP-request is not made? Say, I want my application NOT to send an API call to a remote server, if the user doesn't supply a username. What RSpec test should I write in my Rails app to test that HTTP-request is never made? Can fakeweb help me somehow?

Original source