Sha256: 7b6a349dba21571eb00a1a9cd50af5339d9992d44345b169adf659097864d36d

Contents?: true

Size: 1.36 KB

Versions: 30

Compression:

Stored size: 1.36 KB

Contents

require_relative "../spec_helper"

describe "run_handler plugin" do 
  it "makes r.run :not_found=>:pass keep going on 404" do
    pr = proc{|env| [(env['PATH_INFO'] == '/a' ? 404 : 201), {}, ['b']]}
    app(:run_handler) do |r|
      r.run pr, :not_found=>:pass
      'a'
    end

    status.must_equal 201
    body.must_equal 'b'
    status('/a').must_equal 200
    body('/a').must_equal 'a'
  end

  it "makes r.run with a block yield rack app to block, and have it be thrown afterward" do
    pr = proc{|env| [(env['PATH_INFO'] == '/a' ? 404 : 201), {}, ['b']]}
    app(:run_handler) do |r|
      r.run(pr){|a| a[0] *= 2}
      'a'
    end

    status.must_equal 402
    status('/a').must_equal 808
  end

  it "works when both :not_found=>:pass and block are given" do
    pr = proc{|env| [(env['PATH_INFO'] == '/a' ? 202 : 201), {}, ['b']]}
    app(:run_handler) do |r|
      r.run(pr, :not_found=>:pass){|a| a[0] *= 2}
      'a'
    end

    status.must_equal 402
    body.must_equal 'b'
    status('/a').must_equal 200
    body('/a').must_equal 'a'
  end

  it "makes r.run work normally if not given an option or block" do
    pr = proc{|env| [(env['PATH_INFO'] == '/a' ? 404 : 201), {}, ['b']]}
    app(:run_handler) do |r|
      r.run pr
      'a'
    end

    status.must_equal 201
    body.must_equal 'b'
    status('/a').must_equal 404
    body('/a').must_equal 'b'
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
roda-3.28.0 spec/plugin/run_handler_spec.rb
roda-3.27.0 spec/plugin/run_handler_spec.rb
roda-3.26.0 spec/plugin/run_handler_spec.rb
roda-3.25.0 spec/plugin/run_handler_spec.rb
roda-3.24.0 spec/plugin/run_handler_spec.rb
roda-3.23.0 spec/plugin/run_handler_spec.rb
roda-3.22.0 spec/plugin/run_handler_spec.rb
roda-3.21.0 spec/plugin/run_handler_spec.rb
roda-3.20.0 spec/plugin/run_handler_spec.rb
roda-3.19.0 spec/plugin/run_handler_spec.rb
roda-3.18.0 spec/plugin/run_handler_spec.rb
roda-3.17.0 spec/plugin/run_handler_spec.rb
roda-3.16.0 spec/plugin/run_handler_spec.rb
roda-3.15.0 spec/plugin/run_handler_spec.rb
roda-3.14.1 spec/plugin/run_handler_spec.rb
roda-3.14.0 spec/plugin/run_handler_spec.rb
roda-3.13.0 spec/plugin/run_handler_spec.rb
roda-3.12.0 spec/plugin/run_handler_spec.rb
roda-3.11.0 spec/plugin/run_handler_spec.rb
roda-3.10.0 spec/plugin/run_handler_spec.rb