Class: VCR::Request::Typed

Inherits:
self
  • Object
show all
Defined in:
lib/vcr/structs.rb

Overview

Decorates a VCR::Request with its current type.

Direct Known Subclasses

FiberAware

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, type) ⇒ Typed

Returns a new instance of Typed.

Parameters:

  • request (Request)

    the request

  • type (Symbol)

    the type. Should be one of ‘:ignored`, `:stubbed`, `:recordable` or `:unhandled`.



243
244
245
246
# File 'lib/vcr/structs.rb', line 243

def initialize(request, type)
  @type = type
  super(request)
end

Instance Attribute Details

#typeSymbol (readonly)

Returns One of ‘:ignored`, `:stubbed`, `:recordable` or `:unhandled`.

Returns:

  • (Symbol)

    One of ‘:ignored`, `:stubbed`, `:recordable` or `:unhandled`.



239
240
241
# File 'lib/vcr/structs.rb', line 239

def type
  @type
end

Instance Method Details

#externally_stubbed?Boolean

Returns whether or not this request is being stubbed by an external library (such as WebMock).

Returns:

  • (Boolean)

    whether or not this request is being stubbed by an external library (such as WebMock).

See Also:



264
265
266
# File 'lib/vcr/structs.rb', line 264

def externally_stubbed?
  type == :externally_stubbed
end

#ignored?Boolean

Returns whether or not this request is being ignored.

Returns:

  • (Boolean)

    whether or not this request is being ignored



249
250
251
# File 'lib/vcr/structs.rb', line 249

def ignored?
  type == :ignored
end

#real?Boolean

Note:

VCR allows ‘:ignored` and `:recordable` requests to be made for real.

Returns whether or not this request will be made for real.

Returns:

  • (Boolean)

    whether or not this request will be made for real.



280
281
282
# File 'lib/vcr/structs.rb', line 280

def real?
  ignored? || recordable?
end

#recordable?Boolean

Returns whether or not this request will be recorded.

Returns:

  • (Boolean)

    whether or not this request will be recorded.



269
270
271
# File 'lib/vcr/structs.rb', line 269

def recordable?
  type == :recordable
end

#stubbed?Boolean

Returns whether or not this request will be stubbed. It may be stubbed by an external library or by VCR.

Returns:

  • (Boolean)

    whether or not this request will be stubbed. It may be stubbed by an external library or by VCR.

See Also:



288
289
290
# File 'lib/vcr/structs.rb', line 288

def stubbed?
  stubbed_by_vcr? || externally_stubbed?
end

#stubbed_by_vcr?Boolean

Returns whether or not this request is being stubbed by VCR.

Returns:

  • (Boolean)

    whether or not this request is being stubbed by VCR

See Also:



256
257
258
# File 'lib/vcr/structs.rb', line 256

def stubbed_by_vcr?
  type == :stubbed_by_vcr
end

#unhandled?Boolean

Returns whether or not VCR knows how to handle this request.

Returns:

  • (Boolean)

    whether or not VCR knows how to handle this request.



274
275
276
# File 'lib/vcr/structs.rb', line 274

def unhandled?
  type == :unhandled
end