Sha256: f42e9d37cce2cb5afa1abc79eab9ef9a6d8005a9516121c716e8996934e61441

Contents?: true

Size: 736 Bytes

Versions: 28

Compression:

Stored size: 736 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").must_equal '1foo'
    body("/foofoo").must_equal '2foofoo'
    body("/foofoofoo").must_equal '3foofoofoo'
    status("/foofoofoofoo").must_equal 404
    status.must_equal 404
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
roda-2.29.0 spec/plugin/hash_matcher_spec.rb
roda-2.28.0 spec/plugin/hash_matcher_spec.rb
roda-2.27.0 spec/plugin/hash_matcher_spec.rb
roda-2.26.0 spec/plugin/hash_matcher_spec.rb
roda-2.25.0 spec/plugin/hash_matcher_spec.rb
roda-2.24.0 spec/plugin/hash_matcher_spec.rb
roda-2.23.0 spec/plugin/hash_matcher_spec.rb
roda-2.22.0 spec/plugin/hash_matcher_spec.rb
roda-2.21.0 spec/plugin/hash_matcher_spec.rb
roda-2.20.0 spec/plugin/hash_matcher_spec.rb
roda-2.19.0 spec/plugin/hash_matcher_spec.rb
roda-2.18.0 spec/plugin/hash_matcher_spec.rb
roda-2.17.0 spec/plugin/hash_matcher_spec.rb
roda-2.16.0 spec/plugin/hash_matcher_spec.rb
roda-2.15.0 spec/plugin/hash_matcher_spec.rb
roda-2.14.0 spec/plugin/hash_matcher_spec.rb
roda-2.13.0 spec/plugin/hash_matcher_spec.rb
roda-2.12.0 spec/plugin/hash_matcher_spec.rb
roda-2.11.0 spec/plugin/hash_matcher_spec.rb
roda-2.10.0 spec/plugin/hash_matcher_spec.rb