Class: RSpec::Cassette::NetConnectManager

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/cassette/net_connect_manager.rb

Defined Under Namespace

Classes: IgnoredRequest

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ NetConnectManager

Returns a new instance of NetConnectManager.



10
11
12
# File 'lib/rspec/cassette/net_connect_manager.rb', line 10

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#disable!Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rspec/cassette/net_connect_manager.rb', line 14

def disable!
  return if @configuration.allow_http_connections_when_no_cassette

  options = {}
  options[:allow_localhost] = true if @configuration.ignore_localhost

  allow_list = build_allow_list
  options[:allow] = allow_list unless allow_list.empty?

  WebMock.disable_net_connect!(**options)
end

#restore!Object



26
27
28
29
30
# File 'lib/rspec/cassette/net_connect_manager.rb', line 26

def restore!
  return if @configuration.allow_http_connections_when_no_cassette

  WebMock.allow_net_connect!
end