You could argue that it's a bad idea, but I've created a model that
accesses the web in its after_create method:
class Premise < ActiveRecord::Base
after_create :lookup_elevation
...
def lookup_elevation
(call google elevation service via Mechanize)
end
...
end
Of course, this immediately broke all of my RSpec tests, since
creating a Premise (even via FactoryGirl) will call lookup_elevation
which raises a WebMock::NetConnectNotAllowedError.
Is there a simple way to create a global stub? Or do I have to
sprinkle webmock stubs throughout my RSpec tests? (The latter would
make me sad, since it doesn't seem right to be stubbing web access in
tests that have nothing to to with accessing the web.)
TIA.
- ff