Class: SPV::Fixtures::Modifiers::Path

Inherits:
Base
  • Object
show all
Defined in:
lib/site_prism_vcr/fixtures/modifiers/path.rb

Overview

It takes a fixture and adds a path to it.

Defined Under Namespace

Classes: ShortcutPathError

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from SPV::Fixtures::Modifiers::Base

Instance Method Details

#modify(fixture) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/site_prism_vcr/fixtures/modifiers/path.rb', line 8

def modify(fixture)
  if shortcut = fixture.shortcut_path
    raise ShortcutPathError.new(
      "You cannot use a shortcut path while listing fixtures in the 'path' method. " <<
      "Please, use 'fixtures' method for '#{fixture.clean_name}' fixture or " <<
      "you can additionally use the 'path' method where you will specify a shortcut path as a path name." <<
      "Example: path(':#{shortcut}', ['#{fixture.clean_name}'])"
    )
  else
    path = @options.path
    path = path + '/' unless path[-1, 1] == '/'

    fixture.prepend_path(path)
  end
end