Sha256: 35a6a8f3b41f04108f36a3b5adab221ea0a8cc7992c69ae3ec32190a8250f2fa

Contents?: true

Size: 731 Bytes

Versions: 4

Compression:

Stored size: 731 Bytes

Contents

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

describe "hash_matcher plugin" do 
  it "should enable the handling of arbitrary hash keys" do
    app(:bare) do 
      plugin :hash_matcher
      hash_matcher(:foos){|v| consume(self.class.cached_matcher(:"foos-#{v}"){/((?:foo){#{v}})/})}
      route do |r|
        r.is :foos=>1 do |f|
          "1#{f}"
        end
        r.is :foos=>2 do |f|
          "2#{f}"
        end
        r.is :foos=>3 do |f|
          "3#{f}"
        end
      end
    end

    body("/foo").should == '1foo'
    body("/foofoo").should == '2foofoo'
    body("/foofoofoo").should == '3foofoofoo'
    status("/foofoofoofoo").should == 404
    status.should == 404
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
roda-2.2.0 spec/plugin/hash_matcher_spec.rb
roda-2.1.0 spec/plugin/hash_matcher_spec.rb
roda-2.0.0 spec/plugin/hash_matcher_spec.rb
roda-1.3.0 spec/plugin/hash_matcher_spec.rb