Sha256: d9ad6d0967fdc8b400c25ab517debea1d3d1ea05f593e68e0fed653a1e118209

Contents?: true

Size: 1.03 KB

Versions: 27

Compression:

Stored size: 1.03 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.must_equal 404

      body("/a").must_equal 'a'
      body("/a/b").must_equal 'a/b'
      status("/a/b/").must_equal 404

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

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

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

Version data entries

27 entries across 27 versions & 1 rubygems

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