Sha256: 44295cbfa2229d7a6b5c634cf529b14eeaf84ea2a5728c70fa9d932cd65e85b7

Contents?: true

Size: 853 Bytes

Versions: 2

Compression:

Stored size: 853 Bytes

Contents

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

describe "r.run" do
  it "should allow composition of apps" do
    a = app do |r|
      r.on "services/:id" do |id|
        "View #{id}"
      end
    end

    app(:new) do |r|
      r.on "provider" do
        r.run a
      end
    end

    body("/provider/services/101").should == 'View 101'
  end

  it "modifies SCRIPT_NAME/PATH_INFO when calling run" do
    a = app{|r| "#{r.script_name}|#{r.path_info}"}
    app(:static_path_info){|r| r.on("a"){r.run a}}
    body("/a/b").should == "/a|/b"
  end

  it "restores SCRIPT_NAME/PATH_INFO before returning from run" do
    a = app{|r| "#{r.script_name}|#{r.path_info}"}
    app(:static_path_info){|r| s = catch(:halt){r.on("a"){r.run a}}; "#{s[2].join}%#{r.script_name}|#{r.path_info}"}
    body("/a/b").should == "/a|/b%|/a/b"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roda-2.2.0 spec/composition_spec.rb
roda-2.1.0 spec/composition_spec.rb