Sha256: 37d1390155b52146136188b25804947e9b82b1e4aaf4dfe34444d7d56e7fec7a

Contents?: true

Size: 965 Bytes

Versions: 30

Compression:

Stored size: 965 Bytes

Contents

require_relative "../spec_helper"

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
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
roda-3.9.0 spec/plugin/backtracking_array_spec.rb
roda-3.8.0 spec/plugin/backtracking_array_spec.rb
roda-3.7.0 spec/plugin/backtracking_array_spec.rb
roda-3.6.0 spec/plugin/backtracking_array_spec.rb
roda-3.5.0 spec/plugin/backtracking_array_spec.rb
roda-3.4.0 spec/plugin/backtracking_array_spec.rb
roda-3.3.0 spec/plugin/backtracking_array_spec.rb
roda-3.2.0 spec/plugin/backtracking_array_spec.rb
roda-3.1.0 spec/plugin/backtracking_array_spec.rb
roda-3.0.0 spec/plugin/backtracking_array_spec.rb