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.28.0 spec/plugin/backtracking_array_spec.rb
roda-3.27.0 spec/plugin/backtracking_array_spec.rb
roda-3.26.0 spec/plugin/backtracking_array_spec.rb
roda-3.25.0 spec/plugin/backtracking_array_spec.rb
roda-3.24.0 spec/plugin/backtracking_array_spec.rb
roda-3.23.0 spec/plugin/backtracking_array_spec.rb
roda-3.22.0 spec/plugin/backtracking_array_spec.rb
roda-3.21.0 spec/plugin/backtracking_array_spec.rb
roda-3.20.0 spec/plugin/backtracking_array_spec.rb
roda-3.19.0 spec/plugin/backtracking_array_spec.rb
roda-3.18.0 spec/plugin/backtracking_array_spec.rb
roda-3.17.0 spec/plugin/backtracking_array_spec.rb
roda-3.16.0 spec/plugin/backtracking_array_spec.rb
roda-3.15.0 spec/plugin/backtracking_array_spec.rb
roda-3.14.1 spec/plugin/backtracking_array_spec.rb
roda-3.14.0 spec/plugin/backtracking_array_spec.rb
roda-3.13.0 spec/plugin/backtracking_array_spec.rb
roda-3.12.0 spec/plugin/backtracking_array_spec.rb
roda-3.11.0 spec/plugin/backtracking_array_spec.rb
roda-3.10.0 spec/plugin/backtracking_array_spec.rb