Module: EndpointStub

Defined in:
lib/endpoint_stub.rb,
lib/endpoint_stub/version.rb

Defined Under Namespace

Classes: Config

Constant Summary collapse

VERSION =
"1.4.5"

Class Method Summary collapse

Class Method Details

.activate!Object

Enable endpoint stubbing. This will cause all HTTP requests to raise an error, as per WebMock, unless relating to an ActiveResource model.



17
18
19
20
# File 'lib/endpoint_stub.rb', line 17

def self.activate!
  WebMock.enable!
  Config.activated = true
end

.deactivate!Object

Disable endpoint stubbing. This allows real HTTP requests again.



23
24
25
26
# File 'lib/endpoint_stub.rb', line 23

def self.deactivate!
  WebMock.disable!
  Config.activated = false
end

.refresh!Object

Calls deactivate, clears all stubs, then re-activates.



29
30
31
32
33
# File 'lib/endpoint_stub.rb', line 29

def self.refresh!
  deactivate!
  Endpoint::Stub.clear!
  activate!
end