Sha256: 42a256628a0342ebbcebdbaa8cbc8cb7b3fcfbae77dd7e4162425b283caabd88

Contents?: true

Size: 914 Bytes

Versions: 2

Compression:

Stored size: 914 Bytes

Contents

module SPV
  class Fixtures
    module Modifiers
      # It takes a fixture and adds a path to it
      class Path
        def initialize(options)
          @options = options
        end

        def modify(fixture)
          if fixture.has_link_to_home_path?
            raise HomePathError.new(
              "You cannot use the home 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 home path as a path name." <<
              "Example: path('~/', ['#{fixture.clean_name}'])"
            )
          else
            path = @options.path
            path = path + '/' unless path[-1, 1] == '/'

            fixture.add_path(path)
          end
        end

        class HomePathError < ArgumentError; end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
site_prism.vcr-0.1.0 lib/site_prism_vcr/fixtures/modifiers/path.rb
site_prism.vcr-0.0.1 lib/site_prism_vcr/fixtures/modifiers/path.rb