Class: SPV::Fixtures::Manager
- Inherits:
-
Object
- Object
- SPV::Fixtures::Manager
- Defined in:
- lib/site_prism_vcr/fixtures/manager.rb
Overview
Takes cares about inserting and ejecting fixtures from Vcr.
Class Method Summary collapse
-
.inject(fixtures, options) ⇒ SPV::Fixtures::Manager
Initializes a new instance of the fixtures manager class, injects given fixtures into VCR, returns an instance of the fixtures manager class.
Instance Method Summary collapse
-
#eject ⇒ void
Ejects only fixtures from Vcr which are injected by this instance of the fixtures manager class.
-
#initialize(fixtures, options) ⇒ void
constructor
Initializes a new instance.
-
#inject ⇒ void
Injects given fixtures to Vcr.
Constructor Details
#initialize(fixtures, options) ⇒ void
Initializes a new instance
26 27 28 |
# File 'lib/site_prism_vcr/fixtures/manager.rb', line 26 def initialize(fixtures, ) @fixtures, @options = fixtures, end |
Class Method Details
.inject(fixtures, options) ⇒ SPV::Fixtures::Manager
Initializes a new instance of the fixtures manager class, injects given fixtures into VCR, returns an instance of the fixtures manager class
14 15 16 17 18 |
# File 'lib/site_prism_vcr/fixtures/manager.rb', line 14 def self.inject(fixtures, ) manager = new(fixtures, ) manager.inject manager end |
Instance Method Details
#eject ⇒ void
This method returns an undefined value.
Ejects only fixtures from Vcr which are injected by this instance of the fixtures manager class.
49 50 51 52 53 54 55 56 57 58 59 60 |
# 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 ⇒ void
This method returns an undefined value.
Injects given fixtures to Vcr.
35 36 37 38 39 40 41 42 43 |
# 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. end end |