Class: SPV::Applier
- Inherits:
-
Object
- Object
- SPV::Applier
- Defined in:
- lib/site_prism_vcr/applier.rb
Overview
This class manages defining default fixtures and applying them on an event.
Defined Under Namespace
Classes: EventError
Instance Method Summary collapse
-
#alter_fixtures(&block) ⇒ void
Alters default fixtures and options.
-
#apply_vcr(&block) ⇒ void
Applies fixtures to be used for stubbing HTTP interactions caused by an event (click on an element or page loading).
-
#initialize(node, &block) ⇒ Applier
constructor
A new instance of Applier.
-
#shift_event(&block) ⇒ SPV::Applier
Stores a block with an action (click, scroll down, mouse over etc) VCR should be applied on.
Constructor Details
#initialize(node, &block) ⇒ Applier
Returns a new instance of Applier.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/site_prism_vcr/applier.rb', line 7 def initialize(node, &block) @node, @options = node, Options.new adjuster = DSL::InitialAdjuster.new(@options) if block_given? adjuster.instance_eval &block end @fixtures = adjuster.prepare_fixtures end |
Instance Method Details
#alter_fixtures(&block) ⇒ void
This method returns an undefined value.
Alters default fixtures and options.
48 49 50 51 52 |
# File 'lib/site_prism_vcr/applier.rb', line 48 def alter_fixtures(&block) @fixtures = adjust_fixtures( @options, &block ) end |
#apply_vcr(&block) ⇒ void
This method returns an undefined value.
Applies fixtures to be used for stubbing HTTP interactions caused by an event (click on an element or page loading).
Makes a defined waiter to meet expectation before ejecting fixtures from VCR.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/site_prism_vcr/applier.rb', line 67 def apply_vcr(&block) verify_define_event! fixtures, = @fixtures, @options. if block_given? fixtures = adjust_fixtures(, &block) end fixtures_manager = Fixtures::Manager.inject( fixtures, ) @event_action.call Waiter.wait( @node, fixtures_manager, ) end |
#shift_event(&block) ⇒ SPV::Applier
Stores a block with an action (click, scroll down, mouse over etc) VCR should be applied on.
This block will be called over an object VCR linked to.
Example:
@my_element.shift_event do
self.click
end
33 34 35 36 37 |
# File 'lib/site_prism_vcr/applier.rb', line 33 def shift_event(&block) @event_action = block self end |