Sha256: 353f328522da03685f3a90b3e8ae3d759e5d0e55d7201df69811785de139c19a

Contents?: true

Size: 1.09 KB

Versions: 26

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'
require 'dugway/path_interpreter'

describe Dugway::PathInterpreter do
  let(:path) { double 'path' }
  let(:interpreter) { described_class.new(path) }

  it "initializes with arguements" do
    expect(interpreter.path).to eq path
  end

  describe "#call" do
    it "handles non-string paths" do
      expect(described_class.new(/regex/).call).to eql /regex/
    end

    it "handles category, artist, and product type paths" do
      expect(described_class.new("/product/:product(.js)").call).to eq(
        %r{^/product/(?<product>(?-mix:[a-z0-9\-_]+))(?-mix:(\.(?<format>js))?)$}
      )
    end

    it "handles products and cart type paths" do
      expect(described_class.new("/products(.js)").call).to eq(
        %r{^/products(?-mix:(\.(?<format>js))?)$}
      )
    end

    it "handles custom pages" do
      expect(described_class.new("/:custom-page").call).to eq(
        %r{^/(?<custom-page>(?-mix:[a-z0-9\-_]+))$}
      )
    end

    it "handles everything else" do
      expect(described_class.new("/checkout").call).to eq(
        %r{^/checkout$}
      )
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dugway-1.1.0 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.14 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.13 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.12 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.10 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.9 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.8 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.7 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.6 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.5 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.4 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.3 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.2 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.1 spec/units/dugway/path_interpreter_spec.rb
dugway-1.0.0 spec/units/dugway/path_interpreter_spec.rb
dugway-0.12.3 spec/units/dugway/path_interpreter_spec.rb
dugway-0.12.2 spec/units/dugway/path_interpreter_spec.rb
dugway-0.12.1 spec/units/dugway/path_interpreter_spec.rb
dugway-0.12.0 spec/units/dugway/path_interpreter_spec.rb
dugway-0.11.4 spec/units/dugway/path_interpreter_spec.rb