Sha256: b96a3da6d242d292b2638b7cacba25f29dec956f263d52fee91a6161b10fe7e1
Contents?: true
Size: 971 Bytes
Versions: 3
Compression:
Stored size: 971 Bytes
Contents
module VCR module Middleware class CassetteArguments def initialize @name = nil @options = {} end def name(name = nil) @name = name if name @name end def options(options = {}) @options.merge!(options) end end class Rack include VCR::VariableArgsBlockCaller def initialize(app, &block) raise ArgumentError.new("You must provide a block to set the cassette options") unless block @app, @cassette_arguments_block, @mutex = app, block, Mutex.new end def call(env) @mutex.synchronize do VCR.use_cassette(*cassette_arguments(env)) do @app.call(env) end end end private def cassette_arguments(env) arguments = CassetteArguments.new call_block(@cassette_arguments_block, arguments, env) [arguments.name, arguments.options] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vcr-2.0.0.rc1 | lib/vcr/middleware/rack.rb |
vcr-2.0.0.beta2 | lib/vcr/middleware/rack.rb |
vcr-2.0.0.beta1 | lib/vcr/middleware/rack.rb |