class SPV::Fixtures::Manager
Takes cares about inserting and ejecting fixtures from Vcr.
Public Class Methods
inject(fixtures, options)
click to toggle source
Initializes a new instance of the fixtures manager class, injects given fixtures into VCR, returns an instance of the fixtures manager class
@param fixtures [SPV::Fixtures] List of fixtures. @param options [SPV::Options] An object with all options.
@return [SPV::Fixtures::Manager]
# File lib/site_prism_vcr/fixtures/manager.rb, line 14 def self.inject(fixtures, options) manager = new(fixtures, options) manager.inject manager end
new(fixtures, options)
click to toggle source
Initializes a new instance
@param fixtures [SPV::Fixtures] List of fixtures. @param options [SPV::Options] An object with all options.
@return [void]
# File lib/site_prism_vcr/fixtures/manager.rb, line 26 def initialize(fixtures, options) @fixtures, @options = fixtures, options end
Public Instance Methods
eject()
click to toggle source
Ejects only fixtures from Vcr which are injected by this instance of the fixtures manager class.
@return [void]
# File lib/site_prism_vcr/fixtures/manager.rb, line 49 def eject inserted_names = @fixtures.map(&:name) # TODO: find better way, may be some pull request to the VCR? VCR.send(:cassettes).delete_if do |cassette| if remove = inserted_names.include?(cassette.name) cassette.eject end remove end end
inject()
click to toggle source
Injects given fixtures to Vcr.
@return [void]
@raise [ArgumentError] If a list of fixtures is empty.
# File lib/site_prism_vcr/fixtures/manager.rb, line 35 def inject raise ArgumentError.new( 'No fixtures were specified to insert them into VCR' ) if @fixtures.size == 0 @fixtures.each do |fixture| VCR.insert_cassette fixture.name, fixture.options end end