Sha256: 4d23b4dc1298effcd0a8443016988611d458e3fa292d26f3eac0ae3c49787e9f
Contents?: true
Size: 1018 Bytes
Versions: 13
Compression:
Stored size: 1018 Bytes
Contents
require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__))) 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
13 entries across 13 versions & 1 rubygems