Sha256: 98cb1cdda247aa864a8a6851aa24fb2e96fd2addda4702501b7f0595f3914063

Contents?: true

Size: 917 Bytes

Versions: 23

Compression:

Stored size: 917 Bytes

Contents

require_relative "../spec_helper"

describe "response_request plugin" do
  it "gives the response access to the request" do
    app(:response_request) do
      response.request.post? ? "b" : "a"
    end

    body.must_equal "a"
    body('REQUEST_METHOD'=>'POST').must_equal "b"
  end

  it "should work with error_handler plugin" do
    app(:bare) do
      plugin :response_request

      plugin :error_handler do |_|
        response.request.post? ? "b" : "a"
      end
      
      route{raise}
    end

    body.must_equal "a"
    body('REQUEST_METHOD'=>'POST').must_equal "b"
  end

  it "should work with class_level_routing plugin" do
    app(:bare) do
      plugin :response_request
      plugin :class_level_routing
      
      is '' do |_|
        response.request.post? ? "b" : "a"
      end
      
      route{}
    end

    body.must_equal "a"
    body('REQUEST_METHOD'=>'POST').must_equal "b"
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

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