Sha256: 16964e53e96f146d5e0cd0d2750840e01195f0fdfaeb7c794a8ec1b056fef476

Contents?: true

Size: 905 Bytes

Versions: 28

Compression:

Stored size: 905 Bytes

Contents

require File.expand_path("spec_helper", File.dirname(__FILE__))

describe "redirects" do
  it "should be immediately processed" do
    app do |r|
      r.root do
        r.redirect "/hello"
        "Foo"
      end

      r.is "about" do
        r.redirect "/hello", 301
        "Foo"
      end

      r.is 'foo' do
        r.get do
          r.redirect
        end

        r.post do
          r.redirect
        end
      end
    end

    status.must_equal 302
    header('Location').must_equal '/hello'
    body.must_equal ''

    status("/about").must_equal 301
    header('Location', "/about").must_equal '/hello'
    body("/about").must_equal ''

    status("/foo", 'REQUEST_METHOD'=>'POST').must_equal 302
    header('Location', "/foo", 'REQUEST_METHOD'=>'POST').must_equal '/foo'
    body("/foo", 'REQUEST_METHOD'=>'POST').must_equal ''

    proc{req('/foo')}.must_raise(Roda::RodaError)
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

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