Sha256: ba9ea79c31e83eac9fd0bc86b783a74a503108fd4de75c47978c76ecb325e58c

Contents?: true

Size: 974 Bytes

Versions: 30

Compression:

Stored size: 974 Bytes

Contents

require_relative "../spec_helper"

describe "match_affix plugin" do 
  it "allows changing the match prefix/suffix" do
    app(:bare) do
      plugin :match_affix, "", /(\/|\z)/

      route do |r|
        r.on "/albums" do |b|
          r.on "b/:id" do |id, s|
            "b-#{b}-#{id}-#{s.inspect}"
          end

          "albums-#{b}"
        end
      end
    end

    body("/albums/a/1").must_equal 'albums-/'
    body("/albums/b/1").must_equal 'b-/-1-""'
  end

  it "handles extra trailing slash only" do
    app(:bare) do
      plugin :match_affix, nil, /(?:\/\z|(?=\/|\z))/

      route do |r|
        r.on "albums" do
          r.on "b" do
            "albums/b:#{r.remaining_path}"
          end

          "albums:#{r.remaining_path}"
        end
      end
    end

    body("/albums/a").must_equal 'albums:/a'
    body("/albums/a/").must_equal 'albums:/a/'
    body("/albums/b").must_equal 'albums/b:'
    body("/albums/b/").must_equal 'albums/b:'
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
roda-3.28.0 spec/plugin/match_affix_spec.rb
roda-3.27.0 spec/plugin/match_affix_spec.rb
roda-3.26.0 spec/plugin/match_affix_spec.rb
roda-3.25.0 spec/plugin/match_affix_spec.rb
roda-3.24.0 spec/plugin/match_affix_spec.rb
roda-3.23.0 spec/plugin/match_affix_spec.rb
roda-3.22.0 spec/plugin/match_affix_spec.rb
roda-3.21.0 spec/plugin/match_affix_spec.rb
roda-3.20.0 spec/plugin/match_affix_spec.rb
roda-3.19.0 spec/plugin/match_affix_spec.rb
roda-3.18.0 spec/plugin/match_affix_spec.rb
roda-3.17.0 spec/plugin/match_affix_spec.rb
roda-3.16.0 spec/plugin/match_affix_spec.rb
roda-3.15.0 spec/plugin/match_affix_spec.rb
roda-3.14.1 spec/plugin/match_affix_spec.rb
roda-3.14.0 spec/plugin/match_affix_spec.rb
roda-3.13.0 spec/plugin/match_affix_spec.rb
roda-3.12.0 spec/plugin/match_affix_spec.rb
roda-3.11.0 spec/plugin/match_affix_spec.rb
roda-3.10.0 spec/plugin/match_affix_spec.rb