Sha256: a8d3b14174f76c5aa712e9ef41a83b6091003063f9850ac750f437e16f92ec53

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

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

describe "backtracking_array plugin" do 
  it "backtracks to next entry in array if later matcher fails" do
    app(:backtracking_array) do |r|
      r.is %w'a a/b' do |id|
        id
      end

      r.is %w'c c/d', %w'd e' do |a, b|
        "#{a}-#{b}" 
      end

      r.is [%w'f f/g', %w'g g/h'] do |id|
        id
      end
    end

    tests = lambda do
      status.should == 404

      body("/a").should == 'a'
      body("/a/b").should == 'a/b'
      status("/a/b/").should == 404

      body("/c/d").should == 'c-d'
      body("/c/e").should == 'c-e'
      body("/c/d/d").should == 'c/d-d'
      body("/c/d/e").should == 'c/d-e'
      status("/c/d/").should == 404

      body("/f").should == 'f'
      body("/f/g").should == 'f/g'
      body("/g").should == 'g'
      body("/g/h").should == 'g/h'
      status("/f/g/").should == 404
      status("/g/h/").should == 404
    end

    tests.call
    app.plugin(:static_path_info)
    tests.call
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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