Module: TCR

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

Defined Under Namespace

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

Constant Summary collapse

VERSION =
"0.4.0"

Instance Method Summary collapse

Instance Method Details

#cassetteObject



21
22
23
# File 'lib/tcr.rb', line 21

def cassette
  @cassette
end

#cassette=(v) ⇒ Object



25
26
27
# File 'lib/tcr.rb', line 25

def cassette=(v)
  @cassette = v
end

#configurationObject



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

def configuration
  @configuration ||= Configuration.new
end

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

Yields:



13
14
15
# File 'lib/tcr.rb', line 13

def configure
  yield configuration
end

#disabledObject



29
30
31
# File 'lib/tcr.rb', line 29

def disabled
  @disabled || false
end

#disabled=(v) ⇒ Object



33
34
35
# File 'lib/tcr.rb', line 33

def disabled=(v)
  @disabled = v
end

#save_sessionObject



37
38
# File 'lib/tcr.rb', line 37

def save_session
end

#turned_off(&block) ⇒ Object

Raises:

  • (ArgumentError)


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

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 = []
  ret_val = yield
  configuration.hook_tcp_ports = current_hook_tcp_ports
  ret_val
end

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



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

def use_cassette(name, options = {}, &block)
  raise ArgumentError, "`TCR.use_cassette` requires a block." unless block
  TCR.cassette = Cassette.new(name)
  ret_val = yield
  TCR.cassette.save
  TCR.cassette.check_hits_all_sessions if options[:hit_all] || configuration.hit_all
  ret_val
ensure
  TCR.cassette = nil
end