Sha256: b18045cd80adf2f05a0e216d8615b5b79dde05da57f3f3162c8779dca229aca4

Contents?: true

Size: 1.68 KB

Versions: 10

Compression:

Stored size: 1.68 KB

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

describe "symbol_matchers plugin" do 
  it "allows symbol specific regexps" do
    app(:bare) do
      plugin :symbol_matchers
      symbol_matcher(:f, /(f+)/)

      route do |r|
        r.is :d do |d|
          "d#{d}"
        end

        r.is "foo:optd" do |o|
          "foo#{o.inspect}"
        end

        r.is "bar:opt" do |o|
          "bar#{o.inspect}"
        end

        r.is "format:format" do |f|
          "format#{f.inspect}"
        end

        r.is :f do |f|
          "f#{f}"
        end

        r.is 'q:rest' do |r|
          "rest#{r}"
        end

        r.is :w do |w|
          "w#{w}"
        end

        r.is ':d/:w/:f' do |d, w, f|
          "dwf#{d}#{w}#{f}"
        end
      end
    end

    status.should == 404
    body("/1").should == 'd1'
    body("/11232135").should == 'd11232135'
    body("/a").should == 'wa'
    body("/1az0").should == 'w1az0'
    body("/f").should == 'ff'
    body("/foo").should == 'foonil'
    body("/foo/123").should == 'foo"123"'
    status("/foo/bar").should == 404
    status("/foo/123/a").should == 404
    body("/bar").should == 'barnil'
    body("/bar/foo").should == 'bar"foo"'
    status("/bar/foo/baz").should == 404
    body("/format").should == 'formatnil'
    body("/format.json").should == 'format"json"'
    status("/format.").should == 404
    body("/ffffffffffffffff").should == 'fffffffffffffffff'
    status("/-").should == 404
    body("/1/1a/f").should == 'dwf11af'
    body("/12/1azy/fffff").should == 'dwf121azyfffff'
    status("/1/f/a").should == 404
    body("/qa/b/c/d//f/g").should == 'resta/b/c/d//f/g'
    body('/q').should == 'rest'
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
roda-cj-1.0.5 spec/plugin/symbol_matchers_spec.rb
roda-cj-1.0.4 spec/plugin/symbol_matchers_spec.rb
roda-cj-1.0.3 spec/plugin/symbol_matchers_spec.rb
roda-cj-1.0.2 spec/plugin/symbol_matchers_spec.rb
roda-cj-1.0.1 spec/plugin/symbol_matchers_spec.rb
roda-cj-1.0.0 spec/plugin/symbol_matchers_spec.rb
roda-1.0.0 spec/plugin/symbol_matchers_spec.rb
roda-cj-0.9.6 spec/plugin/symbol_matchers_spec.rb
roda-cj-0.9.5 spec/plugin/symbol_matchers_spec.rb
roda-cj-0.9.4 spec/plugin/symbol_matchers_spec.rb