Module: TCR

Extended by:
TCR
Included in:
TCR
Defined in:
lib/tcr/configuration.rb,
lib/tcr.rb,
lib/tcr/errors.rb,
lib/tcr/version.rb,
lib/tcr/cassette.rb,
lib/tcr/recordable_tcp_socket.rb,
lib/tcr/net/ldap.rb

Overview

rubocop:disable Style/FrozenStringLiteralComment

Defined Under Namespace

Classes: Cassette, Configuration, DirectionMismatchError, ExtraSessionsError, NoCassetteError, NoMoreSessionsError, RecordableSSLSocket, RecordableTCPSocket, TCRError

Constant Summary collapse

VERSION =
'0.3.2'

Instance Method Summary collapse

Instance Method Details

#cassetteObject



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

def cassette
  @cassette
end

#cassette=(val) ⇒ Object



27
28
29
# File 'lib/tcr.rb', line 27

def cassette=(val)
  @cassette = val
end

#configurationObject



19
20
21
# File 'lib/tcr.rb', line 19

def configuration
  @configuration ||= Configuration.new
end

#configure {|configuration| ... } ⇒ Object

Yields:



15
16
17
# File 'lib/tcr.rb', line 15

def configure
  yield configuration
end

#disabledObject



31
32
33
# File 'lib/tcr.rb', line 31

def disabled
  @disabled || false
end

#disabled=(val) ⇒ Object



35
36
37
# File 'lib/tcr.rb', line 35

def disabled=(val)
  @disabled = val
end

#save_sessionObject



39
# File 'lib/tcr.rb', line 39

def save_session; end

#turned_off(&block) ⇒ Object

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
59
# File 'lib/tcr.rb', line 52

def turned_off(&block)
  raise ArgumentError, '`TCR.turned_off` requires a block.' unless block

  current_hook_tcp_ports = configuration.hook_tcp_ports
  configuration.hook_tcp_ports = []
  yield
  configuration.hook_tcp_ports = current_hook_tcp_ports
end

#use_cassette(name, options = {}, &block) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/tcr.rb', line 41

def use_cassette(name, options = {}, &block)
  raise ArgumentError, '`TCR.use_cassette` requires a block.' unless block

  TCR.cassette = Cassette.new(name)
  yield
  TCR.cassette.save
  TCR.cassette.check_hits_all_sessions if options[:hit_all] || configuration.hit_all
ensure
  TCR.cassette = nil
end