class SPV::DSL::Adjuster

This class extends SPV::DSL::InitialAdjuster with new methods which can be used in a block for manipulating fixtures before applying them.

Public Class Methods

new(options, fixtures) click to toggle source
Calls superclass method
# File lib/site_prism_vcr/dsl/adjuster.rb, line 8
def initialize(options, fixtures)
  super options

  @options, @fixtures = options, fixtures
  @action = Action.new(:replace)
end

Public Instance Methods

exchange(old_fixtures, new_fixtures) click to toggle source

Exchanges certain default fixtures with another fixtures.

@param old_fixtures [String, Array<String>] List of fixtures which should be removed.

If string is passed instead of an array, it will be converted to an array.

@param new_fixtures [String, Array<String>] List of fixtures which should added.

If string is passed instead of an array, it will be converted to an array.

@return [void]

@api public

# File lib/site_prism_vcr/dsl/adjuster.rb, line 63
def exchange(old_fixtures, new_fixtures)
  home_path_modifier = Fixtures::Modifiers::ShortcutPath.new(@options)

  old_fixtures = [old_fixtures] unless old_fixtures.is_a?(Array)
  new_fixtures = [new_fixtures] unless new_fixtures.is_a?(Array)

  old_fixtures, new_fixtures = @fixtures_handler.handle_set_raws(
    old_fixtures,
    new_fixtures,
    [home_path_modifier]
  )

  @fixtures = @fixtures.exchange(
    old_fixtures,
    new_fixtures
  )
end
prepare_fixtures() click to toggle source

Performs the replace action when no explicit action is defined in a block for manipulating fixtures before applying them. Otherwise, performs a defined action (union or replace).

@return [SPV::Fixtures] A set of prepared fixtures.

@api public

# File lib/site_prism_vcr/dsl/adjuster.rb, line 101
def prepare_fixtures
  @fixtures.public_send(
    @action.action,
    @tmp_keeper.fixtures
  )
end
replace() click to toggle source

Defines the replace action as an action which will be performed over cassettes while adjusting cassettes.

Example:

@page.details_link.click_and_apply_vcr do
  fixtures ['no_found']
  replace
end

In this case ‘no_found’ cassette will be used instead of default cassettes defined for ‘details_link’.

@return [void]

@api public

# File lib/site_prism_vcr/dsl/adjuster.rb, line 30
def replace
  @action.action = :replace
end
union() click to toggle source

Defines the union action as an action which will be performed over cassettes while adjusting cassettes.

Example:

@page.details_link.click_and_apply_vcr do
  fixtures ['no_found']
  union
end

In this case ‘no_found’ cassette will be used a long with default cassettes.

@return [void]

@api public

# File lib/site_prism_vcr/dsl/adjuster.rb, line 49
def union
  @action.action = :union
end
waiter_options(options) click to toggle source

Redefines default waiter options or if default waiter options is not defined, it defines new options for a waiter. This method doesn’t redefine all default options, it redefines only options passed in a hash.

@param options [Hash] Options for a waiter

@return [void]

@api public

# File lib/site_prism_vcr/dsl/adjuster.rb, line 90
def waiter_options(options)
  @options.merge_waiter_options!(options)
end