Sha256: 604fcd122218676974c5ce36d0d6b0c8b6136c48f3c23273abf8933227eac9f7

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

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

describe "request.path, .remaining_path, and .matched_path" do
  it "should return the script name and path_info as a string" do
    app do |r|
      r.on "foo" do
        "#{r.path}:#{r.matched_path}:#{r.remaining_path}"
      end
    end

    body("/foo/bar").should ==  "/foo/bar:/foo:/bar"
  end
end

describe "request.halt" do
  it "should return rack response as argument given it as argument" do
    app do |r|
      r.halt [200, {}, ['foo']]
    end

    body.should ==  "foo"
  end

  it "should use current response if no argument is given" do
    app do |r|
      response.write('foo')
      r.halt
    end

    body.should ==  "foo"
  end
end

describe "request.scope" do
  it "should return roda instance" do
    app(:bare) do
      attr_accessor :b

      route do |r|
        self.b = 'a'
        request.scope.b
      end
    end

    body.should ==  "a"
  end
end

describe "request.inspect" do
  it "should return information about request" do
    app(:bare) do
      def self.inspect
        'Foo'
      end

      route do |r|
        request.inspect
      end
    end

    body('/a/b').should ==  "#<Foo::RodaRequest GET /a/b>"
    body('REQUEST_METHOD'=>'POST').should ==  "#<Foo::RodaRequest POST />"
  end
end

describe "TERM.inspect" do
  it "should return TERM" do
    app do |r|
      r.class::TERM.inspect
    end

    body.should ==  "TERM"
  end
end

describe "roda_class" do
  it "should return the related roda subclass" do
    app do |r|
      self.class.opts[:a] = 'a'
      r.class.roda_class.opts[:a] + r.roda_class.opts[:a]
    end

    body.should ==  "aa"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roda-2.2.0 spec/request_spec.rb
roda-2.1.0 spec/request_spec.rb
roda-2.0.0 spec/request_spec.rb