Class: SPV::Waiter

Inherits:
Object
  • Object
show all
Defined in:
lib/site_prism_vcr/waiter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, fixtures_manager, options) ⇒ Waiter

Returns a new instance of Waiter.



9
10
11
12
13
# File 'lib/site_prism_vcr/waiter.rb', line 9

def initialize(node, fixtures_manager, options)
  @node, @waiter_method = node, options.waiter
  @fixtures_manager = fixtures_manager
  @options = options.waiter_options || {}
end

Class Method Details

.wait(node, fixtures_manager, options) ⇒ Object



3
4
5
6
7
# File 'lib/site_prism_vcr/waiter.rb', line 3

def self.wait(node, fixtures_manager, options)
  waiter = new(node, fixtures_manager, options)
  waiter.wait
  waiter
end

Instance Method Details

#waitObject



15
16
17
18
19
20
21
22
23
# File 'lib/site_prism_vcr/waiter.rb', line 15

def wait
  if @waiter_method
    @node.instance_eval &@waiter_method

    if @options.fetch(:eject_cassettes, true)
      @fixtures_manager.eject
    end
  end
end

#with_new_options(options) ⇒ Object



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

def with_new_options(options)
  self.class.new(@node, @fixtures_manager, options)
end